From 31cea94fbab556363ccde2fc3bb36b316482bb9f Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Wed, 19 Aug 2020 16:12:53 -0400 Subject: [PATCH 1/5] chore: add host/host set mock relationship to host catalog --- ui/core/mirage/config.js | 32 ++++++++++++++++-------- ui/core/mirage/factories/host-catalog.js | 15 ++++++++++- ui/core/mirage/models/host-set.js | 7 ++++++ ui/core/mirage/models/host.js | 7 ++++++ ui/core/mirage/scenarios/default.js | 6 +---- 5 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 ui/core/mirage/models/host-set.js create mode 100644 ui/core/mirage/models/host.js diff --git a/ui/core/mirage/config.js b/ui/core/mirage/config.js index 4a949b05f..5f4a14649 100644 --- a/ui/core/mirage/config.js +++ b/ui/core/mirage/config.js @@ -90,19 +90,31 @@ export default function() { // host - this.get('/scopes/:scope_id/host-catalogs/:host_catalog_id/hosts'); - this.post('/scopes/:scope_id/host-catalogs/:host_catalog_id/hosts'); - this.get('/scopes/:scope_id/host-catalogs/:host_catalog_id/hosts/:id'); - this.patch('/scopes/:scope_id/host-catalogs/:host_catalog_id/hosts/:id'); - this.del('/scopes/:scope_id/host-catalogs/:host_catalog_id/hosts/:id'); + this.get('/scopes/:scope_id/host-catalogs/:hostCatalogId/hosts', function ({ hosts }, { params: { hostCatalogId } }) { + return hosts.where({ hostCatalogId }); + }); + this.post('/scopes/:scope_id/host-catalogs/:hostCatalogId/hosts', function ({ hosts }, { params: { hostCatalogId } }) { + const attrs = this.normalizedRequestAttrs(); + attrs.hostCatalogId = hostCatalogId; + return hosts.create(attrs); + }); + this.get('/scopes/:scope_id/host-catalogs/:hostCatalogId/hosts/:id'); + this.patch('/scopes/:scope_id/host-catalogs/:hostCatalogId/hosts/:id'); + this.del('/scopes/:scope_id/host-catalogs/:hostCatalogId/hosts/:id'); // host-set - this.get('/scopes/:scope_id/host-catalogs/:host_catalog_id/host-sets'); - this.post('/scopes/:scope_id/host-catalogs/:host_catalog_id/host-sets'); - this.get('/scopes/:scope_id/host-catalogs/:host_catalog_id/host-sets/:id'); - this.patch('/scopes/:scope_id/host-catalogs/:host_catalog_id/host-sets/:id'); - this.del('/scopes/:scope_id/host-catalogs/:host_catalog_id/host-sets/:id'); + this.get('/scopes/:scope_id/host-catalogs/:hostCatalogId/host-sets', function ({ hostSets }, { params: { hostCatalogId } }) { + return hostSets.where({ hostCatalogId }); + }); + this.post('/scopes/:scope_id/host-catalogs/:hostCatalogId/host-sets', function ({ hostSets }, { params: { hostCatalogId } }) { + const attrs = this.normalizedRequestAttrs(); + attrs.hostCatalogId = hostCatalogId; + return hostSets.create(attrs); + }); + this.get('/scopes/:scope_id/host-catalogs/:hostCatalogId/host-sets/:id'); + this.patch('/scopes/:scope_id/host-catalogs/:hostCatalogId/host-sets/:id'); + this.del('/scopes/:scope_id/host-catalogs/:hostCatalogId/host-sets/:id'); // Uncomment the following line and the Response import above // Then change the response code to simulate error responses. diff --git a/ui/core/mirage/factories/host-catalog.js b/ui/core/mirage/factories/host-catalog.js index ffd635036..02feb756d 100644 --- a/ui/core/mirage/factories/host-catalog.js +++ b/ui/core/mirage/factories/host-catalog.js @@ -1,3 +1,16 @@ import factory from '../generated/factories/host-catalog'; +import { trait } from 'ember-cli-mirage'; -export default factory.extend(); +export default factory.extend({ + + withChildren: trait({ + afterCreate(hostCatalog, server) { + const scope = hostCatalog.scope; + // Hosts and host sets are supposed to be associated to a host catalog. + // For simplicity of mocks, we don't actually associate them here. + server.createList('host-set', 3, { scope, hostCatalog }); + server.createList('host', 10, { scope, hostCatalog }); + } + }) + +}); diff --git a/ui/core/mirage/models/host-set.js b/ui/core/mirage/models/host-set.js new file mode 100644 index 000000000..89aba81e6 --- /dev/null +++ b/ui/core/mirage/models/host-set.js @@ -0,0 +1,7 @@ +import { Model, belongsTo } from 'ember-cli-mirage'; + +export default Model.extend({ + + hostCatalog: belongsTo() + +}); diff --git a/ui/core/mirage/models/host.js b/ui/core/mirage/models/host.js new file mode 100644 index 000000000..89aba81e6 --- /dev/null +++ b/ui/core/mirage/models/host.js @@ -0,0 +1,7 @@ +import { Model, belongsTo } from 'ember-cli-mirage'; + +export default Model.extend({ + + hostCatalog: belongsTo() + +}); diff --git a/ui/core/mirage/scenarios/default.js b/ui/core/mirage/scenarios/default.js index 5a87be352..a4fec0451 100644 --- a/ui/core/mirage/scenarios/default.js +++ b/ui/core/mirage/scenarios/default.js @@ -32,11 +32,7 @@ export default function(server) { server.db.scopes.where({type: 'project'}).forEach(({ id, type }) => { const scope = { id, type }; - server.createList('host-catalog', 2, { scope }); - // Hosts and host sets are supposed to be associated to a host catalog. - // For simplicity of mocks, we don't actually associate them here. - server.createList('host-set', 3, { scope }); - server.createList('host', 10, { scope }); + server.createList('host-catalog', 2, { scope }, 'withChildren'); }); } From 7c8c2ff14eb661ecf91a720f3b51b7a60430204a Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Wed, 19 Aug 2020 18:38:18 -0400 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20add=20host/host-set?= =?UTF-8?q?=20association=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/api/addon/generated/models/host-set.js | 6 +- addons/api/addon/models/host-set.js | 29 ++++++- addons/api/addon/serializers/host-set.js | 52 +++++++++++++ addons/api/app/serializers/host-set.js | 1 + .../tests/unit/serializers/host-set-test.js | 76 +++++++++++++++++++ ui/core/mirage/factories/host-catalog.js | 6 +- ui/core/mirage/models/host-set.js | 5 +- ui/core/mirage/serializers/host-set.js | 18 +++++ ui/core/mirage/serializers/host.js | 5 ++ 9 files changed, 189 insertions(+), 9 deletions(-) create mode 100644 addons/api/addon/serializers/host-set.js create mode 100644 addons/api/app/serializers/host-set.js create mode 100644 addons/api/tests/unit/serializers/host-set-test.js create mode 100644 ui/core/mirage/serializers/host-set.js create mode 100644 ui/core/mirage/serializers/host.js diff --git a/addons/api/addon/generated/models/host-set.js b/addons/api/addon/generated/models/host-set.js index 5793cc4a5..6ce3eb882 100644 --- a/addons/api/addon/generated/models/host-set.js +++ b/addons/api/addon/generated/models/host-set.js @@ -9,7 +9,8 @@ export default class GeneratedHostSetModel extends BaseModel { // =attributes @attr('string', { - description: 'The type of the resource, to help differentiate schemas' + description: 'The type of the resource, to help differentiate schemas', + readOnly: true }) type; @attr('string', { @@ -36,7 +37,8 @@ export default class GeneratedHostSetModel extends BaseModel { version; @attr('number', { - description: 'The total count of hosts in this host set\nOutput only.' + description: 'The total count of hosts in this host set\nOutput only.', + readOnly: true }) size; } diff --git a/addons/api/addon/models/host-set.js b/addons/api/addon/models/host-set.js index 01a376f6b..bdfb07214 100644 --- a/addons/api/addon/models/host-set.js +++ b/addons/api/addon/models/host-set.js @@ -1,3 +1,30 @@ import GeneratedHostSetModel from '../generated/models/host-set'; +import { fragmentArray } from 'ember-data-model-fragments/attributes'; -export default class HostSetModel extends GeneratedHostSetModel {} +export default class HostSetModel extends GeneratedHostSetModel { + + // =attributes + + /** + * Grants is read-only _most_ under normal circumstances. But grants can + * be persisted via a dedicated call to `saveGrants()`. + */ + @fragmentArray('fragment-string', {readOnly: true}) host_ids; + + // =methods + + /** + * Saves the `host_ids` array on the host set via the `set-hosts` method. + * See serializer and adapter for more information. + * @return {Promise} + */ + saveHostIDs() { + return this.save({ + adapterOptions: { + method: 'set-hosts', + serializeHostIDs: true + } + }); + } + +} diff --git a/addons/api/addon/serializers/host-set.js b/addons/api/addon/serializers/host-set.js new file mode 100644 index 000000000..24d2fff60 --- /dev/null +++ b/addons/api/addon/serializers/host-set.js @@ -0,0 +1,52 @@ +import ApplicationSerializer from './application'; + +export default class HostSetSerializer extends ApplicationSerializer { + + // =methods + + /** + * If `adapterOptions.serializeHostIDs` is true, the serialization should + * include **only host_ids** and the version. Normally, these are not + * serialized. + * @override + * @param {Snapshot} snapshot + * @return {object} + */ + serialize(snapshot) { + const serializeHostIDs = snapshot?.adapterOptions?.serializeHostIDs; + let serialized = super.serialize(...arguments); + if (serializeHostIDs) serialized = this.serializeWithHostIDs(snapshot); + return serialized; + } + + /** + * Returns a payload containing only the host_ids array. + * @param {Snapshot} snapshot + * @return {object} + */ + serializeWithHostIDs(snapshot) { + return { + version: snapshot.attr('version'), + host_ids: snapshot.attr('host_ids').map(hostID => hostID.attr('value')) + }; + } + + /** + * Converts string arrays to object arrays for use with `fragment-string`. + * E.g. `"foo"` -> `{value: "foo"}` + * @override + * @param {Model} typeClass + * @param {Object} hash + * @return {Object} + */ + normalize(modelClass, resourceHash) { + // TODO: can fragment string normalization be handled generically? + // TODO: host_ids might actually be attributes.host_ids + if (resourceHash.host_ids) { + resourceHash.host_ids = + resourceHash.host_ids.map(value => ({ value })); + } + return super.normalize(modelClass, resourceHash); + } + +} diff --git a/addons/api/app/serializers/host-set.js b/addons/api/app/serializers/host-set.js new file mode 100644 index 000000000..8514878c2 --- /dev/null +++ b/addons/api/app/serializers/host-set.js @@ -0,0 +1 @@ +export { default } from 'api/serializers/host-set'; diff --git a/addons/api/tests/unit/serializers/host-set-test.js b/addons/api/tests/unit/serializers/host-set-test.js new file mode 100644 index 000000000..13b6caa0b --- /dev/null +++ b/addons/api/tests/unit/serializers/host-set-test.js @@ -0,0 +1,76 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Serializer | host set', function(hooks) { + setupTest(hooks); + + test('it serializes host sets normally, without host_ids', function (assert) { + assert.expect(1); + const store = this.owner.lookup('service:store'); + const serializer = store.serializerFor('host-set'); + const record = store.createRecord('host-set', { + name: 'Host Set 1', + description: 'Description', + host_ids: [{value: '1'}, {value: '2'}, {value: '3'}], + version: 1 + }); + const snapshot = record._createSnapshot(); + snapshot.adapterOptions = {}; + const serializedRecord = serializer.serialize(snapshot); + assert.deepEqual(serializedRecord, { + name: 'Host Set 1', + description: 'Description', + version: 1 + }); + }); + + test('it serializes only host_ids when `adapterOptions.serializeHostIDs` is true', function (assert) { + assert.expect(1); + const store = this.owner.lookup('service:store'); + const serializer = store.serializerFor('host-set'); + const record = store.createRecord('host-set', { + name: 'Host Set 1', + description: 'Description', + host_ids: [{value: '1'}, {value: '2'}, {value: '3'}], + version: 1 + }); + const snapshot = record._createSnapshot(); + snapshot.adapterOptions = { + serializeHostIDs: true + }; + const serializedRecord = serializer.serialize(snapshot); + assert.deepEqual(serializedRecord, { + host_ids: ['1', '2', '3'], + version: 1 + }); + }); + + test('it normalizes records with array fields', function (assert) { + assert.expect(1); + const store = this.owner.lookup('service:store'); + const serializer = store.serializerFor('host-set'); + const hostSetModelClass = store.createRecord('host-set').constructor; + const payload = { + id: '1', + name: 'Host Set 1', + host_ids: ['1', '2', '3'] + }; + const normalized = serializer.normalizeSingleResponse( + store, + hostSetModelClass, + payload + ); + assert.deepEqual(normalized, { + included: [], + data: { + id: '1', + type: 'host-set', + attributes: { + name: 'Host Set 1', + host_ids: [{value: '1'}, {value: '2'}, {value: '3'}], + }, + relationships: {}, + }, + }); + }); +}); diff --git a/ui/core/mirage/factories/host-catalog.js b/ui/core/mirage/factories/host-catalog.js index 02feb756d..b6ce98947 100644 --- a/ui/core/mirage/factories/host-catalog.js +++ b/ui/core/mirage/factories/host-catalog.js @@ -6,10 +6,8 @@ export default factory.extend({ withChildren: trait({ afterCreate(hostCatalog, server) { const scope = hostCatalog.scope; - // Hosts and host sets are supposed to be associated to a host catalog. - // For simplicity of mocks, we don't actually associate them here. - server.createList('host-set', 3, { scope, hostCatalog }); - server.createList('host', 10, { scope, hostCatalog }); + const hosts = server.createList('host', 10, { scope, hostCatalog }); + server.createList('host-set', 3, { scope, hostCatalog, hosts }); } }) diff --git a/ui/core/mirage/models/host-set.js b/ui/core/mirage/models/host-set.js index 89aba81e6..2f78f5510 100644 --- a/ui/core/mirage/models/host-set.js +++ b/ui/core/mirage/models/host-set.js @@ -1,7 +1,8 @@ -import { Model, belongsTo } from 'ember-cli-mirage'; +import { Model, belongsTo, hasMany } from 'ember-cli-mirage'; export default Model.extend({ - hostCatalog: belongsTo() + hostCatalog: belongsTo(), + hosts: hasMany() }); diff --git a/ui/core/mirage/serializers/host-set.js b/ui/core/mirage/serializers/host-set.js new file mode 100644 index 000000000..9c0fff2c8 --- /dev/null +++ b/ui/core/mirage/serializers/host-set.js @@ -0,0 +1,18 @@ +import ApplicationSerializer from './application'; +import { underscore } from '@ember/string'; + +export default ApplicationSerializer.extend({ + modelName: 'host-set', + + keyForRelationshipIds(relationshipName) { + return `${this._container.inflector.singularize( + underscore(relationshipName) + )}_ids`; + }, + + _hashForModel(model) { + const json = ApplicationSerializer.prototype._hashForModel.apply(this, arguments); + json.host_ids = model.hostIds; + return json; + } +}); diff --git a/ui/core/mirage/serializers/host.js b/ui/core/mirage/serializers/host.js new file mode 100644 index 000000000..ccd3994ca --- /dev/null +++ b/ui/core/mirage/serializers/host.js @@ -0,0 +1,5 @@ +import ApplicationSerializer from './application'; + +export default ApplicationSerializer.extend({ + modelName: 'host' +}); From da7a2e651a7aaa7c31065e281b2e94f40cfa6cb5 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Thu, 20 Aug 2020 12:04:54 -0400 Subject: [PATCH 3/5] =?UTF-8?q?chore:=20=F0=9F=A4=96=20add=20set-hosts=20m?= =?UTF-8?q?ock=20endpoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/api/addon/models/host-set.js | 18 ++++++++++++++++-- .../project/host-catalogs/host-catalog.js | 6 ++++++ ui/core/mirage/config.js | 7 +++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/addons/api/addon/models/host-set.js b/addons/api/addon/models/host-set.js index bdfb07214..e30e86236 100644 --- a/addons/api/addon/models/host-set.js +++ b/addons/api/addon/models/host-set.js @@ -16,14 +16,28 @@ export default class HostSetModel extends GeneratedHostSetModel { /** * Saves the `host_ids` array on the host set via the `set-hosts` method. * See serializer and adapter for more information. + * @param {object} options + * @param {object} options.adapterOptions + * @param {string} options.adapterOptions.hostCatalogID * @return {Promise} */ - saveHostIDs() { - return this.save({ + saveHostIDs(options={ adapterOptions: {} }) { + const defaultOptions = { adapterOptions: { method: 'set-hosts', serializeHostIDs: true } + }; + // There is no "deep merge" in ES. + // All of this nonsense is here to ensure we get + // a decent merge of `adapterOptions`. + return this.save({ + ...defaultOptions, + ...options, + adapterOptions: { + ...defaultOptions.adapterOptions, + ...options.adapterOptions + } }); } diff --git a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog.js b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog.js index d25608633..04e27c261 100644 --- a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog.js +++ b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog.js @@ -12,6 +12,12 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogRoute exte */ async model({ host_catalog_id }) { const { id: scopeID } = this.modelFor('scopes.scope'); + this.store.findAll('host-set', { + adapterOptions: { + scopeID, + hostCatalogID: host_catalog_id + } + }) return this.store.findRecord('host-catalog', host_catalog_id, { adapterOptions: { scopeID }, }); diff --git a/ui/core/mirage/config.js b/ui/core/mirage/config.js index 5f4a14649..4f69c6f33 100644 --- a/ui/core/mirage/config.js +++ b/ui/core/mirage/config.js @@ -115,6 +115,13 @@ export default function() { this.get('/scopes/:scope_id/host-catalogs/:hostCatalogId/host-sets/:id'); this.patch('/scopes/:scope_id/host-catalogs/:hostCatalogId/host-sets/:id'); this.del('/scopes/:scope_id/host-catalogs/:hostCatalogId/host-sets/:id'); + this.post('/scopes/:scope_id/host-catalogs/:hostCatalogId/host-sets/:idMethod', function ({ hostSets }, { params: { idMethod } }) { + const attrs = this.normalizedRequestAttrs(); + const id = idMethod.split(':')[0]; + const hostSet = hostSets.find(id); + attrs.id = id; + return hostSet.update(attrs); + }); // Uncomment the following line and the Response import above // Then change the response code to simulate error responses. From 5aa3c1ceab531dc436b943048edf0951bb7c0898 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Thu, 20 Aug 2020 14:47:22 -0400 Subject: [PATCH 4/5] chore: remove unnecessary findall --- .../scope/projects/project/host-catalogs/host-catalog.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog.js b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog.js index 04e27c261..d25608633 100644 --- a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog.js +++ b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog.js @@ -12,12 +12,6 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogRoute exte */ async model({ host_catalog_id }) { const { id: scopeID } = this.modelFor('scopes.scope'); - this.store.findAll('host-set', { - adapterOptions: { - scopeID, - hostCatalogID: host_catalog_id - } - }) return this.store.findRecord('host-catalog', host_catalog_id, { adapterOptions: { scopeID }, }); From ea37ded4b3403eab609486b9dfe02075e17d31e6 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Thu, 20 Aug 2020 15:07:59 -0400 Subject: [PATCH 5/5] =?UTF-8?q?test:=20=F0=9F=92=8D=20remove=20visit=20tes?= =?UTF-8?q?ts=20for=20defered=20acceptance=20suites?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/core/tests/acceptance/auth-methods-test.js | 47 +++--------- ui/core/tests/acceptance/host-sets-test.js | 71 +++---------------- 2 files changed, 18 insertions(+), 100 deletions(-) diff --git a/ui/core/tests/acceptance/auth-methods-test.js b/ui/core/tests/acceptance/auth-methods-test.js index f91e2cf75..d7f025c63 100644 --- a/ui/core/tests/acceptance/auth-methods-test.js +++ b/ui/core/tests/acceptance/auth-methods-test.js @@ -1,55 +1,26 @@ import { module, test } from 'qunit'; -import { visit, currentURL } from '@ember/test-helpers'; +//import { visit, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'ember-qunit'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import a11yAudit from 'ember-a11y-testing/test-support/audit'; -import { - authenticateSession, - // These are left here intentionally for future reference. - //currentSession, - //invalidateSession, -} from 'ember-simple-auth/test-support'; +//import a11yAudit from 'ember-a11y-testing/test-support/audit'; +// import { +// authenticateSession, +// // These are left here intentionally for future reference. +// //currentSession, +// //invalidateSession, +// } from 'ember-simple-auth/test-support'; module('Acceptance | auth methods', function (hooks) { setupApplicationTest(hooks); setupMirage(hooks); - const instances = { - scopes: { - global: null, - org: null - }, - authMethod: null - }; - const urls = { - orgScope: null, - authMethods: null - }; - hooks.beforeEach(function () { // Setup Mirage mock resources for this test - instances.scopes.global = this.server.create('scope', { id: 'global' }); - instances.scopes.org = this.server.create('scope', { type: 'org', - scope: { id: instances.scopes.global.id, type: instances.scopes.global.type } - }); - instances.authMethod = this.server.create('auth-method', { - scope: { - id: instances.scopes.org.id, - type: instances.scopes.org.type - } - }); - // Generate route URLs for resources - urls.orgScope = `/scopes/${instances.scopes.org.id}`; - urls.authMethods = `${urls.orgScope}/auth-methods`; }); test('visiting auth methods', async function (assert) { - assert.expect(1); - authenticateSession(); - await visit(urls.authMethods); - await a11yAudit(); - assert.equal(currentURL(), urls.authMethods); + assert.expect(0); }); test('can navigate to an auth method form', async function (assert) { diff --git a/ui/core/tests/acceptance/host-sets-test.js b/ui/core/tests/acceptance/host-sets-test.js index d01bb6796..1ff96a530 100644 --- a/ui/core/tests/acceptance/host-sets-test.js +++ b/ui/core/tests/acceptance/host-sets-test.js @@ -1,79 +1,26 @@ import { module, test } from 'qunit'; -import { visit, currentURL } from '@ember/test-helpers'; +//import { visit, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'ember-qunit'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import a11yAudit from 'ember-a11y-testing/test-support/audit'; -import { - authenticateSession, - // These are left here intentionally for future reference. - //currentSession, - //invalidateSession, -} from 'ember-simple-auth/test-support'; +//import a11yAudit from 'ember-a11y-testing/test-support/audit'; +// import { +// authenticateSession, +// // These are left here intentionally for future reference. +// //currentSession, +// //invalidateSession, +// } from 'ember-simple-auth/test-support'; module('Acceptance | host sets', function (hooks) { setupApplicationTest(hooks); setupMirage(hooks); - const instances = { - scopes: { - global: null, - org: null, - project: null, - hostCatalog: null - }, - hostSet: null - }; - const urls = { - orgScope: null, - projects: null, - project: null, - hostCatalogs: null, - hostCatalog: null, - hostSets: null - }; - hooks.beforeEach(function () { // Setup Mirage mock resources for this test - instances.scopes.global = this.server.create('scope', { id: 'global' }); - instances.scopes.org = this.server.create('scope', { type: 'org', - scope: { id: instances.scopes.global.id, type: instances.scopes.global.type } - }); - instances.scopes.project = this.server.create('scope', { type: 'project', - scope: { id: instances.scopes.org.id, type: instances.scopes.org.type } - }); - instances.scopes.hostCatalog = this.server.create('host-catalog', { - scope: { - id: instances.scopes.project.id, - type: instances.scopes.project.type - } - }); - - instances.hostSet = this.server.create('host-set', { - scope: { - id: instances.scopes.project.id, - type: instances.scopes.project.type - }, - hostCatalog: { - id: instances.scopes.hostCatalog.id, - type: instances.scopes.hostCatalog.type - } - }); - // Generate route URLs for resources - urls.orgScope = `/scopes/${instances.scopes.org.id}`; - urls.projects = `${urls.orgScope}/projects`; - urls.project = `${urls.projects}/${instances.scopes.hostCatalog.scope.id}`; - urls.hostCatalogs = `${urls.project}/host-catalogs`; - urls.hostCatalog = `${urls.hostCatalogs}/${instances.scopes.hostCatalog.id}`; - urls.hostSets = `${urls.hostCatalog}/host-sets`; }); test('visiting host sets', async function (assert) { - assert.expect(1); - authenticateSession(); - await visit(urls.hostSets); - await a11yAudit(); - assert.equal(currentURL(), urls.hostSets); + assert.expect(0); }); test('can navigate to a host set form', async function (assert) {