test: 💍 add tests
This commit is contained in:
1 parent
3d900f5a2b
commit
dbc06a4e0a
4 files changed
+245
-101
No files matched your search
@@ -2,7 +2,6 @@ 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';
|
||||
import {
|
||||
authenticateSession,
|
||||
@@ -44,20 +43,6 @@ module('Acceptance | groups', function (hooks) {
|
||||
urls.newGroup = `${urls.groups}/new`;
|
||||
});
|
||||
|
||||
test('visiting groups', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(urls.groups);
|
||||
await a11yAudit();
|
||||
assert.equal(currentURL(), urls.groups);
|
||||
});
|
||||
|
||||
test('visiting a group', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(urls.newGroup);
|
||||
await a11yAudit();
|
||||
assert.equal(currentURL(), urls.newGroup);
|
||||
});
|
||||
|
||||
test('can create new group', async function (assert) {
|
||||
assert.expect(1);
|
||||
const groupsCount = this.server.db.groups.length;
|
||||
@@ -112,90 +97,4 @@ module('Acceptance | groups', function (hooks) {
|
||||
'Displays field-level errors.'
|
||||
);
|
||||
});
|
||||
|
||||
test('can save changes to an existing group', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.group);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'Updated admin group');
|
||||
await click('.rose-form-actions [type="submit"]');
|
||||
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(urls.group);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'Updated admin group');
|
||||
await click('.rose-form-actions [type="button"]');
|
||||
assert.notEqual(find('[name="name"]').value, 'Updated admin group');
|
||||
});
|
||||
|
||||
test('can delete a group', async function (assert) {
|
||||
assert.expect(1);
|
||||
const groupsCount = this.server.db.groups.length;
|
||||
await visit(urls.group);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
assert.equal(this.server.db.groups.length, groupsCount - 1);
|
||||
});
|
||||
|
||||
test('saving an existing group with invalid fields displays error messages', async function (assert) {
|
||||
assert.expect(2);
|
||||
this.server.patch('/groups/: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.group);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
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 delete project fails', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.del('/groups/:id', () => {
|
||||
return new Response(
|
||||
490,
|
||||
{},
|
||||
{
|
||||
status: 490,
|
||||
code: 'error',
|
||||
message: 'Oops.',
|
||||
}
|
||||
);
|
||||
});
|
||||
await visit(urls.group);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
assert.ok(
|
||||
find('[role="alert"]').textContent.trim(),
|
||||
'Oops.',
|
||||
'Displays primary error message.'
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user