diff --git a/ui/core/tests/acceptance/host-catalogs-test.js b/ui/core/tests/acceptance/host-catalogs-test.js index 677fada21..a9438517e 100644 --- a/ui/core/tests/acceptance/host-catalogs-test.js +++ b/ui/core/tests/acceptance/host-catalogs-test.js @@ -34,6 +34,7 @@ module('Acceptance | host catalogs', function (hooks) { hooks.beforeEach(function () { // Setup Mirage mock resources for this test + authenticateSession(); instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', @@ -58,7 +59,6 @@ module('Acceptance | host catalogs', function (hooks) { test('visiting host catalogs', async function (assert) { assert.expect(1); - authenticateSession(); await visit(urls.hostCatalogs); await a11yAudit(); assert.equal(currentURL(), urls.hostCatalogs); @@ -66,7 +66,6 @@ module('Acceptance | host catalogs', function (hooks) { test('can navigate to host catalog form', async function (assert) { assert.expect(1); - authenticateSession({}); await visit(urls.hostCatalogs); await click('main tbody .rose-table-header-cell:nth-child(1) a'); await a11yAudit(); @@ -76,7 +75,6 @@ module('Acceptance | host catalogs', function (hooks) { test('can delete host catalog', async function (assert) { assert.expect(2); const hostCatalogsCount = this.server.db.hostCatalogs.length; - authenticateSession({}); await visit(urls.hostCatalog); assert.equal(currentURL(), urls.hostCatalog); await click('.rose-layout-page-actions .rose-dropdown-button-danger'); @@ -85,7 +83,6 @@ module('Acceptance | host catalogs', function (hooks) { test('can update host catalog and save changes', async function (assert) { assert.expect(1); - authenticateSession({}); await visit(urls.hostCatalog); await fillIn('[name="name"]', 'Test Name'); await click('form [type="submit"]:not(:disabled)'); @@ -94,7 +91,6 @@ module('Acceptance | host catalogs', function (hooks) { test('can update host catalog and cancel changes', async function (assert) { assert.expect(1); - authenticateSession({}); await visit(urls.hostCatalog); await fillIn('[name="name"]', 'Test Name'); await click('form button:not([type="submit"])'); @@ -104,7 +100,6 @@ module('Acceptance | host catalogs', function (hooks) { test('can create host catalog and save changes', async function (assert) { assert.expect(1); const hostCatalogsCount = this.server.db.hostCatalogs.length; - authenticateSession({}); await visit(urls.newHostCatalog); await fillIn('[name="name"]', 'Test Name'); await click('form [type="submit"]:not(:disabled)'); @@ -114,7 +109,6 @@ module('Acceptance | host catalogs', function (hooks) { test('can create host catalog and cancel changes', async function (assert) { assert.expect(1); const hostCatalogsCount = this.server.db.hostCatalogs.length; - authenticateSession({}); await visit(urls.newHostCatalog); await fillIn('[name="name"]', 'Test Name'); await click('form button:not([type="submit"])'); @@ -134,7 +128,6 @@ module('Acceptance | host catalogs', function (hooks) { } ); }); - authenticateSession({}); await visit(urls.hostCatalog); await fillIn('[name="name"]', 'random string'); await click('form [type="submit"]'); @@ -159,7 +152,6 @@ module('Acceptance | host catalogs', function (hooks) { } ); }); - authenticateSession({}); await visit(urls.hostCatalog); await click('.rose-layout-page-actions .rose-dropdown-button-danger'); await a11yAudit(); @@ -191,7 +183,6 @@ module('Acceptance | host catalogs', function (hooks) { } ); }); - authenticateSession({}); await visit(urls.newHostCatalog); await fillIn('[name="name"]', 'random string'); await click('form [type="submit"]'); @@ -229,7 +220,6 @@ module('Acceptance | host catalogs', function (hooks) { } ); }); - authenticateSession({}); await visit(urls.hostCatalog); await fillIn('[name="name"]', 'random string'); await click('form [type="submit"]'); diff --git a/ui/core/tests/acceptance/host-catalogs/host-sets-test.js b/ui/core/tests/acceptance/host-catalogs/host-sets-test.js new file mode 100644 index 000000000..ae4421eab --- /dev/null +++ b/ui/core/tests/acceptance/host-catalogs/host-sets-test.js @@ -0,0 +1,97 @@ +import { module, test } from 'qunit'; +import { visit, currentURL, fillIn, click, findAll } 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'; + +module('Acceptance | host catalogs | host sets', function (hooks) { + setupApplicationTest(hooks); + setupMirage(hooks); + + const instances = { + scopes: { + global: null, + org: null, + project: null, + }, + hostCatalog: null, + }; + const urls = { + orgScope: null, + projects: null, + project: null, + hostCatalogs: null, + hostCatalog: null, + hostSets: null, + newHostSet: null + }; + let hostSetsCount; + + hooks.beforeEach(function () { + // Setup Mirage mock resources for this test + authenticateSession(); + instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.org = this.server.create('scope', { + type: 'org', + scope: { id: 'global', type: 'global' }, + }); + instances.scopes.project = this.server.create('scope', { + type: 'project', + scope: { id: instances.scopes.org.id, type: 'org' }, + }); + instances.hostCatalog = this.server.create('host-catalog', { + scope: instances.scopes.project, + }, 'withChildren'); + hostSetsCount = instances.hostCatalog.hostSetIds.length; + // Generate route URLs for resources + urls.orgScope = `/scopes/${instances.scopes.org.id}`; + urls.projects = `${urls.orgScope}/projects`; + urls.project = `${urls.projects}/${instances.hostCatalog.scope.id}`; + urls.hostCatalogs = `${urls.project}/host-catalogs`; + urls.hostCatalog = `${urls.hostCatalogs}/${instances.hostCatalog.id}`; + urls.hostSets = `${urls.hostCatalog}/host-sets`; + urls.newHostSet = `${urls.hostSets}/new`; + }); + + test('visiting host sets', async function (assert) { + assert.expect(3); + await visit(urls.hostSets); + await a11yAudit(); + assert.equal(currentURL(), urls.hostSets); + assert.ok(hostSetsCount); + assert.equal(findAll('tbody tr').length, hostSetsCount); + }); + + test('can navigate to a host set form', async function (assert) { + assert.expect(1); + await visit(urls.hostSets); + await click('main tbody .rose-table-header-cell:nth-child(1) a'); + await a11yAudit(); + assert.notEqual(currentURL(), urls.hostSets); + }); + + test('can create host set and save changes', async function (assert) { + assert.expect(1); + await visit(urls.newHostSet); + await fillIn('[name="name"]', 'Test Name'); + await fillIn('[name="description"]', 'description'); + await click('form [type="submit"]:not(:disabled)'); + await visit(urls.hostSets); + assert.equal(findAll('tbody tr').length, hostSetsCount + 1); + }); + + test('can create host set and cancel changes', async function (assert) { + assert.expect(2); + await visit(urls.newHostSet); + await fillIn('[name="name"]', 'Test Name'); + await click('form button:not([type="submit"])'); + assert.equal(currentURL(), urls.hostSets); + assert.equal(findAll('tbody tr').length, hostSetsCount); + }); +}); diff --git a/ui/core/tests/acceptance/host-catalogs/hosts-test.js b/ui/core/tests/acceptance/host-catalogs/hosts-test.js new file mode 100644 index 000000000..e69de29bb