[UI]: update Ember to 3.27 (#16227)

* Upgrade to 3.25 via ember-cli-update

* v3.25.3...v3.26.1

* v3.26.1...v3.27.0


Co-authored-by: Michael Klein <michael@firstiwaslike.com>
This commit is contained in:
Valeriia Ruban 2023-02-10 13:32:19 -08:00 committed by GitHub
parent 7dda5e8b1d
commit 1d64c98c51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
75 changed files with 709 additions and 407 deletions

3
.changelog/16227.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
ui: update Ember version to 3.27;
```

View File

@ -21,9 +21,7 @@
},
"resolutions": {
"xmlhttprequest-ssl": "^1.6.3",
"ember-basic-dropdown": "3.0.21",
"ember-changeset": "3.10.1",
"validated-changeset": "0.10.0"
"ember-basic-dropdown": "3.0.21"
},
"engines": {
"node": ">=10 <=14"

View File

@ -15,6 +15,7 @@ app/utils/dom/event-target/event-target-shim/event.js
# misc
/coverage/
!.*
.*/
.eslintcache
# ember-try

View File

@ -72,5 +72,10 @@ module.exports = {
'node/no-unpublished-require': 'off',
}),
},
{
// Test files:
files: ['tests/**/*-test.{js,ts}'],
extends: ['plugin:qunit/recommended'],
},
],
};

View File

@ -1,7 +1,7 @@
'use strict';
module.exports = {
extends: 'octane',
extends: 'recommended',
rules: {
'no-partial': false,
'table-groups': false,

View File

@ -1,8 +1,10 @@
import { validatePresence } from 'ember-changeset-validations/validators';
import validateSometimes from 'ember-changeset-conditional-validations/validators/sometimes';
import validateSometimes from 'consul-ui/validations/sometimes';
export default (schema) => ({
Name: [validatePresence(true)],
Value: validateSometimes([validatePresence(true)], function () {
Value: [
validateSometimes(validatePresence(true), function () {
return this.get('HeaderType') !== 'Present';
}),
],
});

View File

@ -3,11 +3,12 @@ import {
validatePresence,
validateFormat,
} from 'ember-changeset-validations/validators';
import validateSometimes from 'ember-changeset-conditional-validations/validators/sometimes';
import validateSometimes from 'consul-ui/validations/sometimes';
const name = 'intention-permission';
export default (schema) => ({
'*': validateSometimes([validatePresence(true)], function () {
'*': [
validateSometimes(validatePresence(true), function () {
const methods = this.get('HTTP.Methods') || [];
const headers = this.get('HTTP.Header') || [];
const pathType = this.get('HTTP.PathType') || 'NoPath';
@ -19,11 +20,14 @@ export default (schema) => ({
].includes(true);
return !isValid;
}),
],
Action: [validateInclusion({ in: schema[name].Action.allowedValues })],
HTTP: {
Path: validateSometimes([validateFormat({ regex: /^\// })], function () {
Path: [
validateSometimes(validateFormat({ regex: /^\// }), function () {
const pathType = this.get('HTTP.PathType');
return typeof pathType !== 'undefined' && pathType !== 'NoPath';
}),
],
},
});

View File

@ -1,7 +1,8 @@
import { validatePresence, validateLength } from 'ember-changeset-validations/validators';
import validateSometimes from 'ember-changeset-conditional-validations/validators/sometimes';
import validateSometimes from 'consul-ui/validations/sometimes';
export default {
'*': validateSometimes([validatePresence(true)], function () {
'*': [
validateSometimes(validatePresence(true), function () {
const action = this.get('Action') || '';
const permissions = this.get('Permissions') || [];
if (action === '' && permissions.length === 0) {
@ -9,10 +10,11 @@ export default {
}
return false;
}),
],
SourceName: [validatePresence(true), validateLength({ min: 1 })],
DestinationName: [validatePresence(true), validateLength({ min: 1 })],
Permissions: [
validateSometimes([validateLength({ min: 1 })], function (changes, content) {
validateSometimes(validateLength({ min: 1 }), function (changes, content) {
return !this.get('Action');
}),
],

View File

@ -0,0 +1,45 @@
/* eslint-disable no-prototype-builtins */
import { get } from '@ember/object';
export default function validateSometimes(validator, condition) {
return guardValidatorWithCondition(validator);
function guardValidatorWithCondition(validator) {
return function (key, newValue, oldValue, changes, content) {
let thisValue = {
get(property) {
if (property.includes('.')) {
let changesValue = get(changes, property);
if (typeof changesValue !== 'undefined') {
return changesValue;
}
// Check if the `changes` value is explicitly undefined,
// or if it's not present at all.
let pathSegments = property.split('.');
let propName = pathSegments.pop();
let objPath = pathSegments.join('.');
let obj = get(changes, objPath);
if (obj && obj.hasOwnProperty && obj.hasOwnProperty(propName)) {
return changesValue;
}
return get(content, property);
}
if (changes.hasOwnProperty(property)) {
return get(changes, property);
} else {
return get(content, property);
}
},
};
if (condition.call(thisValue, changes, content)) {
return validator(key, newValue, oldValue, changes, content);
}
return true;
};
}
}

View File

@ -3,7 +3,7 @@
"packages": [
{
"name": "ember-cli",
"version": "3.24.0",
"version": "3.27.0",
"blueprints": [
{
"name": "app",

View File

@ -13,7 +13,7 @@
"build:staging": "ember build --environment staging",
"build:ci": "ember build --environment test",
"doc:toc": "doctoc README.md",
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel 'lint:!(fix)'",
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"",
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
"lint:hbs": "ember-template-lint .",
"lint:hbs:fix": "ember-template-lint . --fix",
@ -64,9 +64,9 @@
"@docfy/ember": "^0.4.1",
"@ember/optional-features": "^2.0.0",
"@ember/render-modifiers": "^1.0.2",
"@ember/test-helpers": "^2.1.4",
"@glimmer/component": "^1.0.3",
"@glimmer/tracking": "^1.0.3",
"@ember/test-helpers": "^2.2.5",
"@glimmer/component": "^1.0.4",
"@glimmer/tracking": "^1.0.4",
"@hashicorp/design-system-components": "^1.0.4",
"@hashicorp/design-system-tokens": "^1.0.0",
"@hashicorp/ember-cli-api-double": "^4.0.0",
@ -107,29 +107,28 @@
"ember-assign-helper": "^0.3.0",
"ember-auto-import": "^2.4.2",
"ember-can": "^4.2.0",
"ember-changeset-conditional-validations": "^0.6.0",
"ember-changeset-validations": "~3.9.0",
"ember-cli": "~3.24.0",
"ember-cli-app-version": "^4.0.0",
"ember-cli-babel": "^7.23.0",
"ember-changeset-validations": "~3.15.2",
"ember-cli": "~3.27.0",
"ember-cli-app-version": "^5.0.0",
"ember-cli-babel": "^7.26.6",
"ember-cli-code-coverage": "^1.0.0-beta.4",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-deprecation-workflow": "^2.1.0",
"ember-cli-flash": "^2.1.1",
"ember-cli-htmlbars": "^5.3.1",
"ember-cli-htmlbars": "^5.7.1",
"ember-cli-inject-live-reload": "^2.0.2",
"ember-cli-page-object": "^1.17.10",
"ember-cli-page-object": "^1.17.11",
"ember-cli-postcss": "^8.1.0",
"ember-cli-sri": "^2.1.1",
"ember-cli-string-helpers": "^5.0.0",
"ember-cli-template-lint": "^2.0.1",
"ember-cli-terser": "^4.0.1",
"ember-cli-terser": "^4.0.2",
"ember-cli-yadda": "^0.7.0",
"ember-collection": "^1.0.0-alpha.9",
"ember-collection": "^1.0.0",
"ember-compatibility-helpers": "^1.2.5",
"ember-composable-helpers": "^5.0.0",
"ember-data": "~3.24.0",
"ember-data-model-fragments": "5.0.0-beta.0",
"ember-data": "~3.27.1",
"ember-data-model-fragments": "5.0.0-beta.8",
"ember-decorators": "^6.1.1",
"ember-exam": "^6.1.0",
"ember-export-application-global": "^2.0.1",
@ -143,10 +142,10 @@
"ember-named-blocks-polyfill": "^0.2.3",
"ember-on-helper": "^0.1.0",
"ember-on-resize-modifier": "^0.3.0",
"ember-page-title": "^6.2.1",
"ember-page-title": "^6.2.2",
"ember-power-select": "^4.0.5",
"ember-power-select-with-create": "^0.8.0",
"ember-qunit": "^5.1.1",
"ember-qunit": "^5.1.4",
"ember-ref-bucket": "^4.1.0",
"ember-render-helpers": "^0.2.0",
"ember-resolver": "^8.0.2",
@ -154,16 +153,17 @@
"ember-router-helpers": "^0.4.0",
"ember-set-helper": "^2.0.0",
"ember-sinon-qunit": "5.0.0",
"ember-source": "~3.24.0",
"ember-source": "~3.27.2",
"ember-stargate": "^0.2.0",
"ember-string-fns": "^1.4.0",
"ember-test-selectors": "^5.0.0",
"ember-truth-helpers": "^3.0.0",
"eslint": "^7.17.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-ember": "^10.1.1",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-ember": "^10.4.2",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-qunit": "^6.1.1",
"faker": "^5.5.3",
"flat": "^5.0.0",
"hast-util-to-string": "^1.0.4",
@ -177,9 +177,9 @@
"ngraph.graph": "^19.1.0",
"parse-duration": "^1.0.0",
"pretender": "^3.2.0",
"prettier": "^2.2.1",
"prettier": "^2.3.0",
"pretty-ms": "^7.0.1",
"qunit": "^2.13.0",
"qunit": "^2.15.0",
"qunit-dom": "^1.6.0",
"react-is": "^17.0.1",
"refractor": "^3.5.0",
@ -190,7 +190,7 @@
"tape": "^5.0.1",
"text-encoding": "^0.7.0",
"tippy.js": "^6.2.7",
"torii": "^0.10.1",
"torii": "^1.0.0-beta.1",
"tracked-built-ins": "^3.1.0",
"unist-util-visit": "^2.0.3",
"wayfarer": "^7.0.1",

View File

@ -10,7 +10,7 @@ const TOKEN_SET_BY_HCP = 'token-set-by-hcp';
module('Acceptance | hcp login', function (hooks) {
setupApplicationTest(hooks);
module('with `CONSUL_HTTP_TOKEN` not set', function () {
module('with `CONSUL_HTTP_TOKEN` not set', function (hooks) {
hooks.beforeEach(function () {
setupTestEnv(this.owner, {
CONSUL_ACLS_ENABLED: true,

View File

@ -23,7 +23,7 @@
</div>
</div>
<script src="/testem.js" integrity=""></script>
<script src="/testem.js" integrity="" data-embroider-ignore></script>
{{content-for "body-footer"}}
{{content-for "test-body-footer"}}

View File

@ -29,6 +29,7 @@ module('Integration | Adapter | auth-method', function (hooks) {
});
});
test('requestForQueryRecord returns the correct body', function (assert) {
assert.expect(2);
return nspaceRunner(
(adapter, serializer, client) => {
const request = client.body.bind(client);

View File

@ -17,6 +17,7 @@ module('Integration | Adapter | binding-rule', function (hooks) {
assert.equal(`${actual.method} ${actual.url}`, expected);
});
test('requestForQuery returns the correct body', function (assert) {
assert.expect(2);
return nspaceRunner(
(adapter, serializer, client) => {
const request = client.body.bind(client);

View File

@ -29,6 +29,8 @@ module('Integration | Adapter | discovery-chain', function (hooks) {
});
});
test('requestForQueryRecord returns the correct body', function (assert) {
assert.expect(2);
return nspaceRunner(
(adapter, serializer, client) => {
const request = client.body.bind(client);

View File

@ -10,6 +10,7 @@ module('Integration | Adapter | intention', function (hooks) {
const id =
'SourcePartition:SourceNS:SourceName:DestinationPartition:DestinationNS:DestinationName';
test('requestForQuery returns the correct url', function (assert) {
assert.expect(2);
return nspaceRunner(
(adapter, serializer, client) => {
const request = client.body.bind(client);

View File

@ -31,6 +31,7 @@ module('Integration | Adapter | topology', function (hooks) {
});
});
test('requestForQueryRecord returns the correct body', function (assert) {
assert.expect(2);
return nspaceRunner(
(adapter, serializer, client) => {
const request = client.body.bind(client);

View File

@ -12,13 +12,13 @@ module('Integration | Component | auth-profile', function (hooks) {
await render(hbs`<AuthProfile />`);
assert.ok(this.element.textContent.indexOf('AccessorID') !== -1);
assert.notStrictEqual(this.element.textContent.indexOf('AccessorID'), -1);
// Template block usage:
await render(hbs`
<AuthProfile></AuthProfile>
`);
assert.ok(this.element.textContent.indexOf('AccessorID') !== -1);
assert.notStrictEqual(this.element.textContent.indexOf('AccessorID'), -1);
});
});

View File

@ -16,6 +16,7 @@ module('Integration | Serializer | auth-method', function (hooks) {
const partition = 'default';
[undefinedNspace, 'team-1', undefined].forEach((nspace) => {
test(`respondForQuery returns the correct data for list endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:auth-method');
const request = {
url: `/v1/acl/auth-methods?dc=${dc}${typeof nspace !== 'undefined' ? `&ns=${nspace}` : ``}${
@ -53,6 +54,7 @@ module('Integration | Serializer | auth-method', function (hooks) {
});
});
test(`respondForQueryRecord returns the correct data for item endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:auth-method');
const request = {
url: `/v1/acl/auth-method/${id}?dc=${dc}${

View File

@ -9,6 +9,7 @@ module('Integration | Serializer | binding-rule', function (hooks) {
const partition = 'default';
[undefinedNspace, 'team-1', undefined].forEach((nspace) => {
test(`respondForQuery returns the correct data for list endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:binding-rule');
const request = {
url: `/v1/acl/binding-rules?dc=${dc}${

View File

@ -12,6 +12,7 @@ module('Integration | Serializer | coordinate', function (hooks) {
const nspace = 'default';
const partition = 'default';
test('respondForQuery returns the correct data for list endpoint', function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:coordinate');
const request = {
url: `/v1/coordinate/nodes?dc=${dc}`,

View File

@ -12,6 +12,7 @@ import {
module('Integration | Serializer | discovery-chain', function (hooks) {
setupTest(hooks);
test('respondForQueryRecord returns the correct data for item endpoint', function (assert) {
assert.expect(2);
const serializer = this.owner.lookup('serializer:discovery-chain');
const dc = 'dc-1';
const id = 'slug';

View File

@ -14,6 +14,7 @@ module('Integration | Serializer | intention', function (hooks) {
const nspace = 'default';
const partition = 'default';
test('respondForQuery returns the correct data for list endpoint', function (assert) {
assert.expect(4);
const serializer = this.owner.lookup('serializer:intention');
const request = {
url: `/v1/connect/intentions?dc=${dc}`,
@ -53,6 +54,7 @@ module('Integration | Serializer | intention', function (hooks) {
});
});
test('respondForQueryRecord returns the correct data for item endpoint', function (assert) {
assert.expect(4);
const serializer = this.owner.lookup('serializer:intention');
const request = {
url: `/v1/connect/intentions/${id}?dc=${dc}`,

View File

@ -16,6 +16,7 @@ module('Integration | Serializer | kv', function (hooks) {
const partition = 'default';
[undefinedNspace, 'team-1', undefined].forEach((nspace) => {
test(`respondForQuery returns the correct data for list endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:kv');
const request = {
url: `/v1/kv/${id}?keys&dc=${dc}${typeof nspace !== 'undefined' ? `&ns=${nspace}` : ``}${
@ -61,6 +62,7 @@ module('Integration | Serializer | kv', function (hooks) {
});
});
test(`respondForQueryRecord returns the correct data for item endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:kv');
const request = {
url: `/v1/kv/${id}?dc=${dc}${typeof nspace !== 'undefined' ? `&ns=${nspace}` : ``}${

View File

@ -12,6 +12,7 @@ module('Integration | Serializer | node', function (hooks) {
const nspace = 'default';
const partition = 'default';
test('respondForQuery returns the correct data for list endpoint', function (assert) {
assert.expect(4);
const store = this.owner.lookup('service:store');
const serializer = this.owner.lookup('serializer:node');
serializer.store = store;
@ -46,6 +47,7 @@ module('Integration | Serializer | node', function (hooks) {
});
});
test('respondForQueryRecord returns the correct data for item endpoint', function (assert) {
assert.expect(4);
const store = this.owner.lookup('service:store');
const serializer = this.owner.lookup('serializer:node');
serializer.store = store;
@ -81,6 +83,8 @@ module('Integration | Serializer | node', function (hooks) {
});
});
test('respondForQueryLeader returns the correct data', function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:node');
const dc = 'dc-1';
const request = {

View File

@ -13,6 +13,7 @@ module('Integration | Serializer | nspace', function (hooks) {
const undefinedPartition = 'default';
const partition = 'default';
test('respondForQuery returns the correct data for list endpoint', function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:nspace');
const request = {
url: `/v1/namespaces?dc=${dc}${
@ -44,6 +45,7 @@ module('Integration | Serializer | nspace', function (hooks) {
});
});
test('respondForQueryRecord returns the correct data for item endpoint', function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:nspace');
const id = 'slug';
const request = {

View File

@ -17,6 +17,8 @@ module('Integration | Serializer | oidc-provider', function (hooks) {
const partition = 'default';
[undefinedNspace, 'team-1', undefined].forEach((nspace) => {
test(`respondForQuery returns the correct data for list endpoint when the nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:oidc-provider');
const request = {
url: `/v1/internal/ui/oidc-auth-methods?dc=${dc}`,
@ -50,6 +52,8 @@ module('Integration | Serializer | oidc-provider', function (hooks) {
});
});
test(`respondForQueryRecord returns the correct data for item endpoint when the nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:oidc-provider');
const dc = 'dc-1';
const id = 'slug';

View File

@ -7,6 +7,8 @@ import { HEADERS_SYMBOL as META } from 'consul-ui/utils/http/consul';
module('Integration | Serializer | partition', function (hooks) {
setupTest(hooks);
test('respondForQuery returns the correct data for list endpoint', function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:partition');
const dc = 'dc-1';
const request = {

View File

@ -16,6 +16,8 @@ module('Integration | Serializer | policy', function (hooks) {
const partition = 'default';
[undefinedNspace, 'team-1', undefined].forEach((nspace) => {
test(`respondForQuery returns the correct data for list endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:policy');
const request = {
url: `/v1/acl/policies?dc=${dc}${typeof nspace !== 'undefined' ? `&ns=${nspace}` : ``}${
@ -52,6 +54,8 @@ module('Integration | Serializer | policy', function (hooks) {
});
});
test(`respondForQueryRecord returns the correct data for item endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:policy');
const request = {
url: `/v1/acl/policy/${id}?dc=${dc}${typeof nspace !== 'undefined' ? `&ns=${nspace}` : ``}${

View File

@ -18,6 +18,8 @@ module('Integration | Serializer | role', function (hooks) {
const partition = 'default';
[undefinedNspace, 'team-1', undefined].forEach((nspace) => {
test(`respondForQuery returns the correct data for list endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:role');
const request = {
url: `/v1/acl/roles?dc=${dc}${typeof nspace !== 'undefined' ? `&ns=${nspace}` : ``}${
@ -56,6 +58,8 @@ module('Integration | Serializer | role', function (hooks) {
});
});
test(`respondForQueryRecord returns the correct data for item endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:role');
const request = {
url: `/v1/acl/role/${id}?dc=${dc}${typeof nspace !== 'undefined' ? `&ns=${nspace}` : ``}${

View File

@ -15,6 +15,8 @@ module('Integration | Serializer | service-instance', function (hooks) {
const partition = 'default';
[undefinedNspace, 'team-1', undefined].forEach((nspace) => {
test(`respondForQueryRecord returns the correct data for item endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:service-instance');
const id = 'service-name';
const node = 'node-0';

View File

@ -14,6 +14,7 @@ module('Integration | Serializer | service', function (hooks) {
const partition = 'default';
[undefinedNspace, 'team-1', undefined].forEach((nspace) => {
test(`respondForQuery returns the correct data for list endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(4);
const serializer = this.owner.lookup('serializer:service');
const request = {
url: `/v1/internal/ui/services?dc=${dc}${
@ -54,6 +55,8 @@ module('Integration | Serializer | service', function (hooks) {
});
});
test(`respondForQuery returns the correct data for list endpoint when gateway is set when nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:service');
const gateway = 'gateway';
const request = {

View File

@ -16,6 +16,8 @@ module('Integration | Serializer | session | response', function (hooks) {
const partition = 'default';
[undefinedNspace, 'team-1', undefined].forEach((nspace) => {
test(`respondForQuery returns the correct data for list endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:session');
const node = 'node-id';
const request = {
@ -54,6 +56,7 @@ module('Integration | Serializer | session | response', function (hooks) {
});
});
test(`respondForQueryRecord returns the correct data for item endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:session');
const request = {
url: `/v1/session/info/${id}?dc=${dc}${

View File

@ -19,6 +19,7 @@ module('Integration | Serializer | token', function (hooks) {
const partition = 'default';
[undefinedNspace, 'team-1', undefined].forEach((nspace) => {
test(`respondForQuery returns the correct data for list endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:token');
const request = {
url: `/v1/acl/tokens?dc=${dc}${typeof nspace !== 'undefined' ? `&ns=${nspace}` : ``}${
@ -57,6 +58,7 @@ module('Integration | Serializer | token', function (hooks) {
});
});
test(`respondForQueryRecord returns the correct data for item endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(1);
const serializer = this.owner.lookup('serializer:token');
const request = {
url: `/v1/acl/token/${id}?dc=${dc}${typeof nspace !== 'undefined' ? `&ns=${nspace}` : ``}${

View File

@ -12,6 +12,8 @@ import {
module('Integration | Serializer | topology', function (hooks) {
setupTest(hooks);
test('respondForQueryRecord returns the correct data for item endpoint', function (assert) {
assert.expect(2);
const serializer = this.owner.lookup('serializer:topology');
const dc = 'dc-1';
const id = 'slug';

View File

@ -10,6 +10,8 @@ module(`Integration | Service | coordinate`, function (hooks) {
setupTest(hooks);
test('findAllByDatacenter returns the correct data for list endpoint', function (assert) {
assert.expect(1);
const subject = this.owner.lookup('service:repository/coordinate');
subject.store.serializerFor('coordinate').timestamp = function () {
@ -53,6 +55,7 @@ module(`Integration | Service | coordinate`, function (hooks) {
});
test('findAllByNode calls findAllByDatacenter with the correct arguments', function (assert) {
assert.expect(3);
const datacenter = 'dc-1';
const conf = {
cursor: 1,

View File

@ -7,6 +7,8 @@ module('Integration | Service | discovery-chain', function (hooks) {
const dc = 'dc-1';
const id = 'slug';
test('findBySlug returns the correct data for item endpoint', function (assert) {
assert.expect(2);
return repo(
'Service',
'findBySlug',

View File

@ -13,6 +13,8 @@ module(`Integration | Service | kv`, function (hooks) {
const partition = 'default';
[undefinedNspace, 'team-1', undefined].forEach((nspace) => {
test(`findAllBySlug returns the correct data for list endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(2);
const subject = this.owner.lookup('service:repository/kv');
subject.store.serializerFor('kv').timestamp = function () {
@ -58,6 +60,8 @@ module(`Integration | Service | kv`, function (hooks) {
);
});
test(`findBySlug returns the correct data for item endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(2);
const subject = this.owner.lookup('service:repository/kv');
return repo(

View File

@ -11,6 +11,8 @@ module(`Integration | Service | node`, function (hooks) {
setupTest(hooks);
test('findByDatacenter returns the correct data for list endpoint', function (assert) {
assert.expect(200);
const subject = this.owner.lookup('service:repository/node');
subject.store.serializerFor('node').timestamp = function () {
return now;
@ -41,6 +43,8 @@ module(`Integration | Service | node`, function (hooks) {
);
});
test('findBySlug returns the correct data for item endpoint', function (assert) {
assert.expect(2);
const subject = this.owner.lookup('service:repository/node');
return repo(

View File

@ -60,6 +60,7 @@ module(`Integration | Service | policy`, function (hooks) {
);
});
test(`findBySlug returns the correct data for item endpoint when the nspace is ${nspace}`, function (assert) {
assert.expect(2);
const subject = this.owner.lookup('service:repository/policy');
return repo(
'Policy',

View File

@ -11,6 +11,8 @@ module(`Integration | Service | service`, function (hooks) {
const partition = 'default';
[undefinedNspace, 'team-1', undefined].forEach((nspace) => {
test(`findGatewayBySlug returns the correct data for list endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(5);
const subject = this.owner.lookup('service:repository/service');
subject.store.serializerFor('service').timestamp = function () {
return now;

View File

@ -57,6 +57,8 @@ module(`Integration | Service | token`, function (hooks) {
);
});
test(`findBySlug returns the correct data for item endpoint when nspace is ${nspace}`, function (assert) {
assert.expect(3);
const subject = this.owner.lookup('service:repository/token');
return repo(
'Token',

View File

@ -8,6 +8,8 @@ module('Integration | Service | topology', function (hooks) {
const id = 'slug';
const kind = '';
test('findBySlug returns the correct data for item endpoint', function (assert) {
assert.expect(2);
return repo(
'Service',
'findBySlug',

View File

@ -7,6 +7,8 @@ module('Unit | Ability | *', function (hooks) {
// Replace this with your real tests.
test('it exists', function (assert) {
assert.expect(228);
const abilities = Object.keys(requirejs.entries)
.filter((key) => key.indexOf('/abilities/') !== -1)
.map((key) => key.split('/').pop())
@ -55,7 +57,8 @@ module('Unit | Ability | *', function (hooks) {
break;
case 'kv':
// TODO: We currently hardcode KVs to always be true
assert.equal(true, ability[`can${perm}`], `Expected ${item}.can${perm} to be true`);
assert.true(ability[`can${perm}`], `Expected ${item}.can${perm} to be true`);
// eslint-disable-next-line qunit/no-early-return
return;
case 'license':
case 'zone':
@ -63,6 +66,7 @@ module('Unit | Ability | *', function (hooks) {
// License permissions also depend on NSPACES_ENABLED;
// behavior works as expected when verified manually but test
// fails due to this dependency. -@evrowe 2022-04-18
// eslint-disable-next-line qunit/no-early-return
return;
}
assert.equal(

View File

@ -10,6 +10,8 @@ const request = {
};
module('Unit | Component | consul/discovery-chain/get-resolvers', function () {
test('it assigns Subsets correctly', function (assert) {
assert.expect(3);
return get(request.url, {
headers: {
cookie: {
@ -24,12 +26,14 @@ module('Unit | Component | consul/discovery-chain/get-resolvers', function () {
const childId = Object.keys(Chain.Targets)[1];
const target = Chain.Targets[`${childId}`];
const firstChild = actual[0].Children[0];
assert.equal(firstChild.Subset, true);
assert.true(firstChild.Subset);
assert.equal(firstChild.ID, target.ID);
assert.equal(firstChild.Name, target.ServiceSubset);
});
});
test('it assigns Redirects correctly', function (assert) {
assert.expect(2);
return get(request.url, {
headers: {
cookie: {
@ -49,6 +53,8 @@ module('Unit | Component | consul/discovery-chain/get-resolvers', function () {
});
});
test('it assigns Failovers to Subsets correctly', function (assert) {
assert.expect(4);
return Promise.all(
['Datacenter', 'Namespace'].map(function (failoverType) {
return get(request.url, {
@ -64,13 +70,15 @@ module('Unit | Component | consul/discovery-chain/get-resolvers', function () {
}).then(function ({ Chain }) {
const actual = getResolvers(dc, partition, nspace, Chain.Targets, Chain.Nodes);
const actualSubset = actual[0].Children[0];
assert.equal(actualSubset.Subset, true);
assert.true(actualSubset.Subset);
assert.equal(actualSubset.Failover.Type, failoverType);
});
})
);
});
test('it assigns Failovers correctly', function (assert) {
assert.expect(6);
return Promise.all(
['Datacenter', 'Partition', 'Namespace'].map(function (failoverType, i) {
return get(request.url, {
@ -96,6 +104,8 @@ module('Unit | Component | consul/discovery-chain/get-resolvers', function () {
);
});
test('it finds subsets with failovers correctly', function (assert) {
assert.expect(1);
return Promise.resolve({
Chain: {
ServiceName: 'service-name',
@ -162,6 +172,8 @@ module('Unit | Component | consul/discovery-chain/get-resolvers', function () {
});
});
test('it finds services with failovers correctly', function (assert) {
assert.expect(1);
return Promise.resolve({
Chain: {
ServiceName: 'service-name',
@ -206,6 +218,8 @@ module('Unit | Component | consul/discovery-chain/get-resolvers', function () {
});
});
test('it finds services with redirects with failovers correctly', function (assert) {
assert.expect(1);
return Promise.resolve({
Chain: {
ServiceName: 'service-name',

View File

@ -3,6 +3,7 @@ import { module, test } from 'qunit';
module('Unit | Component | search-bar/filters', function () {
test('it correctly reshapes the filter data', function (assert) {
assert.expect(5);
[
// basic filter, returns a single filter button when clicked
// resets selected/queryparam to empty

View File

@ -30,8 +30,9 @@ module('Unit | Helper | document-attrs', function () {
assert.deepEqual(actual, ['a', 'b'], 'keys are removed, leaving keys that need to remain');
// remove first helper
a.synchronize(root);
assert.ok(
typeof attrs.get('class') === 'undefined',
assert.strictEqual(
typeof attrs.get('class'),
'undefined',
'property is completely removed once its empty'
);
assert.throws(() => {

View File

@ -27,11 +27,11 @@ module('Unit | Helper | token/is-legacy', function () {
const actual = isLegacy([[{}, {}]]);
assert.notOk(actual);
});
test('it returns true if the token has a Legacy=true', function (assert) {
test('it returns true if one token has Legacy=true', function (assert) {
const actual = isLegacy([[{}, { Legacy: true }]]);
assert.ok(actual);
});
test('it returns false if the token has a Legacy=false', function (assert) {
test('it returns false if one token as Legacy=false', function (assert) {
const actual = isLegacy([[{}, { Legacy: false }]]);
assert.notOk(actual);
});

View File

@ -57,6 +57,8 @@ module('Unit | Mixin | with blocking actions', function (hooks) {
assert.ok(refresh.calledOnce);
});
test('the error hooks return type', function (assert) {
assert.expect(3);
const subject = this.subject();
const expected = 'success';
['errorCreate', 'errorUpdate', 'errorDelete'].forEach(function (item) {

View File

@ -59,6 +59,8 @@ module('Unit | Search | Predicate | intention', function () {
assert.equal(actual.length, 2);
});
test("* items are found by searching anything in 'All Services (*)'", function (assert) {
assert.expect(6);
const actual = new ExactSearch(
[
{

View File

@ -27,6 +27,8 @@ module('Unit | Serializer | kv', function (hooks) {
'what should respondForCreate/UpdateRecord return when createRecord is called with a `false` payload'
);
test('respondForCreate/UpdateRecord returns a KV uid object when receiving a `true` payload', function (assert) {
assert.expect(2);
const uid = 'key/name';
const dc = 'dc1';
const nspace = 'default';
@ -61,6 +63,8 @@ module('Unit | Serializer | kv', function (hooks) {
});
});
test("respondForCreate/UpdateRecord returns the original object if it's not a Boolean", function (assert) {
assert.expect(1);
const uid = 'key/name';
const dc = 'dc1';
const nspace = 'default';

View File

@ -14,14 +14,14 @@ module('Unit | Service | state', function (hooks) {
test('.matches performs a match correctly', function (assert) {
const service = this.owner.lookup('service:state');
const state = service.state((id) => id === 'idle');
assert.equal(service.matches(state, 'idle'), true);
assert.equal(service.matches(state, 'loading'), false);
assert.true(service.matches(state, 'idle'));
assert.false(service.matches(state, 'loading'));
});
test('.matches performs a match correctly when passed an array', function (assert) {
const service = this.owner.lookup('service:state');
const state = service.state((id) => id === 'idle');
assert.equal(service.matches(state, ['idle']), true);
assert.equal(service.matches(state, ['loading', 'idle']), true);
assert.equal(service.matches(state, ['loading', 'deleting']), false);
assert.true(service.matches(state, ['idle']));
assert.true(service.matches(state, ['loading', 'idle']));
assert.false(service.matches(state, ['loading', 'deleting']));
});
});

View File

@ -42,6 +42,7 @@ module('Unit | Utils | atob', function () {
});
});
test('it decodes strings properly', function (assert) {
assert.expect(2);
[
{
test: '',
@ -57,6 +58,8 @@ module('Unit | Utils | atob', function () {
});
});
test('throws when passed the wrong value', function (assert) {
assert.expect(4);
[{}, ['MTIz', 'NA=='], new Number(), 'hi'].forEach(function (item) {
assert.throws(function () {
atob(item);

View File

@ -3,6 +3,7 @@ import btoa from 'consul-ui/utils/btoa';
module('Unit | Utils | btoa', function () {
test('it encodes strings properly', function (assert) {
assert.expect(2);
[
{
test: '',

View File

@ -34,6 +34,8 @@ module('Unit | Utility | create fingerprinter', function () {
assert.deepEqual(actual, expected);
});
test("fingerprint throws an error if it can't find a foreignKey", function (assert) {
assert.expect(2);
const fingerprint = createFingerprinter('Datacenter', 'Namespace', 'Partition');
[undefined, null].forEach(function (item) {
assert.throws(function () {
@ -42,6 +44,7 @@ module('Unit | Utility | create fingerprinter', function () {
});
});
test("fingerprint throws an error if it can't find a slug", function (assert) {
assert.expect(2);
const fingerprint = createFingerprinter('Datacenter', 'Namespace', 'Partition');
[
{},

View File

@ -3,6 +3,8 @@ import { module, test } from 'qunit';
module('Unit | Utility | dom/click first anchor', function () {
test('it does nothing if the clicked element is generally a clickable thing', function (assert) {
assert.expect(4);
const closest = function () {
return {
querySelector: function () {

View File

@ -5,8 +5,8 @@ import sinon from 'sinon';
module('Unit | Utility | dom/create listeners', function () {
test('it has add and remove methods', function (assert) {
const listeners = createListeners();
assert.ok(typeof listeners.add === 'function');
assert.ok(typeof listeners.remove === 'function');
assert.strictEqual(typeof listeners.add, 'function');
assert.strictEqual(typeof listeners.remove, 'function');
});
test('add returns a remove function', function (assert) {
const listeners = createListeners();
@ -16,7 +16,7 @@ module('Unit | Utility | dom/create listeners', function () {
},
'click'
);
assert.ok(typeof remove === 'function');
assert.strictEqual(typeof remove, 'function');
});
test('remove returns an array of removed handlers (the return of a saved remove)', function (assert) {
// just use true here to prove that it's what gets returned

View File

@ -46,6 +46,8 @@ module('Unit | Utility | dom/event-source/blocking', function () {
assert.ok(source instanceof EventSource);
});
test("the 5xx backoff continues to throw when it's not a 5xx", function (assert) {
assert.expect(11);
const backoff = createErrorBackoff();
[
undefined,
@ -66,6 +68,8 @@ module('Unit | Utility | dom/event-source/blocking', function () {
});
});
test('the 5xx backoff returns a resolve promise on a 5xx (apart from 500)', function (assert) {
assert.expect(18);
[
{ statusCode: 501 },
{ errors: [{ status: 501 }] },
@ -85,12 +89,16 @@ module('Unit | Utility | dom/event-source/blocking', function () {
});
});
test("the cursor validation always returns undefined if the cursor can't be parsed to an integer", function (assert) {
assert.expect(4);
['null', null, '', undefined].forEach((item) => {
const actual = validateCursor(item);
assert.equal(actual, undefined);
});
});
test('the cursor validation always returns a cursor greater than zero', function (assert) {
assert.expect(5);
[
{
cursor: 0,
@ -118,6 +126,8 @@ module('Unit | Utility | dom/event-source/blocking', function () {
});
});
test('the cursor validation resets to 1 if its less than the previous cursor', function (assert) {
assert.expect(4);
[
{
previous: 100,

View File

@ -47,7 +47,7 @@ module('Unit | Utility | dom/event-source/cache', function () {
const Promise = createPromise();
const getCache = domEventSourceCache(function () {}, EventSource, Promise);
assert.ok(typeof getCache === 'function');
assert.strictEqual(typeof getCache, 'function');
});
test('getCache returns a function', function (assert) {
const EventSource = createEventSource();
@ -56,7 +56,7 @@ module('Unit | Utility | dom/event-source/cache', function () {
const getCache = domEventSourceCache(function () {}, EventSource, Promise);
const obj = {};
const cache = getCache(obj);
assert.ok(typeof cache === 'function');
assert.strictEqual(typeof cache, 'function');
});
test('cache creates the default EventSource and keeps it open when there is a cursor', function (assert) {
const EventSource = createEventSource();
@ -89,7 +89,9 @@ module('Unit | Utility | dom/event-source/cache', function () {
assert.ok(source.calledTwice, 'promisifying source called once');
assert.ok(retrievedEventSource instanceof Promise, 'source returns a Promise');
});
test('cache creates the default EventSource and keeps it open when there is a cursor', function (assert) {
test('cache creates the default EventSource and keeps it open when there is a cursor 2', function (assert) {
assert.expect(4);
const EventSource = createEventSource();
const stub = {
close: sinon.stub(),
@ -118,6 +120,8 @@ module('Unit | Utility | dom/event-source/cache', function () {
});
});
test("cache creates the default EventSource and closes it when there isn't a cursor", function (assert) {
assert.expect(4);
const EventSource = createEventSource();
const stub = {
close: sinon.stub(),

View File

@ -53,7 +53,7 @@ module('Unit | Utility | dom/event-source/callable', function () {
dispatchEvent: sinon.stub(),
};
defaultRunner(target, configuration, isClosed);
assert.ok(then.callCount == 10);
assert.equal(then.callCount, 10);
assert.ok(target.dispatchEvent.calledOnce);
});
test('it calls the defaultRunner', function (assert) {

View File

@ -14,15 +14,15 @@ module('Unit | Utility | dom/event source/index', function () {
// Replace this with your real tests.
test('it works', function (assert) {
// All The EventSource
assert.ok(typeof CallableEventSource === 'function');
assert.ok(typeof OpenableEventSource === 'function');
assert.ok(typeof BlockingEventSource === 'function');
assert.ok(typeof StorageEventSource === 'function');
assert.strictEqual(typeof CallableEventSource, 'function');
assert.strictEqual(typeof OpenableEventSource, 'function');
assert.strictEqual(typeof BlockingEventSource, 'function');
assert.strictEqual(typeof StorageEventSource, 'function');
// Utils
assert.ok(typeof source === 'function');
assert.ok(typeof proxy === 'function');
assert.ok(typeof cache === 'function');
assert.ok(typeof resolve === 'function');
assert.strictEqual(typeof source, 'function');
assert.strictEqual(typeof proxy, 'function');
assert.strictEqual(typeof cache, 'function');
assert.strictEqual(typeof resolve, 'function');
});
});

View File

@ -4,6 +4,8 @@ import { module, test } from 'qunit';
module('Unit | Utility | dom/event-target/rsvp', function () {
// Replace this with your real tests.
test('it has EventTarget methods', function (assert) {
assert.expect(4);
const result = domEventTargetRsvp;
assert.equal(typeof result, 'function');
['addEventListener', 'removeEventListener', 'dispatchEvent'].forEach(function (item) {

View File

@ -53,7 +53,7 @@ module('Unit | Utility | dom/is-outside', function () {
const result = domIsOutside(el, target, doc);
assert.notOk(result);
});
test('it is not outside when its in the document but in the element', function (assert) {
test('it is not outside when its in the document but not in the element', function (assert) {
// is in the document
const doc = {
contains: function (el) {

View File

@ -45,7 +45,7 @@ module('Unit | Utility | getEnvironment', function () {
test('it returns a function', function (assert) {
const config = {};
const env = getEnvironment(config, win, doc);
assert.ok(typeof env === 'function');
assert.strictEqual(typeof env, 'function');
});
test('it returns the correct operator value', function (assert) {
const config = {};

View File

@ -5,6 +5,6 @@ module('Unit | Utility | http/request', function () {
// Replace this with your real tests.
test('it works', function (assert) {
const actual = httpRequest;
assert.ok(typeof actual === 'function');
assert.strictEqual(typeof actual, 'function');
});
});

View File

@ -3,6 +3,8 @@ import isFolder from 'consul-ui/utils/isFolder';
module('Unit | Utils | isFolder', function () {
test('it detects if a string ends in a slash', function (assert) {
assert.expect(5);
[
{
test: 'hello/world',

View File

@ -3,6 +3,8 @@ import keyToArray from 'consul-ui/utils/keyToArray';
module('Unit | Utils | keyToArray', function () {
test('it splits a string by a separator, unless the string is the separator', function (assert) {
assert.expect(4);
[
{
test: '/',

View File

@ -3,6 +3,8 @@ import leftTrim from 'consul-ui/utils/left-trim';
module('Unit | Utility | left trim', function () {
test('it trims characters from the left hand side', function (assert) {
assert.expect(8);
[
{
args: ['/a/folder/here', '/'],

View File

@ -3,6 +3,7 @@ import { module, test } from 'qunit';
module('Unit | Utility | merge-checks', function () {
test('it works', function (assert) {
assert.expect(4);
[
{
desc: 'One list of checks, not exposed',

View File

@ -3,6 +3,7 @@ import { module, test } from 'qunit';
module('Unit | Utility | path/resolve', function () {
test('it resolves paths', function (assert) {
assert.expect(9);
[
{
from: 'dc/intentions/create',

View File

@ -3,6 +3,8 @@ import promisedTimeout from 'consul-ui/utils/promisedTimeout';
module('Unit | Utils | promisedTimeout', function () {
test('it calls setTimeout with the correct milliseconds', function (assert) {
assert.expect(2);
const expected = 1000;
const P = function (cb) {
cb(function (milliseconds) {

View File

@ -3,6 +3,8 @@ import rightTrim from 'consul-ui/utils/right-trim';
module('Unit | Utility | right trim', function () {
test('it trims characters from the right hand side', function (assert) {
assert.expect(12);
[
{
args: ['/a/folder/here/', '/'],

View File

@ -3,6 +3,8 @@ import ucfirst from 'consul-ui/utils/ucfirst';
module('Unit | Utils | ucfirst', function () {
test('it returns the first letter in uppercase', function (assert) {
assert.expect(4);
[
{
test: 'hello world',

File diff suppressed because it is too large Load Diff