[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": { "resolutions": {
"xmlhttprequest-ssl": "^1.6.3", "xmlhttprequest-ssl": "^1.6.3",
"ember-basic-dropdown": "3.0.21", "ember-basic-dropdown": "3.0.21"
"ember-changeset": "3.10.1",
"validated-changeset": "0.10.0"
}, },
"engines": { "engines": {
"node": ">=10 <=14" "node": ">=10 <=14"

View File

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

View File

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

View File

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

View File

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

View File

@ -3,27 +3,31 @@ import {
validatePresence, validatePresence,
validateFormat, validateFormat,
} from 'ember-changeset-validations/validators'; } 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'; const name = 'intention-permission';
export default (schema) => ({ export default (schema) => ({
'*': validateSometimes([validatePresence(true)], function () { '*': [
const methods = this.get('HTTP.Methods') || []; validateSometimes(validatePresence(true), function () {
const headers = this.get('HTTP.Header') || []; const methods = this.get('HTTP.Methods') || [];
const pathType = this.get('HTTP.PathType') || 'NoPath'; const headers = this.get('HTTP.Header') || [];
const path = this.get('HTTP.Path') || ''; const pathType = this.get('HTTP.PathType') || 'NoPath';
const isValid = [ const path = this.get('HTTP.Path') || '';
methods.length !== 0, const isValid = [
headers.length !== 0, methods.length !== 0,
pathType !== 'NoPath' && path !== '', headers.length !== 0,
].includes(true); pathType !== 'NoPath' && path !== '',
return !isValid; ].includes(true);
}), return !isValid;
}),
],
Action: [validateInclusion({ in: schema[name].Action.allowedValues })], Action: [validateInclusion({ in: schema[name].Action.allowedValues })],
HTTP: { HTTP: {
Path: validateSometimes([validateFormat({ regex: /^\// })], function () { Path: [
const pathType = this.get('HTTP.PathType'); validateSometimes(validateFormat({ regex: /^\// }), function () {
return typeof pathType !== 'undefined' && pathType !== 'NoPath'; const pathType = this.get('HTTP.PathType');
}), return typeof pathType !== 'undefined' && pathType !== 'NoPath';
}),
],
}, },
}); });

View File

@ -1,18 +1,20 @@
import { validatePresence, validateLength } from 'ember-changeset-validations/validators'; 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 { export default {
'*': validateSometimes([validatePresence(true)], function () { '*': [
const action = this.get('Action') || ''; validateSometimes(validatePresence(true), function () {
const permissions = this.get('Permissions') || []; const action = this.get('Action') || '';
if (action === '' && permissions.length === 0) { const permissions = this.get('Permissions') || [];
return true; if (action === '' && permissions.length === 0) {
} return true;
return false; }
}), return false;
}),
],
SourceName: [validatePresence(true), validateLength({ min: 1 })], SourceName: [validatePresence(true), validateLength({ min: 1 })],
DestinationName: [validatePresence(true), validateLength({ min: 1 })], DestinationName: [validatePresence(true), validateLength({ min: 1 })],
Permissions: [ Permissions: [
validateSometimes([validateLength({ min: 1 })], function (changes, content) { validateSometimes(validateLength({ min: 1 }), function (changes, content) {
return !this.get('Action'); 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": [ "packages": [
{ {
"name": "ember-cli", "name": "ember-cli",
"version": "3.24.0", "version": "3.27.0",
"blueprints": [ "blueprints": [
{ {
"name": "app", "name": "app",

View File

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

View File

@ -23,7 +23,7 @@
</div> </div>
</div> </div>
<script src="/testem.js" integrity=""></script> <script src="/testem.js" integrity="" data-embroider-ignore></script>
{{content-for "body-footer"}} {{content-for "body-footer"}}
{{content-for "test-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) { test('requestForQueryRecord returns the correct body', function (assert) {
assert.expect(2);
return nspaceRunner( return nspaceRunner(
(adapter, serializer, client) => { (adapter, serializer, client) => {
const request = client.body.bind(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); assert.equal(`${actual.method} ${actual.url}`, expected);
}); });
test('requestForQuery returns the correct body', function (assert) { test('requestForQuery returns the correct body', function (assert) {
assert.expect(2);
return nspaceRunner( return nspaceRunner(
(adapter, serializer, client) => { (adapter, serializer, client) => {
const request = client.body.bind(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) { test('requestForQueryRecord returns the correct body', function (assert) {
assert.expect(2);
return nspaceRunner( return nspaceRunner(
(adapter, serializer, client) => { (adapter, serializer, client) => {
const request = client.body.bind(client); const request = client.body.bind(client);

View File

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

View File

@ -12,13 +12,13 @@ module('Integration | Component | auth-profile', function (hooks) {
await render(hbs`<AuthProfile />`); await render(hbs`<AuthProfile />`);
assert.ok(this.element.textContent.indexOf('AccessorID') !== -1); assert.notStrictEqual(this.element.textContent.indexOf('AccessorID'), -1);
// Template block usage: // Template block usage:
await render(hbs` await render(hbs`
<AuthProfile></AuthProfile> <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'; const partition = 'default';
[undefinedNspace, 'team-1', undefined].forEach((nspace) => { [undefinedNspace, 'team-1', undefined].forEach((nspace) => {
test(`respondForQuery returns the correct data for list endpoint when nspace is ${nspace}`, function (assert) { 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 serializer = this.owner.lookup('serializer:auth-method');
const request = { const request = {
url: `/v1/acl/auth-methods?dc=${dc}${typeof nspace !== 'undefined' ? `&ns=${nspace}` : ``}${ 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) { 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 serializer = this.owner.lookup('serializer:auth-method');
const request = { const request = {
url: `/v1/acl/auth-method/${id}?dc=${dc}${ url: `/v1/acl/auth-method/${id}?dc=${dc}${

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,6 +3,7 @@ import { module, test } from 'qunit';
module('Unit | Component | search-bar/filters', function () { module('Unit | Component | search-bar/filters', function () {
test('it correctly reshapes the filter data', function (assert) { test('it correctly reshapes the filter data', function (assert) {
assert.expect(5);
[ [
// basic filter, returns a single filter button when clicked // basic filter, returns a single filter button when clicked
// resets selected/queryparam to empty // 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'); assert.deepEqual(actual, ['a', 'b'], 'keys are removed, leaving keys that need to remain');
// remove first helper // remove first helper
a.synchronize(root); a.synchronize(root);
assert.ok( assert.strictEqual(
typeof attrs.get('class') === 'undefined', typeof attrs.get('class'),
'undefined',
'property is completely removed once its empty' 'property is completely removed once its empty'
); );
assert.throws(() => { assert.throws(() => {

View File

@ -27,11 +27,11 @@ module('Unit | Helper | token/is-legacy', function () {
const actual = isLegacy([[{}, {}]]); const actual = isLegacy([[{}, {}]]);
assert.notOk(actual); 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 }]]); const actual = isLegacy([[{}, { Legacy: true }]]);
assert.ok(actual); 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 }]]); const actual = isLegacy([[{}, { Legacy: false }]]);
assert.notOk(actual); assert.notOk(actual);
}); });

View File

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

View File

@ -59,6 +59,8 @@ module('Unit | Search | Predicate | intention', function () {
assert.equal(actual.length, 2); assert.equal(actual.length, 2);
}); });
test("* items are found by searching anything in 'All Services (*)'", function (assert) { test("* items are found by searching anything in 'All Services (*)'", function (assert) {
assert.expect(6);
const actual = new ExactSearch( 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' '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) { test('respondForCreate/UpdateRecord returns a KV uid object when receiving a `true` payload', function (assert) {
assert.expect(2);
const uid = 'key/name'; const uid = 'key/name';
const dc = 'dc1'; const dc = 'dc1';
const nspace = 'default'; 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) { test("respondForCreate/UpdateRecord returns the original object if it's not a Boolean", function (assert) {
assert.expect(1);
const uid = 'key/name'; const uid = 'key/name';
const dc = 'dc1'; const dc = 'dc1';
const nspace = 'default'; const nspace = 'default';

View File

@ -14,14 +14,14 @@ module('Unit | Service | state', function (hooks) {
test('.matches performs a match correctly', function (assert) { test('.matches performs a match correctly', function (assert) {
const service = this.owner.lookup('service:state'); const service = this.owner.lookup('service:state');
const state = service.state((id) => id === 'idle'); const state = service.state((id) => id === 'idle');
assert.equal(service.matches(state, 'idle'), true); assert.true(service.matches(state, 'idle'));
assert.equal(service.matches(state, 'loading'), false); assert.false(service.matches(state, 'loading'));
}); });
test('.matches performs a match correctly when passed an array', function (assert) { test('.matches performs a match correctly when passed an array', function (assert) {
const service = this.owner.lookup('service:state'); const service = this.owner.lookup('service:state');
const state = service.state((id) => id === 'idle'); const state = service.state((id) => id === 'idle');
assert.equal(service.matches(state, ['idle']), true); assert.true(service.matches(state, ['idle']));
assert.equal(service.matches(state, ['loading', 'idle']), true); assert.true(service.matches(state, ['loading', 'idle']));
assert.equal(service.matches(state, ['loading', 'deleting']), false); 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) { test('it decodes strings properly', function (assert) {
assert.expect(2);
[ [
{ {
test: '', test: '',
@ -57,6 +58,8 @@ module('Unit | Utils | atob', function () {
}); });
}); });
test('throws when passed the wrong value', function (assert) { test('throws when passed the wrong value', function (assert) {
assert.expect(4);
[{}, ['MTIz', 'NA=='], new Number(), 'hi'].forEach(function (item) { [{}, ['MTIz', 'NA=='], new Number(), 'hi'].forEach(function (item) {
assert.throws(function () { assert.throws(function () {
atob(item); atob(item);

View File

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

View File

@ -34,6 +34,8 @@ module('Unit | Utility | create fingerprinter', function () {
assert.deepEqual(actual, expected); assert.deepEqual(actual, expected);
}); });
test("fingerprint throws an error if it can't find a foreignKey", function (assert) { test("fingerprint throws an error if it can't find a foreignKey", function (assert) {
assert.expect(2);
const fingerprint = createFingerprinter('Datacenter', 'Namespace', 'Partition'); const fingerprint = createFingerprinter('Datacenter', 'Namespace', 'Partition');
[undefined, null].forEach(function (item) { [undefined, null].forEach(function (item) {
assert.throws(function () { 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) { test("fingerprint throws an error if it can't find a slug", function (assert) {
assert.expect(2);
const fingerprint = createFingerprinter('Datacenter', 'Namespace', 'Partition'); 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 () { module('Unit | Utility | dom/click first anchor', function () {
test('it does nothing if the clicked element is generally a clickable thing', function (assert) { test('it does nothing if the clicked element is generally a clickable thing', function (assert) {
assert.expect(4);
const closest = function () { const closest = function () {
return { return {
querySelector: function () { querySelector: function () {

View File

@ -5,8 +5,8 @@ import sinon from 'sinon';
module('Unit | Utility | dom/create listeners', function () { module('Unit | Utility | dom/create listeners', function () {
test('it has add and remove methods', function (assert) { test('it has add and remove methods', function (assert) {
const listeners = createListeners(); const listeners = createListeners();
assert.ok(typeof listeners.add === 'function'); assert.strictEqual(typeof listeners.add, 'function');
assert.ok(typeof listeners.remove === 'function'); assert.strictEqual(typeof listeners.remove, 'function');
}); });
test('add returns a remove function', function (assert) { test('add returns a remove function', function (assert) {
const listeners = createListeners(); const listeners = createListeners();
@ -16,7 +16,7 @@ module('Unit | Utility | dom/create listeners', function () {
}, },
'click' '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) { 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 // 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); assert.ok(source instanceof EventSource);
}); });
test("the 5xx backoff continues to throw when it's not a 5xx", function (assert) { test("the 5xx backoff continues to throw when it's not a 5xx", function (assert) {
assert.expect(11);
const backoff = createErrorBackoff(); const backoff = createErrorBackoff();
[ [
undefined, 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) { test('the 5xx backoff returns a resolve promise on a 5xx (apart from 500)', function (assert) {
assert.expect(18);
[ [
{ statusCode: 501 }, { statusCode: 501 },
{ errors: [{ status: 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) { 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) => { ['null', null, '', undefined].forEach((item) => {
const actual = validateCursor(item); const actual = validateCursor(item);
assert.equal(actual, undefined); assert.equal(actual, undefined);
}); });
}); });
test('the cursor validation always returns a cursor greater than zero', function (assert) { test('the cursor validation always returns a cursor greater than zero', function (assert) {
assert.expect(5);
[ [
{ {
cursor: 0, 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) { test('the cursor validation resets to 1 if its less than the previous cursor', function (assert) {
assert.expect(4);
[ [
{ {
previous: 100, previous: 100,

View File

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

View File

@ -53,7 +53,7 @@ module('Unit | Utility | dom/event-source/callable', function () {
dispatchEvent: sinon.stub(), dispatchEvent: sinon.stub(),
}; };
defaultRunner(target, configuration, isClosed); defaultRunner(target, configuration, isClosed);
assert.ok(then.callCount == 10); assert.equal(then.callCount, 10);
assert.ok(target.dispatchEvent.calledOnce); assert.ok(target.dispatchEvent.calledOnce);
}); });
test('it calls the defaultRunner', function (assert) { 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. // Replace this with your real tests.
test('it works', function (assert) { test('it works', function (assert) {
// All The EventSource // All The EventSource
assert.ok(typeof CallableEventSource === 'function'); assert.strictEqual(typeof CallableEventSource, 'function');
assert.ok(typeof OpenableEventSource === 'function'); assert.strictEqual(typeof OpenableEventSource, 'function');
assert.ok(typeof BlockingEventSource === 'function'); assert.strictEqual(typeof BlockingEventSource, 'function');
assert.ok(typeof StorageEventSource === 'function'); assert.strictEqual(typeof StorageEventSource, 'function');
// Utils // Utils
assert.ok(typeof source === 'function'); assert.strictEqual(typeof source, 'function');
assert.ok(typeof proxy === 'function'); assert.strictEqual(typeof proxy, 'function');
assert.ok(typeof cache === 'function'); assert.strictEqual(typeof cache, 'function');
assert.ok(typeof resolve === '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 () { module('Unit | Utility | dom/event-target/rsvp', function () {
// Replace this with your real tests. // Replace this with your real tests.
test('it has EventTarget methods', function (assert) { test('it has EventTarget methods', function (assert) {
assert.expect(4);
const result = domEventTargetRsvp; const result = domEventTargetRsvp;
assert.equal(typeof result, 'function'); assert.equal(typeof result, 'function');
['addEventListener', 'removeEventListener', 'dispatchEvent'].forEach(function (item) { ['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); const result = domIsOutside(el, target, doc);
assert.notOk(result); 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 // is in the document
const doc = { const doc = {
contains: function (el) { contains: function (el) {

View File

@ -45,7 +45,7 @@ module('Unit | Utility | getEnvironment', function () {
test('it returns a function', function (assert) { test('it returns a function', function (assert) {
const config = {}; const config = {};
const env = getEnvironment(config, win, doc); 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) { test('it returns the correct operator value', function (assert) {
const config = {}; const config = {};

View File

@ -5,6 +5,6 @@ module('Unit | Utility | http/request', function () {
// Replace this with your real tests. // Replace this with your real tests.
test('it works', function (assert) { test('it works', function (assert) {
const actual = httpRequest; 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 () { module('Unit | Utils | isFolder', function () {
test('it detects if a string ends in a slash', function (assert) { test('it detects if a string ends in a slash', function (assert) {
assert.expect(5);
[ [
{ {
test: 'hello/world', test: 'hello/world',

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff