test: Add hosts in host catalog test

This commit is contained in:
Susmitha Girumala committed 2020-09-23 17:24:42 -04:00
1 parent 3d92653dde
commit 50518e7c4f
2 files changed
+108 -1

No files matched your search

@@ -21,6 +21,7 @@ module('Acceptance | host catalogs | host sets', function (hooks) {
project: null,
},
hostCatalog: null,
hostSets: null,
};
const urls = {
orgScope: null,
@@ -47,7 +48,11 @@ module('Acceptance | host catalogs | host sets', function (hooks) {
});
instances.hostCatalog = this.server.create('host-catalog', {
scope: instances.scopes.project,
}, 'withChildren');
});
instances.hostSets = this.server.createList('host-set', 3, {
scope: instances.scopes.project,
hostCatalog: instances.hostCatalog
});
hostSetsCount = instances.hostCatalog.hostSetIds.length;
// Generate route URLs for resources
urls.orgScope = `/scopes/${instances.scopes.org.id}`;
@@ -0,0 +1,102 @@
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 | hosts', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
const instances = {
scopes: {
global: null,
org: null,
project: null,
},
hostCatalog: null,
hosts: null,
};
const urls = {
orgScope: null,
projects: null,
project: null,
hostCatalogs: null,
hostCatalog: null,
hosts: null,
newHost: null
};
let hostsCount;
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,
});
instances.hosts = this.server.createList('host', 3, {
scope: instances.scopes.project,
hostCatalog: instances.hostCatalog
});
hostsCount = instances.hosts.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.hosts = `${urls.hostCatalog}/hosts`;
urls.newHost = `${urls.hosts}/new`;
});
test('visiting hosts', async function (assert) {
assert.expect(3);
await visit(urls.hosts);
await a11yAudit();
assert.equal(currentURL(), urls.hosts);
assert.ok(hostsCount);
assert.equal(findAll('tbody tr').length, hostsCount);
});
test('can navigate to a host form', async function (assert) {
assert.expect(1);
await visit(urls.hosts);
await click('main tbody .rose-table-header-cell:nth-child(1) a');
await a11yAudit();
assert.notEqual(currentURL(), urls.hosts);
});
test('can create host and save changes', async function (assert) {
assert.expect(1);
await visit(urls.newHost);
await fillIn('[name="name"]', 'Test Name');
await fillIn('[name="description"]', 'description');
await click('form [type="submit"]:not(:disabled)');
await visit(urls.hosts);
assert.equal(findAll('tbody tr').length, hostsCount + 1);
});
test('can create host and cancel changes', async function (assert) {
assert.expect(2);
await visit(urls.newHost);
await fillIn('[name="name"]', 'Test Name');
await click('form button:not([type="submit"])');
assert.equal(currentURL(), urls.hosts);
assert.equal(findAll('tbody tr').length, hostsCount);
});
});