Merge remote-tracking branch 'origin/develop' into ICU-606-orgs-acceptance-test

This commit is contained in:
Susmitha Girumala committed 2020-09-24 14:38:29 -04:00
commit 7ad189dc34
18 files changed
+589 -120

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,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 | 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);
});
});
@@ -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);
});
});