test: 💍 Update breadcrumbs and IAM acceptance tests under scope

This commit is contained in:
Susmitha Girumala committed 2020-07-28 12:10:22 -04:00
1 parent d2a4cc3f55
commit f749a200e4
13 files changed
+138 -88

No files matched your search

+24 -13
View File
@@ -7,7 +7,8 @@ module('Acceptance | breadcrumbs', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
let org;
let orgScope;
let getProjectScope;
let project;
let hostCatalog;
let user;
@@ -22,33 +23,43 @@ module('Acceptance | breadcrumbs', function (hooks) {
let crumbPath;
hooks.beforeEach(function () {
org = this.server.create('org');
project = this.server.create('project');
user = this.server.create('user');
orgScope = this.server.create(
'scope',
{
type: 'org',
},
'withChildren'
);
hostCatalog = this.server.create('host-catalog');
getProjectScope = () =>
this.server.schema.scopes.where({ type: 'project' }).models[0];
project = getProjectScope();
user = this.server.create('user');
role = this.server.create('role');
group = this.server.create('group');
projectsURL = `/orgs/${org.id}/projects`;
projectsURL = `/scopes/${orgScope.id}/projects`;
newProjectURL = `${projectsURL}/new`;
projectURL = `${projectsURL}/${project.id}`;
hostCatalogsURL = `${projectURL}/host-catalogs`;
newHostCatalogURL = `${hostCatalogsURL}/new`;
hostCatalogURL = `${hostCatalogsURL}/${hostCatalog.id}`;
rolesURL = `/orgs/${org.id}/roles`;
rolesURL = `/scopes/${orgScope.id}/roles`;
newRoleURL = `${rolesURL}/new`;
roleURL = `${rolesURL}/${role.id}`;
groupsURL = `/orgs/${org.id}/groups`;
groupsURL = `/scopes/${orgScope.id}/groups`;
newGroupURL = `${groupsURL}/new`;
groupURL = `${groupsURL}/${group.id}`;
usersURL = `/orgs/${org.id}/users`;
usersURL = `/scopes/${orgScope.id}/users`;
newUserURL = `${usersURL}/${user.id}`;
userURL = `${usersURL}/new`;
// TODO: Update hostcatalog to scopes
hostCatalog = this.server.create('host-catalog');
hostCatalogsURL = `${projectURL}/host-catalogs`;
newHostCatalogURL = `${hostCatalogsURL}/new`;
hostCatalogURL = `${hostCatalogsURL}/${hostCatalog.id}`;
});
test('can navigate via breadcrumbs to projects from project', async function (assert) {
+32 -19
View File
@@ -9,24 +9,37 @@ module('Acceptance | groups', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
let orgScope;
let groupsURL;
let newGroupURL;
hooks.beforeEach(function () {
this.server.create('org');
orgScope = this.server.create(
'scope',
{
type: 'org',
},
'withChildren'
);
groupsURL = `/scopes/${orgScope.id}/groups`;
newGroupURL = `${groupsURL}/new`;
});
test('visiting groups', async function (assert) {
assert.expect(1);
await visit('/orgs/1/groups');
await visit(groupsURL);
await a11yAudit();
assert.equal(currentURL(), '/orgs/1/groups');
assert.equal(currentURL(), groupsURL);
});
test('can create new group', async function (assert) {
assert.expect(4);
assert.equal(this.server.db.groups.length, 0);
await visit('/orgs/1/groups/new');
await visit(newGroupURL);
await fillIn('[name="name"]', 'group name');
await click('[type="submit"]');
assert.equal(currentURL(), '/orgs/1/groups/1');
assert.equal(currentURL(), `${groupsURL}/1`);
assert.equal(this.server.db.groups.length, 1);
assert.equal(this.server.db.groups[0].name, 'group name');
});
@@ -34,16 +47,16 @@ module('Acceptance | groups', function (hooks) {
test('can cancel new group creation', async function (assert) {
assert.expect(3);
assert.equal(this.server.db.groups.length, 0);
await visit('/orgs/1/groups/new');
await visit(newGroupURL);
await fillIn('[name="name"]', 'group name');
await click('.rose-form-actions [type="button"]');
assert.equal(currentURL(), '/orgs/1/groups');
assert.equal(currentURL(), groupsURL);
assert.equal(this.server.db.groups.length, 0);
});
test('saving a new group with invalid fields displays error messages', async function (assert) {
assert.expect(2);
this.server.post('/orgs/:org_id/groups', () => {
this.server.post('/scopes/:scope_id/groups', () => {
return new Response(
400,
{},
@@ -62,7 +75,7 @@ module('Acceptance | groups', function (hooks) {
}
);
});
await visit('/orgs/1/groups/new');
await visit(newGroupURL);
await fillIn('[name="name"]', 'group name');
await click('[type="submit"]');
assert.ok(
@@ -80,17 +93,17 @@ module('Acceptance | groups', function (hooks) {
test('can save changes to an existing group', async function (assert) {
assert.expect(2);
this.server.createList('group', 1, { name: 'Admin group' });
await visit('/orgs/1/groups/1');
await visit(`${groupsURL}/1`);
await fillIn('[name="name"]', 'Updated admin group');
await click('.rose-form-actions [type="submit"]');
assert.equal(currentURL(), '/orgs/1/groups/1');
assert.equal(currentURL(), `${groupsURL}/1`);
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);
this.server.createList('group', 1, { name: 'Admin group' });
await visit('/orgs/1/groups/1');
await visit(`${groupsURL}/1`);
await fillIn('[name="name"]', 'Updated admin group');
await click('.rose-form-actions [type="button"]');
assert.equal(find('[name="name"]').value, 'Admin group');
@@ -100,7 +113,7 @@ module('Acceptance | groups', function (hooks) {
assert.expect(2);
this.server.createList('group', 1);
assert.equal(this.server.db.groups.length, 1);
await visit('/orgs/1/groups/1');
await visit(`${groupsURL}/1`);
await click('.rose-button-warning');
assert.equal(this.server.db.groups.length, 0);
});
@@ -108,7 +121,7 @@ module('Acceptance | groups', function (hooks) {
test('saving an existing group with invalid fields displays error messages', async function (assert) {
assert.expect(2);
this.server.createList('group', 1);
this.server.patch('/orgs/:org_id/groups/:id', () => {
this.server.patch('/scopes/:scope_id/groups/:id', () => {
return new Response(
400,
{},
@@ -127,7 +140,7 @@ module('Acceptance | groups', function (hooks) {
}
);
});
await visit('/orgs/1/groups/1');
await visit(`${groupsURL}/1`);
await fillIn('[name="name"]', 'random string');
await click('[type="submit"]');
assert.ok(
@@ -145,7 +158,7 @@ module('Acceptance | groups', function (hooks) {
test('errors are displayed when save project fails', async function (assert) {
assert.expect(1);
this.server.createList('group', 1);
this.server.patch('/orgs/:org_id/groups/:id', () => {
this.server.patch('/scopes/:scope_id/groups/:id', () => {
return new Response(
490,
{},
@@ -156,7 +169,7 @@ module('Acceptance | groups', function (hooks) {
}
);
});
await visit('/orgs/1/groups/1');
await visit(`${groupsURL}/1`);
await fillIn('[name="name"]', 'Role name');
await click('[type="submit"]');
assert.ok(
@@ -169,7 +182,7 @@ module('Acceptance | groups', function (hooks) {
test('errors are displayed when delete project fails', async function (assert) {
assert.expect(1);
this.server.createList('group', 1);
this.server.del('/orgs/:org_id/groups/:id', () => {
this.server.del('/scopes/:scope_id/groups/:id', () => {
return new Response(
490,
{},
@@ -180,7 +193,7 @@ module('Acceptance | groups', function (hooks) {
}
);
});
await visit('/orgs/1/groups/1');
await visit(`${groupsURL}/1`);
await click('.rose-button-warning');
assert.ok(
find('[role="alert"]').textContent.trim(),
+32 -19
View File
@@ -9,24 +9,37 @@ module('Acceptance | roles', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
let orgScope;
let rolesURL;
let newRoleURL;
hooks.beforeEach(function () {
this.server.create('org');
orgScope = this.server.create(
'scope',
{
type: 'org',
},
'withChildren'
);
rolesURL = `/scopes/${orgScope.id}/roles`;
newRoleURL = `${rolesURL}/new`;
});
test('visiting roles', async function (assert) {
assert.expect(1);
await visit('/orgs/1/roles');
await visit(rolesURL);
await a11yAudit();
assert.equal(currentURL(), '/orgs/1/roles');
assert.equal(currentURL(), rolesURL);
});
test('can create new role', async function (assert) {
assert.expect(4);
assert.equal(this.server.db.roles.length, 0);
await visit('/orgs/1/roles/new');
await visit(newRoleURL);
await fillIn('[name="name"]', 'role name');
await click('[type="submit"]');
assert.equal(currentURL(), '/orgs/1/roles/1');
assert.equal(currentURL(), `${rolesURL}/1`);
assert.equal(this.server.db.roles.length, 1);
assert.equal(this.server.db.roles[0].name, 'role name');
});
@@ -34,16 +47,16 @@ module('Acceptance | roles', function (hooks) {
test('can cancel new role creation', async function (assert) {
assert.expect(3);
assert.equal(this.server.db.roles.length, 0);
await visit('/orgs/1/roles/new');
await visit(newRoleURL);
await fillIn('[name="name"]', 'role name');
await click('.rose-form-actions [type="button"]');
assert.equal(currentURL(), '/orgs/1/roles');
assert.equal(currentURL(), rolesURL);
assert.equal(this.server.db.roles.length, 0);
});
test('saving a new role with invalid fields displays error messages', async function (assert) {
assert.expect(2);
this.server.post('/orgs/:org_id/roles', () => {
this.server.post('/scopes/:scope_id/roles', () => {
return new Response(
400,
{},
@@ -62,7 +75,7 @@ module('Acceptance | roles', function (hooks) {
}
);
});
await visit('/orgs/1/roles/new');
await visit(newRoleURL);
await fillIn('[name="name"]', 'role name');
await click('[type="submit"]');
assert.ok(
@@ -80,17 +93,17 @@ module('Acceptance | roles', function (hooks) {
test('can save changes to an existing role', async function (assert) {
assert.expect(2);
this.server.createList('role', 1, { name: 'Admin role' });
await visit('/orgs/1/roles/1');
await visit(`${rolesURL}/1`);
await fillIn('[name="name"]', 'Updated admin role');
await click('.rose-form-actions [type="submit"]');
assert.equal(currentURL(), '/orgs/1/roles/1');
assert.equal(currentURL(), `${rolesURL}/1`);
assert.equal(this.server.db.roles[0].name, 'Updated admin role');
});
test('can cancel changes to an existing role', async function (assert) {
assert.expect(1);
this.server.createList('role', 1, { name: 'Admin role' });
await visit('/orgs/1/roles/1');
await visit(`${rolesURL}/1`);
await fillIn('[name="name"]', 'Updated admin role');
await click('.rose-form-actions [type="button"]');
assert.equal(find('[name="name"]').value, 'Admin role');
@@ -100,7 +113,7 @@ module('Acceptance | roles', function (hooks) {
assert.expect(2);
this.server.createList('role', 1);
assert.equal(this.server.db.roles.length, 1);
await visit('/orgs/1/roles/1');
await visit(`${rolesURL}/1`);
await click('.rose-button-warning');
assert.equal(this.server.db.roles.length, 0);
});
@@ -108,7 +121,7 @@ module('Acceptance | roles', function (hooks) {
test('saving an existing role with invalid fields displays error messages', async function (assert) {
assert.expect(2);
this.server.createList('role', 1);
this.server.patch('/orgs/:org_id/roles/:id', () => {
this.server.patch('/scopes/:scope_id/roles/:id', () => {
return new Response(
400,
{},
@@ -127,7 +140,7 @@ module('Acceptance | roles', function (hooks) {
}
);
});
await visit('/orgs/1/roles/1');
await visit(`${rolesURL}/1`);
await fillIn('[name="name"]', 'random string');
await click('[type="submit"]');
assert.ok(
@@ -145,7 +158,7 @@ module('Acceptance | roles', function (hooks) {
test('errors are displayed when save project fails', async function (assert) {
assert.expect(1);
this.server.createList('role', 1);
this.server.patch('/orgs/:org_id/roles/:id', () => {
this.server.patch('/scopes/:scope_id/roles/:id', () => {
return new Response(
490,
{},
@@ -156,7 +169,7 @@ module('Acceptance | roles', function (hooks) {
}
);
});
await visit('/orgs/1/roles/1');
await visit(`${rolesURL}/1`);
await fillIn('[name="name"]', 'Role name');
await click('[type="submit"]');
assert.ok(
@@ -169,7 +182,7 @@ module('Acceptance | roles', function (hooks) {
test('errors are displayed when delete project fails', async function (assert) {
assert.expect(1);
this.server.createList('role', 1);
this.server.del('/orgs/:org_id/roles/:id', () => {
this.server.del('/scopes/:scope_id/roles/:id', () => {
return new Response(
490,
{},
@@ -180,7 +193,7 @@ module('Acceptance | roles', function (hooks) {
}
);
});
await visit('/orgs/1/roles/1');
await visit(`${rolesURL}/1`);
await click('.rose-button-warning');
assert.ok(
find('[role="alert"]').textContent.trim(),
+32 -19
View File
@@ -9,25 +9,38 @@ module('Acceptance | users', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
let orgScope;
let usersURL;
let newUserURL;
hooks.beforeEach(function () {
this.server.create('org');
orgScope = this.server.create(
'scope',
{
type: 'org',
},
'withChildren'
);
usersURL = `/scopes/${orgScope.id}/users`;
newUserURL = `${usersURL}/new`;
});
test('visiting users', async function (assert) {
assert.expect(1);
this.server.createList('user', 1);
await visit('/orgs/1/users');
await visit(usersURL);
await a11yAudit();
assert.equal(currentURL(), '/orgs/1/users');
assert.equal(currentURL(), usersURL);
});
test('can create new users', async function (assert) {
assert.expect(4);
assert.equal(this.server.db.users.length, 0);
await visit('/orgs/1/users/new');
await visit(newUserURL);
await fillIn('[name="name"]', 'User name');
await click('[type="submit"]');
assert.equal(currentURL(), '/orgs/1/users/1');
assert.equal(currentURL(), `${usersURL}/1`);
assert.equal(this.server.db.users.length, 1);
assert.equal(this.server.db.users[0].name, 'User name');
});
@@ -35,16 +48,16 @@ module('Acceptance | users', function (hooks) {
test('can cancel creation of a new user', async function (assert) {
assert.expect(3);
assert.equal(this.server.db.users.length, 0);
await visit('/orgs/1/users/new');
await visit(newUserURL);
await fillIn('[name="name"]', 'User name');
await click('.rose-form-actions [type="button"]');
assert.equal(currentURL(), '/orgs/1/users');
assert.equal(currentURL(), usersURL);
assert.equal(this.server.db.users.length, 0);
});
test('saving a new user with invalid fields displays error messages', async function (assert) {
assert.expect(2);
this.server.post('/orgs/:org_id/users', () => {
this.server.post('scopes/:scope_id/users', () => {
return new Response(
400,
{},
@@ -63,7 +76,7 @@ module('Acceptance | users', function (hooks) {
}
);
});
await visit('/orgs/1/users/new');
await visit(newUserURL);
await fillIn('[name="name"]', 'User name');
await click('[type="submit"]');
assert.ok(
@@ -81,17 +94,17 @@ module('Acceptance | users', function (hooks) {
test('can save changes to an existing user', async function (assert) {
assert.expect(2);
this.server.createList('user', 1, { name: 'Test User' });
await visit('/orgs/1/users/1');
await visit(`${usersURL}/1`);
await fillIn('[name="name"]', 'Updated user name');
await click('.rose-form-actions [type="submit"]');
assert.equal(currentURL(), '/orgs/1/users/1');
assert.equal(currentURL(), `${usersURL}/1`);
assert.equal(this.server.db.users[0].name, 'Updated user name');
});
test('can cancel changes to an existing user', async function (assert) {
assert.expect(1);
this.server.createList('user', 1, { name: 'Test User' });
await visit('/orgs/1/users/1');
await visit(`${usersURL}/1`);
await fillIn('[name="name"]', 'Unsaved user name');
await click('.rose-form-actions [type="button"]');
assert.equal(find('[name="name"]').value, 'Test User');
@@ -101,7 +114,7 @@ module('Acceptance | users', function (hooks) {
assert.expect(2);
this.server.createList('user', 1);
assert.equal(this.server.db.users.length, 1);
await visit('/orgs/1/users/1');
await visit(`${usersURL}/1`);
await click('.rose-button-warning');
assert.equal(this.server.db.users.length, 0);
});
@@ -109,7 +122,7 @@ module('Acceptance | users', function (hooks) {
test('saving an existing user with invalid fields displays error messages', async function (assert) {
assert.expect(2);
this.server.createList('user', 1);
this.server.patch('/orgs/:org_id/users/:id', () => {
this.server.patch('/scopes/:scope_id/users/:id', () => {
return new Response(
400,
{},
@@ -128,7 +141,7 @@ module('Acceptance | users', function (hooks) {
}
);
});
await visit('/orgs/1/users/1');
await visit(`${usersURL}/1`);
await fillIn('[name="name"]', 'User name');
await click('[type="submit"]');
assert.ok(
@@ -146,7 +159,7 @@ module('Acceptance | users', function (hooks) {
test('errors are displayed when saving user fails', async function (assert) {
assert.expect(1);
this.server.createList('user', 1);
this.server.patch('/orgs/:org_id/users/:id', () => {
this.server.patch('/scopes/:scope_id/users/:id', () => {
return new Response(
490,
{},
@@ -157,7 +170,7 @@ module('Acceptance | users', function (hooks) {
}
);
});
await visit('/orgs/1/users/1');
await visit(`${usersURL}/1`);
await fillIn('[name="name"]', 'User name');
await click('[type="submit"]');
assert.ok(
@@ -170,7 +183,7 @@ module('Acceptance | users', function (hooks) {
test('errors are displayed when user deletion fails', async function (assert) {
assert.expect(1);
this.server.createList('user', 1);
this.server.del('/orgs/:org_id/users/:id', () => {
this.server.del('/scopes/:scope_id/users/:id', () => {
return new Response(
490,
{},
@@ -181,7 +194,7 @@ module('Acceptance | users', function (hooks) {
}
);
});
await visit('/orgs/1/users/1');
await visit(`${usersURL}/1`);
await click('.rose-button-warning');
assert.ok(
find('[role="alert"]').textContent.trim(),
@@ -1,11 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Controller | scopes/scope/groups', function(hooks) {
module('Unit | Controller | scopes/scope/groups', function (hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
test('it exists', function (assert) {
let controller = this.owner.lookup('controller:scopes/scope/groups');
assert.ok(controller);
});
@@ -1,11 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Controller | scopes/scope/groups/group', function(hooks) {
module('Unit | Controller | scopes/scope/groups/group', function (hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
test('it exists', function (assert) {
let controller = this.owner.lookup('controller:scopes/scope/groups/group');
assert.ok(controller);
});
@@ -1,11 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Controller | scopes/scope/groups/new', function(hooks) {
module('Unit | Controller | scopes/scope/groups/new', function (hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
test('it exists', function (assert) {
let controller = this.owner.lookup('controller:scopes/scope/groups/new');
assert.ok(controller);
});
@@ -1,11 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Controller | scopes/scope/roles', function(hooks) {
module('Unit | Controller | scopes/scope/roles', function (hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
test('it exists', function (assert) {
let controller = this.owner.lookup('controller:scopes/scope/roles');
assert.ok(controller);
});
@@ -1,11 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Controller | scopes/scope/roles/new', function(hooks) {
module('Unit | Controller | scopes/scope/roles/new', function (hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
test('it exists', function (assert) {
let controller = this.owner.lookup('controller:scopes/scope/roles/new');
assert.ok(controller);
});
@@ -1,11 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Controller | scopes/scope/roles/role', function(hooks) {
module('Unit | Controller | scopes/scope/roles/role', function (hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
test('it exists', function (assert) {
let controller = this.owner.lookup('controller:scopes/scope/roles/role');
assert.ok(controller);
});
@@ -1,11 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Controller | scopes/scope/users', function(hooks) {
module('Unit | Controller | scopes/scope/users', function (hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
test('it exists', function (assert) {
let controller = this.owner.lookup('controller:scopes/scope/users');
assert.ok(controller);
});
@@ -1,11 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Controller | scopes/scope/users/new', function(hooks) {
module('Unit | Controller | scopes/scope/users/new', function (hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
test('it exists', function (assert) {
let controller = this.owner.lookup('controller:scopes/scope/users/new');
assert.ok(controller);
});
@@ -1,11 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Controller | scopes/scope/users/user', function(hooks) {
module('Unit | Controller | scopes/scope/users/user', function (hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
test('it exists', function (assert) {
let controller = this.owner.lookup('controller:scopes/scope/users/user');
assert.ok(controller);
});