Merge branch 'develop' into ICU-349-groups-basic-views
This commit is contained in:
32 files changed
+724
-3
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import ApplicationAdapter from './application';
|
||||
import ScopeAdapterMixin from '../mixins/scope-adapter';
|
||||
|
||||
export default class UserAdapter extends ApplicationAdapter.extend(
|
||||
ScopeAdapterMixin
|
||||
) {
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Project is scoped to org only, technically.
|
||||
* @type {boolean}
|
||||
*/
|
||||
includeProject = false;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'api/adapters/user';
|
||||
@@ -0,0 +1,21 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import config from 'ember-get-config';
|
||||
|
||||
module('Unit | Adapter | user', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let adapter = this.owner.lookup('adapter:user');
|
||||
assert.ok(adapter);
|
||||
});
|
||||
|
||||
test('it generates URL prefixes without project scope', function (assert) {
|
||||
assert.expect(1);
|
||||
const service = this.owner.lookup('service:scope');
|
||||
service.org = { id: 1 };
|
||||
service.project = { id: 2 };
|
||||
const adapter = this.owner.lookup('adapter:user');
|
||||
assert.equal(adapter.urlPrefix(), `${config.api.namespace}/orgs/1`);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
<Rose::Form
|
||||
@onSubmit={{@submit}}
|
||||
@cancel={{@cancel}}
|
||||
@disabled={{@model.isSaving}}
|
||||
@error={{@model.errors.base}}
|
||||
as |form|
|
||||
>
|
||||
|
||||
<form.input
|
||||
name="name"
|
||||
@type="name"
|
||||
@value={{@model.name}}
|
||||
@label={{t "form.label.name"}}
|
||||
@error={{@model.errors.name}}
|
||||
readonly={{false}}
|
||||
as |field|>
|
||||
{{#if @model.errors.name}}
|
||||
<field.errors as |errors|>
|
||||
{{#each @model.errors.name as |error|}}
|
||||
<errors.message>{{error.message}}</errors.message>
|
||||
{{/each}}
|
||||
</field.errors>
|
||||
{{/if}}
|
||||
</form.input>
|
||||
|
||||
<form.textarea
|
||||
name="description"
|
||||
@type="description"
|
||||
@value={{@model.description}}
|
||||
@label={{t "form.label.description"}}
|
||||
@error={{@model.errors.description}}
|
||||
disabled={{@model.isSaving}}
|
||||
readonly={{false}}
|
||||
as |field|>
|
||||
{{#if @model.errors.description}}
|
||||
<field.errors as |errors|>
|
||||
{{#each @model.errors.description as |error|}}
|
||||
<errors.message>{{error.message}}</errors.message>
|
||||
{{/each}}
|
||||
</field.errors>
|
||||
{{/if}}
|
||||
</form.textarea>
|
||||
|
||||
<form.actions
|
||||
@disabled={{if @model.cannotSave @model.cannotSave}}
|
||||
@submitText={{t "actions.save"}}
|
||||
@cancelText={{t "actions.cancel"}} />
|
||||
|
||||
</Rose::Form>
|
||||
@@ -0,0 +1,18 @@
|
||||
import Controller from '@ember/controller';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class OrgsOrgUsersController extends Controller {
|
||||
// =services
|
||||
|
||||
@service intl;
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
get breadCrumb() {
|
||||
return this.intl.t('resources.users');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import Controller from '@ember/controller';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class OrgsOrgUsersNewController extends Controller {
|
||||
// =services
|
||||
|
||||
@service intl;
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
get breadCrumb() {
|
||||
return this.intl.t('titles.new');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import Controller from '@ember/controller';
|
||||
import { alias } from '@ember/object/computed';
|
||||
|
||||
export default class OrgsOrgUsersUserController extends Controller {
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
@alias('model.displayName') breadCrumb;
|
||||
}
|
||||
@@ -18,6 +18,12 @@ Router.map(function () {
|
||||
});
|
||||
this.route('new');
|
||||
});
|
||||
|
||||
this.route('users', function() {
|
||||
this.route('user', { path: ':user_id' }, function() {});
|
||||
this.route('new');
|
||||
});
|
||||
|
||||
this.route('roles', function() {
|
||||
this.route('role', { path: ':role_id' }, function() {});
|
||||
this.route('new');
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class OrgsOrgUsersRoute extends Route {
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Returns all users from the store.
|
||||
* @return {Promise[UserModel]}
|
||||
*/
|
||||
model() {
|
||||
return this.store.findAll('user');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class OrgsOrgUsersIndexRoute extends Route {
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import Route from '@ember/routing/route';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class OrgsOrgUsersNewRoute extends Route {
|
||||
// =services
|
||||
|
||||
@service intl;
|
||||
@service notify;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Returns a new unsaved user.
|
||||
* @return {Promise{UserModel}}
|
||||
*/
|
||||
model() {
|
||||
return this.store.createRecord('user');
|
||||
}
|
||||
|
||||
// =actions
|
||||
|
||||
/**
|
||||
* Rollback changes on user to destroy unsaved instance
|
||||
* and redirect to users index.
|
||||
* @param {UserModel} user
|
||||
*/
|
||||
@action
|
||||
cancel(user) {
|
||||
user.rollbackAttributes();
|
||||
this.transitionTo('orgs.org.users');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle saving a user.
|
||||
* @param {UserModel} user
|
||||
* @param {Event} e
|
||||
*/
|
||||
@action
|
||||
async save(user) {
|
||||
try {
|
||||
await user.save();
|
||||
this.transitionTo('orgs.org.users.user', user);
|
||||
this.notify.success(this.intl.t('notify.user.create-success'));
|
||||
} catch (error) {
|
||||
// TODO: replace with translated strings
|
||||
this.notify.error(error.message, { closeAfter: null });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import Route from '@ember/routing/route';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class OrgsOrgUsersUserRoute extends Route {
|
||||
// =services
|
||||
|
||||
@service intl;
|
||||
@service notify;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Returns a user by id.
|
||||
* @param {object} params
|
||||
* @return {Promise{UserModel}}
|
||||
*/
|
||||
model({ user_id: id }) {
|
||||
return this.store.findRecord('user', id);
|
||||
}
|
||||
|
||||
// =actions
|
||||
|
||||
/**
|
||||
* Rollback changes on user.
|
||||
* @param {UserModel} user
|
||||
*/
|
||||
@action
|
||||
cancel(user) {
|
||||
user.rollbackAttributes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle save user.
|
||||
* @param {UserModel} user
|
||||
* @param {Event} e
|
||||
*/
|
||||
@action
|
||||
async save(user) {
|
||||
try {
|
||||
await user.save();
|
||||
this.notify.success(this.intl.t('notify.save-success'));
|
||||
} catch (error) {
|
||||
// TODO: replace with translated strings
|
||||
this.notify.error(error.message, { closeAfter: null });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the user and redirects to index.
|
||||
* @param {UserModel} user
|
||||
*/
|
||||
@action
|
||||
async delete(user) {
|
||||
try {
|
||||
await user.destroyRecord();
|
||||
this.transitionTo('orgs.org.users');
|
||||
this.notify.success(this.intl.t('notify.user.delete-success'));
|
||||
} catch (error) {
|
||||
// TODO: replace with translated strings
|
||||
this.notify.error(error.message, { closeAfter: null });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{{title (t "resources.users")}}
|
||||
|
||||
{{outlet}}
|
||||
@@ -0,0 +1,63 @@
|
||||
<Rose::Layout::Page as |page|>
|
||||
|
||||
<page.breadcrumbs>
|
||||
<BreadCrumbs />
|
||||
</page.breadcrumbs>
|
||||
|
||||
<page.header>
|
||||
<h2>{{t "resources.users"}}</h2>
|
||||
</page.header>
|
||||
|
||||
<page.actions>
|
||||
{{#if @model}}
|
||||
<Rose::LinkButton @route="orgs.org.users.new" @style="primary">{{t 'titles.new'}}</Rose::LinkButton>
|
||||
{{/if}}
|
||||
</page.actions>
|
||||
|
||||
<page.body>
|
||||
|
||||
{{#if @model}}
|
||||
|
||||
<Rose::Table as |table|>
|
||||
<table.header as |header|>
|
||||
<header.row as |row|>
|
||||
<row.cell>{{t 'form.label.name'}}</row.cell>
|
||||
<row.cell>{{t 'form.label.description'}}</row.cell>
|
||||
</header.row>
|
||||
</table.header>
|
||||
<table.body as |body|>
|
||||
{{#each @model as |user|}}
|
||||
<body.row as |row|>
|
||||
<row.cell>
|
||||
<LinkTo
|
||||
@route="orgs.org.users.user"
|
||||
@model={{user}}
|
||||
>
|
||||
{{user.name}}
|
||||
</LinkTo>
|
||||
</row.cell>
|
||||
<row.cell>{{user.description}}</row.cell>
|
||||
</body.row>
|
||||
{{/each}}
|
||||
</table.body>
|
||||
</Rose::Table>
|
||||
|
||||
{{else}}
|
||||
|
||||
<Rose::Layout::Centered>
|
||||
<Rose::Message @title={{t 'titles.users-welcome'}} as |message|>
|
||||
<message.description>
|
||||
{{t 'descriptions.users-welcome'}}
|
||||
</message.description>
|
||||
<message.link @route="orgs.org.users.new">
|
||||
<Rose::Icon @name="plus-circle-outline" />
|
||||
{{t 'titles.new'}}
|
||||
</message.link>
|
||||
</Rose::Message>
|
||||
</Rose::Layout::Centered>
|
||||
|
||||
{{/if}}
|
||||
|
||||
</page.body>
|
||||
|
||||
</Rose::Layout::Page>
|
||||
@@ -0,0 +1,17 @@
|
||||
<Rose::Layout::Page as |page|>
|
||||
<page.breadcrumbs>
|
||||
<BreadCrumbs />
|
||||
</page.breadcrumbs>
|
||||
|
||||
<page.header>
|
||||
<h2>{{t "titles.new"}}</h2>
|
||||
</page.header>
|
||||
|
||||
<page.body>
|
||||
<Form::User
|
||||
@model={{@model}}
|
||||
@submit={{route-action "save" @model}}
|
||||
@cancel={{route-action "cancel" @model}}
|
||||
/>
|
||||
</page.body>
|
||||
</Rose::Layout::Page>
|
||||
@@ -0,0 +1,3 @@
|
||||
{{title @model.name}}
|
||||
|
||||
{{outlet}}
|
||||
@@ -0,0 +1,27 @@
|
||||
<Rose::Layout::Page as |page|>
|
||||
|
||||
<page.breadcrumbs>
|
||||
<BreadCrumbs />
|
||||
</page.breadcrumbs>
|
||||
|
||||
<page.header>
|
||||
<h2>{{t "resources.user"}}</h2>
|
||||
</page.header>
|
||||
|
||||
<page.body>
|
||||
<Form::User
|
||||
@model={{@model}}
|
||||
@submit={{route-action "save" @model}}
|
||||
@cancel={{route-action "cancel" @model}}
|
||||
/>
|
||||
<Rose::Separator />
|
||||
<Rose::Button
|
||||
@style="warning"
|
||||
@disabled={{@model.canSave}}
|
||||
{{on "click" (route-action "delete" @model)}}
|
||||
>
|
||||
{{t 'actions.delete'}}
|
||||
</Rose::Button>
|
||||
</page.body>
|
||||
|
||||
</Rose::Layout::Page>
|
||||
@@ -40,7 +40,14 @@ export default function() {
|
||||
this.patch('/orgs/:org_id/auth-methods/:id');
|
||||
this.del('/orgs/:org_id/auth-methods/:id');
|
||||
|
||||
// role
|
||||
// IAM : Users
|
||||
this.get('/orgs/:org_id/users');
|
||||
this.post('/orgs/:org_id/users');
|
||||
this.get('/orgs/:org_id/users/:id');
|
||||
this.patch('/orgs/:org_id/users/:id');
|
||||
this.del('/orgs/:org_id/users/:id');
|
||||
|
||||
// IAM: Roles
|
||||
this.get('/orgs/:org_id/roles');
|
||||
this.post('/orgs/:org_id/roles');
|
||||
this.get('/orgs/:org_id/roles/:id');
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import factory from '../generated/factories/user';
|
||||
|
||||
export default factory.extend();
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Factory } from 'ember-cli-mirage';
|
||||
import { random, date } from 'faker';
|
||||
|
||||
/**
|
||||
* GeneratedUserModelFactory
|
||||
* User contains all fields related to a User resource
|
||||
*/
|
||||
export default Factory.extend({
|
||||
|
||||
name: () => random.words(),
|
||||
description: () => random.words(),
|
||||
created_time: () => date.recent(),
|
||||
updated_time: () => date.recent(),
|
||||
disabled: () => random.boolean(),
|
||||
|
||||
});
|
||||
@@ -12,8 +12,10 @@ export default function(server) {
|
||||
// same items for request at all scopes.
|
||||
server.createList('auth-method', 3);
|
||||
|
||||
// IAM
|
||||
// Roles
|
||||
// User
|
||||
server.createList('user', 5);
|
||||
|
||||
// Role
|
||||
server.createList('role', 5);
|
||||
// Groups
|
||||
server.createList('group', 5);
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
modelName: 'user'
|
||||
});
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -5,6 +5,8 @@ actions:
|
||||
save: Save
|
||||
help: Need help?
|
||||
resources:
|
||||
user: User
|
||||
users: Users
|
||||
role: Role
|
||||
roles: Roles
|
||||
group: Group
|
||||
@@ -22,6 +24,7 @@ titles:
|
||||
empty-set: No Items Yet
|
||||
projects-welcome: Welcome to Projects
|
||||
host-catalogs-welcome: Welcome to Host Catalogs
|
||||
users-welcome: Welcome to Users
|
||||
roles-welcome: Welcome to Roles
|
||||
groups-welcome: Welcome to Groups
|
||||
descriptions:
|
||||
@@ -29,6 +32,7 @@ descriptions:
|
||||
empty-set: There are no items to display yet. You may be able to add items or try back later.
|
||||
projects-welcome: Projects allow you to create and manage host catalogs. To start, create a project.
|
||||
host-catalogs-welcome: Host catalogs allow you to configure to collect and create hosts and host sets. To start, create a host catalog.
|
||||
users-welcome: Users are authorized to access Watchtower.
|
||||
roles-welcome: Roles are collections of capabilities that can be granted to user and/or groups.
|
||||
groups-welcome: Groups are collections of users.
|
||||
states:
|
||||
@@ -56,6 +60,9 @@ errors:
|
||||
unknown-error: Please contact your administrator or try again later.
|
||||
notify:
|
||||
save-success: Save succeeded.
|
||||
user:
|
||||
create-success: User created succesfully.
|
||||
delete-success: Deleted user successfully.
|
||||
role:
|
||||
create-success: Role created succesfully.
|
||||
delete-success: Deleted role successfully.
|
||||
|
||||
Reference in new issue
Block a user