Merge remote-tracking branch 'origin/develop' into nested-resource-skip-scope-id
This commit is contained in:
3 files changed
+287
-34
No files matched your search
@@ -1,7 +1,8 @@
|
||||
import { Model, belongsTo } from 'ember-cli-mirage';
|
||||
import { Model, belongsTo, hasMany } from 'ember-cli-mirage';
|
||||
|
||||
export default Model.extend({
|
||||
|
||||
scope: belongsTo()
|
||||
scope: belongsTo(),
|
||||
hostSets: hasMany()
|
||||
|
||||
});
|
||||
@@ -2,56 +2,55 @@
|
||||
height="30"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 310 67">
|
||||
<defs><style>.cls-1{fill:#fff;}.cls-2{fill:#f04e54;}</style></defs>
|
||||
|
||||
<g id="LOGOS">
|
||||
<path
|
||||
class="cls-1"
|
||||
fill="#ffffff"
|
||||
d="M104.58,32.17c3.08-1.33,4.48-3.21,4.48-6.54V21.45c0-5.44-3.09-8.59-10.72-8.59H82.5v40.3H99.44c7.32,0,11-3.57,11-9.26V39.61C110.45,35.67,108.27,33,104.58,32.17Zm-14.46-13h7.32c2.78,0,4,1,4,3.27V26c0,2.36-1.08,3.76-4.05,3.76H90.12Zm12.71,23.78c0,3-1.46,3.94-4.91,3.94h-7.8v-11h8.47c3,0,4.24,1.33,4.24,4Z">
|
||||
</path>
|
||||
|
||||
<path
|
||||
class="cls-1"
|
||||
fill="#ffffff"
|
||||
d="M126.48,23.09c-10.1,0-12.82,5.56-12.82,11.62v7.44c0,6.05,2.72,11.61,12.82,11.61s12.83-5.56,12.83-11.61V34.71C139.31,28.65,136.58,23.09,126.48,23.09Zm5.45,19.3c0,3.33-1.51,5.08-5.45,5.08S121,45.72,121,42.39V34.47c0-3.34,1.51-5.09,5.44-5.09s5.45,1.75,5.45,5.09Z">
|
||||
</path>
|
||||
|
||||
<path
|
||||
class="cls-1"
|
||||
fill="#ffffff"
|
||||
d="M161.46,23.69V44.15c-2.67,1.39-5.88,2.48-7.69,2.48s-2.36-.79-2.36-2.37V23.69H144V45.05c0,5.27,1.75,8.71,6.65,8.71a29.59,29.59,0,0,0,11.8-3.08l.73,2.48h5.63V23.69Z">
|
||||
</path>
|
||||
|
||||
<path
|
||||
class="cls-1"
|
||||
fill="#ffffff"
|
||||
d="M193.34,23.09a29.59,29.59,0,0,0-11.8,3.08l-.72-2.48h-5.63V53.16h7.38V32.71c2.66-1.39,5.87-2.48,7.68-2.48s2.36.79,2.36,2.36V53.16H200V31.8C200,26.54,198.24,23.09,193.34,23.09Z">
|
||||
</path>
|
||||
|
||||
<path
|
||||
class="cls-1"
|
||||
fill="#ffffff"
|
||||
d="M222.44,11.66V23.94a41,41,0,0,0-7.87-.85c-6.83,0-9.73,3.87-9.73,10.41v10c0,6.72,3.14,10.22,9.07,10.22a15.48,15.48,0,0,0,9.32-3.08l.72,2.48h5.87V10.63Zm0,33.15a10.43,10.43,0,0,1-6.59,2.66c-2.73,0-3.63-1.33-3.63-3.75V33.32c0-2.67,1-3.94,3.69-3.94a33,33,0,0,1,6.53.79Z">
|
||||
</path>
|
||||
|
||||
<path
|
||||
class="cls-1"
|
||||
fill="#ffffff"
|
||||
d="M245.74,23.09a38.76,38.76,0,0,0-10.11,1.39l.91,5.63a40.74,40.74,0,0,1,8.17-.91c4.71,0,5.62,1.15,5.62,4.42V36.7h-7.07c-6,0-8.6,2.3-8.6,8.29,0,5.09,2.3,8.77,7.69,8.77a16.06,16.06,0,0,0,8.77-2.6l.54,2h6.06V33.74C257.72,26.35,255,23.09,245.74,23.09Zm4.59,23.29a11.57,11.57,0,0,1-5.56,1.51c-2.3,0-3-.9-3-3,0-2.24.67-2.9,3.09-2.9h5.44Z">
|
||||
</path>
|
||||
|
||||
<path
|
||||
class="cls-1"
|
||||
fill="#ffffff"
|
||||
d="M277.92,23.09A33,33,0,0,0,270.18,27l-.48-3.27h-6.24V53.16h7.39v-19a56,56,0,0,1,7.8-4.29Z">
|
||||
</path>
|
||||
|
||||
<path
|
||||
class="cls-1"
|
||||
fill="#ffffff"
|
||||
d="M300.61,23.69l-6.77,22.39-6.72-22.39h-7.56l9.32,29.47h2.59l-3.68,11.92h7l3.93-11.92,9.44-29.47Z">
|
||||
</path>
|
||||
|
||||
<polygon
|
||||
class="cls-2"
|
||||
fill="#f04e54"
|
||||
points="9.89 64.1 9.89 59.28 19.9 59.28 19.9 56.3 15.05 56.3 15.05 51.45 37.97 51.45 27.32 33.01 37.97 14.57 14.47 14.57 14.47 40.15 1.82 40.15 1.82 1.92 45.34 1.92 52.61 14.5 41.92 33.01 52.83 51.9 45.78 64.1 9.89 64.1">
|
||||
</polygon>
|
||||
|
||||
<rect
|
||||
class="cls-2"
|
||||
fill="#f04e54"
|
||||
x="6.98"
|
||||
y="51.45"
|
||||
width="4.85"
|
||||
@@ -59,7 +58,7 @@
|
||||
</rect>
|
||||
|
||||
<rect
|
||||
class="cls-2"
|
||||
fill="#f04e54"
|
||||
x="1.82"
|
||||
y="59.25"
|
||||
width="4.85"
|
||||
|
||||
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
@@ -1,77 +1,330 @@
|
||||
import { module, test } from 'qunit';
|
||||
//import { visit, currentURL } from '@ember/test-helpers';
|
||||
import { visit, currentURL, click, find, findAll, fillIn } 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,
|
||||
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';
|
||||
} from 'ember-simple-auth/test-support';
|
||||
|
||||
module('Acceptance | targets', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
target: null,
|
||||
hostSets: null,
|
||||
};
|
||||
const urls = {
|
||||
orgScope: null,
|
||||
projects: null,
|
||||
project: null,
|
||||
targets: null,
|
||||
newTarget: null,
|
||||
target: null,
|
||||
targetHostSets: null,
|
||||
targetAddHostSets: null,
|
||||
};
|
||||
|
||||
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
|
||||
}, 'withChildren');
|
||||
instances.target = this.server.create('target', {
|
||||
scope: instances.scopes.project,
|
||||
hostSets: instances.hostCatalog.hostSets
|
||||
});
|
||||
|
||||
// Generate route URLs for resources
|
||||
urls.orgScope = `/scopes/${instances.scopes.org.id}`;
|
||||
urls.projects = `${urls.orgScope}/projects`;
|
||||
urls.project = `${urls.projects}/${instances.scopes.project.id}`;
|
||||
urls.targets = `${urls.project}/targets`;
|
||||
urls.newTarget = `${urls.targets}/new`;
|
||||
urls.target = `${urls.targets}/${instances.target.id}`;
|
||||
urls.targetHostSets = `${urls.target}/host-sets`;
|
||||
urls.targetAddHostSets = `${urls.target}/add-host-sets`;
|
||||
});
|
||||
|
||||
hooks.afterEach(async function() {
|
||||
const notification = find('.rose-notification');
|
||||
if(notification) {
|
||||
await click('.rose-notification-dismiss');
|
||||
}
|
||||
});
|
||||
|
||||
test('visiting targets', async function (assert) {
|
||||
assert.expect(0);
|
||||
assert.expect(1);
|
||||
await visit(urls.targets);
|
||||
await a11yAudit();
|
||||
assert.equal(currentURL(), urls.targets);
|
||||
});
|
||||
|
||||
test('can navigate to a target form', async function (assert) {
|
||||
assert.expect(0);
|
||||
assert.expect(1);
|
||||
await visit(urls.targets);
|
||||
await click('main tbody .rose-table-header-cell:nth-child(1) a');
|
||||
await a11yAudit();
|
||||
assert.equal(currentURL(), urls.target);
|
||||
});
|
||||
|
||||
test('can update a target and save changes', async function (assert) {
|
||||
assert.expect(0);
|
||||
assert.expect(2);
|
||||
await visit(urls.target);
|
||||
await fillIn('[name="name"]', 'update name');
|
||||
await fillIn('[name="default_port"]', '1234');
|
||||
await click('form [type="submit"]:not(:disabled)');
|
||||
assert.equal(this.server.db.targets[0].name, 'update name');
|
||||
assert.equal(this.server.db.targets[0].attributes.default_port, '1234');
|
||||
});
|
||||
|
||||
test('can update a target and cancel changes', async function (assert) {
|
||||
assert.expect(0);
|
||||
assert.expect(2);
|
||||
await visit(urls.target);
|
||||
await fillIn('[name="name"]', 'update name');
|
||||
await fillIn('[name="default_port"]', '1234');
|
||||
await click('form button:not([type="submit"])');
|
||||
assert.notEqual(this.server.db.targets[0].name, 'update name');
|
||||
assert.notEqual(this.server.db.targets[0].port, '1234');
|
||||
});
|
||||
|
||||
test('can create new target', async function (assert) {
|
||||
assert.expect(0);
|
||||
assert.expect(1);
|
||||
const targetsCount = this.server.db.targets.length;
|
||||
await visit(urls.newTarget);
|
||||
await fillIn('[name="name"]', 'Target name');
|
||||
await fillIn('[name="description"]', 'description');
|
||||
await fillIn('[name="default_port"]', '1234');
|
||||
await click('form [type="submit"]:not(:disabled)');
|
||||
assert.equal(this.server.db.targets.length, targetsCount + 1);
|
||||
});
|
||||
|
||||
test('can cancel new target creation', async function (assert) {
|
||||
assert.expect(0);
|
||||
assert.expect(2);
|
||||
const targetsCount = this.server.db.targets.length;
|
||||
await visit(urls.newTarget);
|
||||
await fillIn('[name="name"]', 'Target Name');
|
||||
await click('form button:not([type="submit"])');
|
||||
assert.equal(this.server.db.targets.length, targetsCount);
|
||||
assert.equal(currentURL(), urls.targets);
|
||||
});
|
||||
|
||||
test('can delete a target', async function(assert) {
|
||||
assert.expect(1);
|
||||
const targetsCount = this.server.db.targets.length;
|
||||
await visit(urls.target);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
assert.equal(this.server.db.targets.length, targetsCount - 1);
|
||||
});
|
||||
|
||||
test('saving a new target with invalid fields displays error messages', async function (assert) {
|
||||
assert.expect(0);
|
||||
assert.expect(2);
|
||||
this.server.post('/targets', () => {
|
||||
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.newTarget);
|
||||
await fillIn('[name="name"]', 'new target');
|
||||
await click('form [type="submit"]');
|
||||
await a11yAudit();
|
||||
assert.ok(find('[role="alert"]'));
|
||||
assert.ok(find('.rose-form-error-message'));
|
||||
});
|
||||
|
||||
test('errors are displayed when save on target fails', async function (assert) {
|
||||
assert.expect(0);
|
||||
assert.expect(1);
|
||||
this.server.patch('/targets/:id', () => {
|
||||
return new Response(
|
||||
490,
|
||||
{},
|
||||
{
|
||||
status: 490,
|
||||
code: 'error',
|
||||
message: 'Oops.',
|
||||
}
|
||||
);
|
||||
});
|
||||
await visit(urls.target);
|
||||
await fillIn('[name="name"]', 'save target');
|
||||
await click('form [type="submit"]');
|
||||
await a11yAudit();
|
||||
assert.ok(find('[role="alert"]'));
|
||||
});
|
||||
|
||||
test('errors are displayed when delete on a target fails', async function (assert) {
|
||||
assert.expect(0);
|
||||
assert.expect(1);
|
||||
this.server.del('/targets/:id', () => {
|
||||
return new Response(
|
||||
490,
|
||||
{},
|
||||
{
|
||||
status: 490,
|
||||
code: 'error',
|
||||
message: 'Oops.',
|
||||
}
|
||||
);
|
||||
});
|
||||
await visit(urls.target);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
await a11yAudit();
|
||||
assert.ok(find('[role="alert"]'));
|
||||
});
|
||||
|
||||
test('saving an existing target with invalid fields displays error messages', async function (assert) {
|
||||
assert.expect(0);
|
||||
assert.expect(2);
|
||||
this.server.patch('/targets/: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.target);
|
||||
await fillIn('[name="name"]', 'existing target');
|
||||
await click('form [type="submit"]');
|
||||
await a11yAudit();
|
||||
assert.ok(find('[role="alert"]'));
|
||||
assert.ok(find('.rose-form-error-message'));
|
||||
});
|
||||
|
||||
test('viewing target host sets', async function (assert) {
|
||||
assert.expect(0);
|
||||
test('visiting target host sets', async function (assert) {
|
||||
assert.expect(3);
|
||||
const targetHostSetCount = instances.target.hostSets.length;
|
||||
await visit(urls.targetHostSets);
|
||||
await a11yAudit();
|
||||
assert.equal(currentURL(), urls.targetHostSets);
|
||||
assert.ok(targetHostSetCount);
|
||||
assert.equal(findAll('tbody tr').length, targetHostSetCount);
|
||||
});
|
||||
|
||||
test('can delete a host sets', async function (assert) {
|
||||
assert.expect(0);
|
||||
assert.expect(2);
|
||||
const targetHostSetCount = instances.target.hostSets.length;
|
||||
await visit(urls.targetHostSets);
|
||||
assert.equal(findAll('tbody tr').length, targetHostSetCount);
|
||||
await click('tbody tr .rose-dropdown-button-danger');
|
||||
assert.equal(findAll('tbody tr').length, targetHostSetCount - 1);
|
||||
});
|
||||
|
||||
test('shows error message on host set remove', async function (assert) {
|
||||
assert.expect(2);
|
||||
this.server.post('/targets/:idMethod', () => {
|
||||
return new Response(
|
||||
400,
|
||||
{},
|
||||
{
|
||||
status: 400,
|
||||
code: 'invalid_argument',
|
||||
message: 'The request was invalid.',
|
||||
details: {},
|
||||
}
|
||||
);
|
||||
});
|
||||
const targetHostSetCount = instances.target.hostSets.length;
|
||||
await visit(urls.targetHostSets);
|
||||
assert.equal(findAll('tbody tr').length, targetHostSetCount);
|
||||
await click('tbody tr .rose-dropdown-button-danger');
|
||||
assert.ok(find('[role="alert"]'));
|
||||
});
|
||||
|
||||
test('select and save host sets to add', async function (assert) {
|
||||
assert.expect(0);
|
||||
assert.expect(3);
|
||||
instances.target.update({ hostSetIds: [] });
|
||||
await visit(urls.targetHostSets);
|
||||
assert.equal(findAll('tbody tr').length, 0);
|
||||
await click('.rose-layout-page-actions a')
|
||||
assert.equal(currentURL(), urls.targetAddHostSets);
|
||||
await click('tbody label');
|
||||
await click('form [type="submit"]');
|
||||
await visit(urls.targetHostSets);
|
||||
assert.equal(findAll('tbody tr').length, 1);
|
||||
});
|
||||
|
||||
test('select and cancel host sets to add', async function (assert) {
|
||||
assert.expect(0);
|
||||
assert.expect(4);
|
||||
const targetHostSetCount = instances.target.hostSets.length;
|
||||
await visit(urls.targetHostSets);
|
||||
assert.equal(findAll('tbody tr').length, targetHostSetCount);
|
||||
// first, remove a target host set (otherwise none would be available to add)
|
||||
await click('tbody tr .rose-dropdown-button-danger');
|
||||
assert.equal(findAll('tbody tr').length, targetHostSetCount - 1);
|
||||
await click('.rose-layout-page-actions a')
|
||||
assert.equal(currentURL(), urls.targetAddHostSets);
|
||||
await click('tbody label');
|
||||
await click('form [type="button"]');
|
||||
await visit(urls.targetHostSets);
|
||||
assert.equal(findAll('tbody tr').length, targetHostSetCount - 1);
|
||||
});
|
||||
|
||||
test('shows error message on host set add', async function (assert) {
|
||||
assert.expect(4);
|
||||
this.server.post('/targets/:idMethod', () => {
|
||||
return new Response(
|
||||
400,
|
||||
{},
|
||||
{
|
||||
status: 400,
|
||||
code: 'invalid_argument',
|
||||
message: 'The request was invalid.',
|
||||
details: {},
|
||||
}
|
||||
);
|
||||
});
|
||||
instances.target.update({ hostSetIds: [] });
|
||||
await visit(urls.targetAddHostSets);
|
||||
assert.equal(instances.target.hostSets.length, 0);
|
||||
assert.equal(currentURL(), urls.targetAddHostSets);
|
||||
await click('tbody label');
|
||||
await click('form [type="submit"]');
|
||||
assert.equal(currentURL(), urls.targetAddHostSets);
|
||||
assert.equal(instances.target.hostSets.length, 0);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user