Merge branch 'develop' into ICU-349-groups-basic-views
This commit is contained in:
32 files changed
+724
-3
No files matched your search
@@ -10,10 +10,12 @@ module('Acceptance | breadcrumbs', function (hooks) {
|
||||
let org;
|
||||
let project;
|
||||
let hostCatalog;
|
||||
let user;
|
||||
let role;
|
||||
let group;
|
||||
let projectsURL, projectURL, newProjectURL;
|
||||
let hostCatalogsURL, hostCatalogURL, newHostCatalogURL;
|
||||
let usersURL, userURL, newUserURL;
|
||||
let rolesURL, roleURL, newRoleURL;
|
||||
let groupsURL, groupURL, newGroupURL;
|
||||
|
||||
@@ -22,6 +24,8 @@ module('Acceptance | breadcrumbs', function (hooks) {
|
||||
hooks.beforeEach(function () {
|
||||
org = this.server.create('org');
|
||||
project = this.server.create('project');
|
||||
user = this.server.create('user');
|
||||
|
||||
hostCatalog = this.server.create('host-catalog');
|
||||
role = this.server.create('role');
|
||||
group = this.server.create('group');
|
||||
@@ -41,6 +45,10 @@ module('Acceptance | breadcrumbs', function (hooks) {
|
||||
groupsURL = `/orgs/${org.id}/groups`;
|
||||
newGroupURL = `${groupsURL}/new`;
|
||||
groupURL = `${groupsURL}/${group.id}`;
|
||||
|
||||
usersURL = `/orgs/${org.id}/users`;
|
||||
newUserURL = `${usersURL}/${user.id}`;
|
||||
userURL = `${usersURL}/new`;
|
||||
});
|
||||
|
||||
test('can navigate via breadcrumbs to projects from project', async function (assert) {
|
||||
@@ -132,4 +140,24 @@ module('Acceptance | breadcrumbs', function (hooks) {
|
||||
await click(find('.rose-nav-breadcrumbs-link:first-child'));
|
||||
assert.equal(currentURL(), groupsURL, 'After navigating via breadcrumbs, we are one level up.');
|
||||
});
|
||||
|
||||
test('can navigate via breadcrumbs to users from user', async function (assert) {
|
||||
assert.expect(3);
|
||||
await visit(userURL);
|
||||
assert.equal(currentURL(), userURL, 'We begin on the expected page.');
|
||||
crumbPath = new URL(find('.rose-nav-breadcrumbs-link:last-child').href).pathname;
|
||||
assert.equal(crumbPath, userURL, 'Last crumb has expected URL.');
|
||||
await click(find('.rose-nav-breadcrumbs-link:first-child'));
|
||||
assert.equal(currentURL(), usersURL, 'After navigating via breadcrumbs, we are one level up.');
|
||||
});
|
||||
|
||||
test('can navigate via breadcrumbs to users from new user', async function (assert) {
|
||||
assert.expect(3);
|
||||
await visit(newUserURL);
|
||||
assert.equal(currentURL(), newUserURL, 'We begin on th expected page.');
|
||||
crumbPath = new URL(find('.rose-nav-breadcrumbs-link:last-child').href).pathname;
|
||||
assert.equal(crumbPath, newUserURL, 'Last crumb has expected URL.');
|
||||
await click(find('.rose-nav-breadcrumbs-link:first-child'));
|
||||
assert.equal(currentURL(), usersURL, 'After navigating via breadcrumbs, we are one level up.');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,192 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, currentURL, click, fillIn, 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 { Response } from 'miragejs';
|
||||
|
||||
module('Acceptance | users', function(hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.server.create('org');
|
||||
});
|
||||
|
||||
test('visiting users', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.createList('user', 1);
|
||||
await visit('/orgs/1/users');
|
||||
await a11yAudit();
|
||||
assert.equal(currentURL(), '/orgs/1/users');
|
||||
});
|
||||
|
||||
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 fillIn('[name="name"]', 'User name');
|
||||
await click('[type="submit"]');
|
||||
assert.equal(currentURL(), '/orgs/1/users/1');
|
||||
assert.equal(this.server.db.users.length, 1);
|
||||
assert.equal(this.server.db.users[0].name, 'User name');
|
||||
});
|
||||
|
||||
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 fillIn('[name="name"]', 'User name');
|
||||
await click('.rose-form-actions [type="button"]');
|
||||
assert.equal(currentURL(), '/orgs/1/users');
|
||||
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', () => {
|
||||
return new Response(
|
||||
400,
|
||||
{},
|
||||
{
|
||||
status: 400,
|
||||
code: 'invalid_argument',
|
||||
message: 'The request was invalid.',
|
||||
details: {
|
||||
fields: [
|
||||
{
|
||||
name: 'name',
|
||||
message: 'Name is required.',
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
await visit('/orgs/1/users/new');
|
||||
await fillIn('[name="name"]', 'User name');
|
||||
await click('[type="submit"]');
|
||||
assert.ok(
|
||||
find('[role="alert"]').textContent.trim(),
|
||||
'The request was invalid.',
|
||||
'Displays primary error message.'
|
||||
);
|
||||
assert.ok(
|
||||
find('.rose-form-error-message').textContent.trim(),
|
||||
'Name is required.',
|
||||
'Displays field-level errors.'
|
||||
);
|
||||
});
|
||||
|
||||
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 fillIn('[name="name"]', 'Updated user name');
|
||||
await click('.rose-form-actions [type="submit"]');
|
||||
assert.equal(currentURL(), '/orgs/1/users/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 fillIn('[name="name"]', 'Unsaved user name');
|
||||
await click('.rose-form-actions [type="button"]');
|
||||
assert.equal(find('[name="name"]').value, 'Test User');
|
||||
});
|
||||
|
||||
test('can delete an user', async function(assert) {
|
||||
assert.expect(2);
|
||||
this.server.createList('user', 1);
|
||||
assert.equal(this.server.db.users.length, 1);
|
||||
await visit('/orgs/1/users/1');
|
||||
await click('.rose-button-warning');
|
||||
assert.equal(this.server.db.users.length, 0);
|
||||
});
|
||||
|
||||
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', () => {
|
||||
return new Response(
|
||||
400,
|
||||
{},
|
||||
{
|
||||
status: 400,
|
||||
code: 'invalid_argument',
|
||||
message: 'The request was invalid.',
|
||||
details: {
|
||||
fields: [
|
||||
{
|
||||
name: 'name',
|
||||
message: 'Name is required.',
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
await visit('/orgs/1/users/1');
|
||||
await fillIn('[name="name"]', 'User name');
|
||||
await click('[type="submit"]');
|
||||
assert.ok(
|
||||
find('[role="alert"]').textContent.trim(),
|
||||
'The request was invalid.',
|
||||
'Displays primary error message.'
|
||||
);
|
||||
assert.ok(
|
||||
find('.rose-form-error-message').textContent.trim(),
|
||||
'Name is required.',
|
||||
'Displays field-level errors.'
|
||||
);
|
||||
});
|
||||
|
||||
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', () => {
|
||||
return new Response(
|
||||
490,
|
||||
{},
|
||||
{
|
||||
status: 490,
|
||||
code: 'error',
|
||||
message: 'Oops.',
|
||||
}
|
||||
);
|
||||
});
|
||||
await visit('/orgs/1/users/1');
|
||||
await fillIn('[name="name"]', 'User name');
|
||||
await click('[type="submit"]');
|
||||
assert.ok(
|
||||
find('[role="alert"]').textContent.trim(),
|
||||
'Oops.',
|
||||
'Displays primary error message.'
|
||||
);
|
||||
});
|
||||
|
||||
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', () => {
|
||||
return new Response(
|
||||
490,
|
||||
{},
|
||||
{
|
||||
status: 490,
|
||||
code: 'error',
|
||||
message: 'Oops.',
|
||||
}
|
||||
);
|
||||
});
|
||||
await visit('/orgs/1/users/1');
|
||||
await click('.rose-button-warning');
|
||||
assert.ok(
|
||||
find('[role="alert"]').textContent.trim(),
|
||||
'Oops.',
|
||||
'Displays primary error message.'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Controller | orgs/org/users', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let controller = this.owner.lookup('controller:orgs/org/users');
|
||||
assert.ok(controller);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Controller | orgs/org/users/new', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let controller = this.owner.lookup('controller:orgs/org/users/new');
|
||||
assert.ok(controller);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Controller | orgs/org/users/user', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let controller = this.owner.lookup('controller:orgs/org/users/user');
|
||||
assert.ok(controller);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | orgs/org/users', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:orgs/org/users');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | orgs/org/users/index', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:orgs/org/users/index');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | orgs/org/users/new', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:orgs/org/users/new');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | orgs/org/users/user', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:orgs/org/users/user');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user