Merge branch 'develop' into refactor-component-structure

This commit is contained in:
Randall Morey authored and GitHub committed 2020-09-24 14:57:59 -04:00
commit a97a21ab5a
7 files changed
+727 -140

No files matched your search

+39 -51
View File
@@ -15,49 +15,53 @@ module('Acceptance | groups', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
let orgScope;
let groupsURL;
let groupURL;
let newGroupURL;
const instances = {
scopes: {
global: null,
org: null,
},
group: null,
};
const urls = {
orgScope: null,
groups: null,
group: null,
newGroup: null,
};
hooks.beforeEach(function () {
orgScope = this.server.create(
'scope',
{
type: 'org',
},
'withChildren'
);
const group = this.server.create('group', {
scope: orgScope,
});
groupsURL = `/scopes/${orgScope.id}/groups`;
groupURL = `${groupsURL}/${group.id}`;
newGroupURL = `${groupsURL}/new`;
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.group = this.server.create('group', {
scope: instances.scopes.org,
});
urls.groups = `/scopes/${instances.scopes.org.id}/groups`;
urls.group = `${urls.groups}/${instances.group.id}`;
urls.newGroup = `${urls.groups}/new`;
});
test('visiting groups', async function (assert) {
assert.expect(1);
await visit(groupsURL);
await visit(urls.groups);
await a11yAudit();
assert.equal(currentURL(), groupsURL);
assert.equal(currentURL(), urls.groups);
});
test('visiting a group', async function (assert) {
assert.expect(1);
await visit(newGroupURL);
await visit(urls.newGroup);
await a11yAudit();
assert.equal(currentURL(), newGroupURL);
assert.equal(currentURL(), urls.newGroup);
});
test('can create new group', async function (assert) {
assert.expect(1);
const groupsCount = this.server.db.groups.length;
await visit(newGroupURL);
await visit(urls.newGroup);
await fillIn('[name="name"]', 'group name');
await click('[type="submit"]');
assert.equal(this.server.db.groups.length, groupsCount + 1);
@@ -66,10 +70,10 @@ module('Acceptance | groups', function (hooks) {
test('can cancel new group creation', async function (assert) {
assert.expect(2);
const groupsCount = this.server.db.groups.length;
await visit(newGroupURL);
await visit(urls.newGroup);
await fillIn('[name="name"]', 'group name');
await click('.rose-form-actions [type="button"]');
assert.equal(currentURL(), groupsURL);
assert.equal(currentURL(), urls.groups);
assert.equal(this.server.db.groups.length, groupsCount);
});
@@ -94,7 +98,7 @@ module('Acceptance | groups', function (hooks) {
}
);
});
await visit(newGroupURL);
await visit(urls.newGroup);
await fillIn('[name="name"]', 'group name');
await click('[type="submit"]');
assert.ok(
@@ -111,16 +115,16 @@ module('Acceptance | groups', function (hooks) {
test('can save changes to an existing group', async function (assert) {
assert.expect(2);
await visit(groupURL);
await visit(urls.group);
await fillIn('[name="name"]', 'Updated admin group');
await click('.rose-form-actions [type="submit"]');
assert.equal(currentURL(), groupURL);
assert.equal(currentURL(), urls.group);
assert.equal(this.server.db.groups[0].name, 'Updated admin group');
});
test('can cancel changes to an existing group', async function (assert) {
assert.expect(1);
await visit(groupURL);
await visit(urls.group);
await fillIn('[name="name"]', 'Updated admin group');
await click('.rose-form-actions [type="button"]');
assert.notEqual(find('[name="name"]').value, 'Updated admin group');
@@ -129,7 +133,7 @@ module('Acceptance | groups', function (hooks) {
test('can delete a group', async function (assert) {
assert.expect(1);
const groupsCount = this.server.db.groups.length;
await visit(groupURL);
await visit(urls.group);
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
assert.equal(this.server.db.groups.length, groupsCount - 1);
});
@@ -155,7 +159,7 @@ module('Acceptance | groups', function (hooks) {
}
);
});
await visit(groupURL);
await visit(urls.group);
await fillIn('[name="name"]', 'random string');
await click('[type="submit"]');
assert.ok(
@@ -183,7 +187,7 @@ module('Acceptance | groups', function (hooks) {
}
);
});
await visit(groupURL);
await visit(urls.group);
await fillIn('[name="name"]', 'Role name');
await click('[type="submit"]');
assert.ok(
@@ -206,7 +210,7 @@ module('Acceptance | groups', function (hooks) {
}
);
});
await visit(groupURL);
await visit(urls.group);
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
assert.ok(
find('[role="alert"]').textContent.trim(),
@@ -214,20 +218,4 @@ module('Acceptance | groups', function (hooks) {
'Displays primary error message.'
);
});
test('can view group members', async function (assert) {
assert.expect(0);
});
test('can delete members', async function (assert) {
assert.expect(0);
});
test('select and save members to add', async function (assert) {
assert.expect(0);
});
test('select and cancel members to add', async function (assert) {
assert.expect(0);
});
});
@@ -0,0 +1,141 @@
import { module, test } from 'qunit';
import { visit, currentURL, click, find, 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 { Response } from 'miragejs';
import {
authenticateSession,
// These are left here intentionally for future reference.
//currentSession,
//invalidateSession,
} from 'ember-simple-auth/test-support';
module('Acceptance | groups | members', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
const instances = {
scopes: {
global: null,
org: null,
},
group: null,
};
const urls = {
orgScope: null,
groups: null,
group: null,
members: null,
addMembers: null,
};
let membersCount;
hooks.beforeEach(function () {
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.group = this.server.create('group', {
scope: instances.scopes.org,
}, 'withMembers');
membersCount = instances.group.memberIds.length;
urls.groups = `/scopes/${instances.scopes.org.id}/groups`;
urls.group = `${urls.groups}/${instances.group.id}`;
urls.members = `${urls.group}/members`;
urls.addMembers = `${urls.group}/add-members`;
});
test('visiting group members', async function (assert) {
assert.expect(2);
await visit(urls.members);
await a11yAudit();
assert.equal(currentURL(), urls.members);
assert.equal(findAll('tbody tr').length, membersCount);
});
test('can remove a member', async function (assert) {
assert.expect(2);
await visit(urls.members);
assert.equal(findAll('tbody tr').length, membersCount);
await click('tbody tr .rose-dropdown-button-danger');
assert.equal(findAll('tbody tr').length, membersCount - 1);
});
test('shows error message on member remove', async function (assert) {
assert.expect(2);
this.server.post('/groups/:idMethod', () => {
return new Response(
400,
{},
{
status: 400,
code: 'invalid_argument',
message: 'The request was invalid.',
details: {},
}
);
});
await visit(urls.members);
assert.equal(findAll('tbody tr').length, membersCount);
await click('tbody tr .rose-dropdown-button-danger');
assert.ok(find('[role="alert"]'));
});
test('visiting member selection', async function(assert) {
assert.expect(1);
await visit(urls.addMembers);
await a11yAudit();
assert.equal(currentURL(), urls.addMembers);
});
test('select and save members to add', async function (assert) {
assert.expect(3);
instances.group.update({ memberIds: [] });
await visit(urls.members);
assert.equal(findAll('tbody tr').length, 0);
await click('.rose-layout-page-actions a')
assert.equal(currentURL(), urls.addMembers);
await click('tbody label');
await click('form [type="submit"]');
await visit(urls.members);
assert.equal(findAll('tbody tr').length, 1);
});
test('select and cancel members to add', async function (assert) {
assert.expect(4);
await visit(urls.members);
assert.equal(findAll('tbody tr').length, membersCount);
await click('tbody tr .rose-dropdown-button-danger');
assert.equal(findAll('tbody tr').length, membersCount - 1);
await click('.rose-layout-page-actions a')
assert.equal(currentURL(), urls.addMembers);
await click('tbody label');
await click('form [type="button"]');
await visit(urls.members);
assert.equal(findAll('tbody tr').length, membersCount - 1);
});
test('shows error message on member add', async function (assert) {
assert.expect(1);
this.server.post('/groups/:idMethod', () => {
return new Response(
400,
{},
{
status: 400,
code: 'invalid_argument',
message: 'The request was invalid.',
details: {},
}
);
});
instances.group.update({ memberIds: [] });
await visit(urls.addMembers);
await click('tbody label');
await click('form [type="submit"]');
assert.ok(find('[role="alert"]'));
});
});
+1 -11
View File
@@ -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"]');
@@ -0,0 +1,132 @@
import { module, test } from 'qunit';
import { visit, currentURL, fillIn, click, find, 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 { Response } from 'miragejs';
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,
hostSets: 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,
});
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}`;
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);
});
test('saving a new host set with invalid fields displays error messages', async function (assert) {
assert.expect(2);
this.server.post('/host-sets', () => {
return new Response(
400,
{},
{
status: 400,
code: 'invalid_argument',
message: 'The request was invalid.',
details: {
request_fields: [
{
name: 'name',
description: 'Name is required.',
},
],
},
}
);
});
await visit(urls.newHostSet);
await fillIn('[name="name"]', 'new target');
await click('form [type="submit"]');
await a11yAudit();
assert.ok(find('[role="alert"]'));
assert.ok(find('.rose-form-error-message'));
});
});
@@ -0,0 +1,132 @@
import { module, test } from 'qunit';
import { visit, currentURL, fillIn, click, find, 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 { Response } from 'miragejs';
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);
});
test('saving a new host with invalid fields displays error messages', async function (assert) {
assert.expect(2);
this.server.post('/hosts', () => {
return new Response(
400,
{},
{
status: 400,
code: 'invalid_argument',
message: 'The request was invalid.',
details: {
request_fields: [
{
name: 'name',
description: 'Name is required.',
},
],
},
}
);
});
await visit(urls.newHost);
await fillIn('[name="name"]', 'new target');
await click('form [type="submit"]');
await a11yAudit();
assert.ok(find('[role="alert"]'));
assert.ok(find('.rose-form-error-message'));
});
});
+138 -43
View File
@@ -1,73 +1,168 @@
import { module, test } from 'qunit';
//import { visit, currentURL } from '@ember/test-helpers';
import { visit, currentURL, fillIn, click, find } 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 { Response } from 'miragejs';
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,
hostSet: null,
};
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.hostSet = this.server.create('host-set', {
scope: instances.scopes.project,
hostCatalog: instances.hostCatalog
});
// 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.hostSet = `${urls.hostSets}/${instances.hostSet.id}`;
});
test('visiting host sets', async function (assert) {
assert.expect(0);
});
test('can navigate to a host set form', async function (assert) {
assert.expect(0);
test('visiting a host set', async function (assert) {
assert.expect(1);
await visit(urls.hostSet);
await a11yAudit();
assert.equal(currentURL(), urls.hostSet);
});
test('can update a host set and save changes', async function (assert) {
assert.expect(0);
assert.expect(3);
await visit(urls.hostSet);
await fillIn('[name="name"]', 'Updated name');
await fillIn('[name="description"]', 'Updated description');
await click('.rose-form-actions [type="submit"]');
assert.equal(currentURL(), urls.hostSet);
assert.equal(this.server.db.hostSets[0].name, 'Updated name');
assert.equal(this.server.db.hostSets[0].description, 'Updated description');
});
test('can update a host set and cancel changes', async function (assert) {
assert.expect(0);
assert.expect(1);
await visit(urls.hostSet);
await fillIn('[name="name"]', 'Updated name');
await click('.rose-form-actions [type="button"]');
assert.notEqual(find('[name="name"]').value, 'Updated name');
});
test('can create new host set', async function (assert) {
assert.expect(0);
});
test('can cancel new host set creation', async function (assert) {
assert.expect(0);
});
test('saving a new host set with invalid fields displays error messages', async function (assert) {
assert.expect(0);
});
test('errors are displayed when save on host set fails', async function (assert) {
assert.expect(0);
});
test('errors are displayed when delete on a host set fails', async function (assert) {
assert.expect(0);
test('can delete host set', async function (assert) {
assert.expect(2);
const hostSetsCount = this.server.db.hostSets.length;
await visit(urls.hostSet);
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
assert.equal(currentURL(), urls.hostSets);
assert.equal(this.server.db.hostSets.length, hostSetsCount - 1);
});
test('saving an existing host set with invalid fields displays error messages', async function (assert) {
assert.expect(0);
assert.expect(2);
this.server.patch('/host-sets/:id', () => {
return new Response(
400,
{},
{
status: 400,
code: 'invalid_argument',
message: 'The request was invalid.',
details: {
request_fields: [
{
name: 'name',
description: 'Name is required.',
},
],
},
}
);
});
await visit(urls.hostSet);
await fillIn('[name="name"]', 'existing host');
await click('[type="submit"]');
await a11yAudit();
assert.ok(find('[role="alert"]'));
assert.ok(find('.rose-form-error-message'));
});
test('can view hosts associated with a host set', async function (assert) {
assert.expect(0);
test('errors are displayed when save on host set fails', async function (assert) {
assert.expect(1);
this.server.patch('/host-sets/:id', () => {
return new Response(
490,
{},
{
status: 490,
code: 'error',
message: 'Oops.',
}
);
});
await visit(urls.hostSet);
await fillIn('[name="name"]', 'save host');
await click('form [type="submit"]');
await a11yAudit();
assert.ok(find('[role="alert"]'));
});
test('can add/remove host associations to a host set and save', async function (assert) {
assert.expect(0);
});
test('can cancel add/remove host associations to a host set', async function (assert) {
assert.expect(0);
test('errors are displayed when delete on a host set fails', async function (assert) {
assert.expect(1);
this.server.del('/host-sets/:id', () => {
return new Response(
490,
{},
{
status: 490,
code: 'error',
message: 'Oops.',
}
);
});
await visit(urls.hostSet);
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
await a11yAudit();
assert.ok(find('[role="alert"]'));
});
});
+144 -35
View File
@@ -1,61 +1,170 @@
import { module, test } from 'qunit';
// import { visit, currentURL } from '@ember/test-helpers';
import { visit, currentURL, fillIn, click, find } 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 { Response } from 'miragejs';
import {
authenticateSession,
// These are left here intentionally for future reference.
//currentSession,
//invalidateSession,
} from 'ember-simple-auth/test-support';
module('Acceptance | hosts', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
const instances = {
scopes: {
global: null,
org: null,
project: null,
},
hostCatalog: null,
host: null,
};
const urls = {
orgScope: null,
projects: null,
project: null,
hostCatalogs: null,
hostCatalog: null,
hosts: null,
host: null,
};
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.host = this.server.create('host', {
scope: instances.scopes.project,
hostCatalog: instances.hostCatalog
});
// 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.host = `${urls.hosts}/${instances.host.id}`;
});
test('visiting host', async function (assert) {
assert.expect(0);
});
test('can navigate to a host form', async function (assert) {
assert.expect(0);
test('visiting a host', async function (assert) {
assert.expect(1);
await visit(urls.host);
await a11yAudit();
assert.equal(currentURL(), urls.host);
});
test('can update a host and save changes', async function (assert) {
assert.expect(0);
assert.expect(4);
await visit(urls.host);
await fillIn('[name="name"]', 'Updated name');
await fillIn('[name="description"]', 'Updated description');
await fillIn('[name="address"]', '::1');
await click('.rose-form-actions [type="submit"]');
assert.equal(currentURL(), urls.host);
assert.equal(this.server.db.hosts[0].name, 'Updated name');
assert.equal(this.server.db.hosts[0].description, 'Updated description');
assert.equal(this.server.db.hosts[0].attributes.address, '::1');
});
test('can update a host and cancel changes', async function (assert) {
assert.expect(0);
assert.expect(1);
await visit(urls.host);
await fillIn('[name="name"]', 'Updated name');
await click('.rose-form-actions [type="button"]');
assert.notEqual(find('[name="name"]').value, 'Updated name');
});
test('can create new host', async function (assert) {
assert.expect(0);
});
test('can cancel new host creation', async function (assert) {
assert.expect(0);
});
test('saving a new host with invalid fields displays error messages', async function (assert) {
assert.expect(0);
});
test('errors are displayed when save on auth method fails', async function (assert) {
assert.expect(0);
});
test('errors are displayed when delete on a host fails', async function (assert) {
assert.expect(0);
test('can delete host', async function (assert) {
assert.expect(2);
const hostsCount = this.server.db.hosts.length;
await visit(urls.host);
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
assert.equal(currentURL(), urls.hosts);
assert.equal(this.server.db.hosts.length, hostsCount - 1);
});
test('saving an existing host with invalid fields displays error messages', async function (assert) {
assert.expect(0);
assert.expect(2);
this.server.patch('/hosts/:id', () => {
return new Response(
400,
{},
{
status: 400,
code: 'invalid_argument',
message: 'The request was invalid.',
details: {
request_fields: [
{
name: 'name',
description: 'Name is required.',
},
],
},
}
);
});
await visit(urls.host);
await fillIn('[name="name"]', 'existing host');
await click('[type="submit"]');
await a11yAudit();
assert.ok(find('[role="alert"]'));
assert.ok(find('.rose-form-error-message'));
});
test('errors are displayed when save on host fails', async function (assert) {
assert.expect(1);
this.server.patch('/hosts/:id', () => {
return new Response(
490,
{},
{
status: 490,
code: 'error',
message: 'Oops.',
}
);
});
await visit(urls.host);
await fillIn('[name="name"]', 'save host');
await click('form [type="submit"]');
await a11yAudit();
assert.ok(find('[role="alert"]'));
});
test('errors are displayed when delete on a host fails', async function (assert) {
assert.expect(1);
this.server.del('/hosts/:id', () => {
return new Response(
490,
{},
{
status: 490,
code: 'error',
message: 'Oops.',
}
);
});
await visit(urls.host);
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
await a11yAudit();
assert.ok(find('[role="alert"]'));
});
});