test: 💍 refactor targets test selectors (#2824)
* test: 💍 refactor targets test selectors ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16427
This commit is contained in:
1 parent
28ddec6898
commit
04b51da60f
9 files changed
+287
-231
No files matched your search
@@ -27,7 +27,7 @@
|
||||
{{#if @model.errors.name}}
|
||||
<F.Error as |E|>
|
||||
{{#each @model.errors.name as |error|}}
|
||||
<E.Message>{{error.message}}</E.Message>
|
||||
<E.Message data-test-error-message-name>{{error.message}}</E.Message>
|
||||
{{/each}}
|
||||
</F.Error>
|
||||
{{/if}}
|
||||
@@ -133,7 +133,9 @@
|
||||
{{#if @model.errors.default_port}}
|
||||
<F.Error as |E|>
|
||||
{{#each @model.errors.default_port as |error|}}
|
||||
<E.Message>{{error.message}}</E.Message>
|
||||
<E.Message
|
||||
data-test-error-message-default-port
|
||||
>{{error.message}}</E.Message>
|
||||
{{/each}}
|
||||
</F.Error>
|
||||
{{/if}}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
<Hds::Button
|
||||
@route='scopes.scope.targets.new'
|
||||
@text={{t 'resources.target.titles.new'}}
|
||||
data-test-new-target-button
|
||||
/>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
{{#if this.showFlyoutBtn}}
|
||||
<Hds::Button
|
||||
data-test-view-more
|
||||
data-test-aliases-view-more
|
||||
@text={{t 'resources.target.actions.view-more-aliases'}}
|
||||
@color='secondary'
|
||||
{{on 'click' this.toggleFlyout}}
|
||||
@@ -63,7 +63,7 @@
|
||||
{{/if}}
|
||||
{{#if this.showFlyOutComponent}}
|
||||
<Hds::Flyout
|
||||
data-test-flyout
|
||||
data-test-aliases-flyout
|
||||
@onClose={{this.toggleFlyout}}
|
||||
as |M|
|
||||
>
|
||||
|
||||
@@ -7,7 +7,6 @@ import { module, test } from 'qunit';
|
||||
import {
|
||||
visit,
|
||||
currentURL,
|
||||
find,
|
||||
click,
|
||||
fillIn,
|
||||
getContext,
|
||||
@@ -19,6 +18,7 @@ import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
import { TYPE_TARGET_TCP, TYPE_TARGET_SSH } from 'api/models/target';
|
||||
import { setupIndexedDb } from 'api/test-support/helpers/indexed-db';
|
||||
import * as commonSelectors from 'admin/tests/helpers/selectors';
|
||||
import * as selectors from './selectors';
|
||||
|
||||
module('Acceptance | targets | create', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
@@ -30,8 +30,6 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
let getSSHTargetCount;
|
||||
let featuresService;
|
||||
|
||||
const SAVE_BTN_SELECTOR = '[type="submit"]';
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
@@ -41,7 +39,6 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
target: null,
|
||||
};
|
||||
const urls = {
|
||||
orgScope: null,
|
||||
projectScope: null,
|
||||
targets: null,
|
||||
target: null,
|
||||
@@ -66,11 +63,9 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
// Generate route URLs for resources
|
||||
urls.orgScope = `/scopes/${instances.scopes.org.id}/scopes`;
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.targets = `${urls.projectScope}/targets`;
|
||||
urls.target = `${urls.targets}/${instances.target.id}`;
|
||||
urls.unknownTarget = `${urls.targets}/foo`;
|
||||
urls.newTarget = `${urls.targets}/new`;
|
||||
urls.newTCPTarget = `${urls.targets}/new?type=tcp`;
|
||||
urls.newSSHTarget = `${urls.targets}/new?type=ssh`;
|
||||
@@ -85,8 +80,11 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
|
||||
test('defaults to type `ssh` when no query param provided', async function (assert) {
|
||||
featuresService.enable('ssh-target');
|
||||
await visit(urls.newTarget);
|
||||
assert.strictEqual(find('[name="Type"]:checked').value, TYPE_TARGET_SSH);
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(commonSelectors.HREF(urls.newTarget));
|
||||
|
||||
assert.dom(selectors.FIELD_TYPE_CHECKED).hasValue(TYPE_TARGET_SSH);
|
||||
});
|
||||
|
||||
test('can create a type `ssh` target', async function (assert) {
|
||||
@@ -96,16 +94,16 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
const sshTargetCount = getSSHTargetCount();
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(`[href="${urls.newTarget}"]`);
|
||||
await click('[value="ssh"]');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click(SAVE_BTN_SELECTOR);
|
||||
await click(commonSelectors.HREF(urls.newTarget));
|
||||
await click(selectors.FIELD_TYPE_VALUE('ssh'));
|
||||
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
|
||||
await click(commonSelectors.SAVE_BTN);
|
||||
|
||||
assert.strictEqual(getSSHTargetCount(), sshTargetCount + 1);
|
||||
assert.strictEqual(getTargetCount(), targetCount + 1);
|
||||
assert.strictEqual(
|
||||
this.server.schema.targets.all().models[getTargetCount() - 1].name,
|
||||
'random string',
|
||||
commonSelectors.FIELD_NAME_VALUE,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -116,43 +114,49 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
const tcpTargetCount = getTCPTargetCount();
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(`[href="${urls.newTarget}"]`);
|
||||
await click('[value="tcp"]');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click(SAVE_BTN_SELECTOR);
|
||||
await click(commonSelectors.HREF(urls.newTarget));
|
||||
await click(selectors.FIELD_TYPE_VALUE('tcp'));
|
||||
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
|
||||
await click(commonSelectors.SAVE_BTN);
|
||||
|
||||
assert.strictEqual(getTargetCount(), targetCount + 1);
|
||||
assert.strictEqual(getTCPTargetCount(), tcpTargetCount + 1);
|
||||
assert.strictEqual(
|
||||
this.server.schema.targets.all().models[getTargetCount() - 1].name,
|
||||
'random string',
|
||||
commonSelectors.FIELD_NAME_VALUE,
|
||||
);
|
||||
});
|
||||
|
||||
test('default port is not marked required for SSH targets', async function (assert) {
|
||||
featuresService.enable('ssh-target');
|
||||
await visit(urls.newTarget);
|
||||
assert.dom('[data-test-default-port-label]').includesText('Optional');
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(commonSelectors.HREF(urls.newTarget));
|
||||
|
||||
assert.dom(selectors.FIELD_DEFAULT_PORT_LABEL).includesText('Optional');
|
||||
});
|
||||
|
||||
test('default port is marked required for TCP targets', async function (assert) {
|
||||
featuresService.enable('ssh-target');
|
||||
await visit(urls.newTarget);
|
||||
await click('[value="tcp"]');
|
||||
assert.dom('[data-test-default-port-label]').includesText('Required');
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(commonSelectors.HREF(urls.newTarget));
|
||||
await click(selectors.FIELD_TYPE_VALUE('tcp'));
|
||||
|
||||
assert.dom(selectors.FIELD_DEFAULT_PORT_LABEL).includesText('Required');
|
||||
});
|
||||
|
||||
test('can navigate to new targets route with proper authorization', async function (assert) {
|
||||
await visit(urls.projectScope);
|
||||
|
||||
await click(`[href="${urls.targets}"]`);
|
||||
await click(commonSelectors.HREF(urls.targets));
|
||||
|
||||
assert.true(
|
||||
instances.scopes.project.authorized_collection_actions.targets.includes(
|
||||
'create',
|
||||
),
|
||||
);
|
||||
assert.dom(`[href="${urls.newTarget}"]`).exists();
|
||||
assert.dom(selectors.NEW_TARGET_BTN).isVisible();
|
||||
});
|
||||
|
||||
test('cannot navigate to new targets route without proper authorization', async function (assert) {
|
||||
@@ -162,28 +166,29 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
);
|
||||
await visit(urls.projectScope);
|
||||
|
||||
await click(`[href="${urls.targets}"]`);
|
||||
await click(commonSelectors.HREF(urls.targets));
|
||||
|
||||
assert.false(
|
||||
instances.scopes.project.authorized_collection_actions.targets.includes(
|
||||
'create',
|
||||
),
|
||||
);
|
||||
assert.dom('.rose-layout-page-actions a').doesNotExist();
|
||||
assert.dom(selectors.NEW_TARGET_BTN).doesNotExist();
|
||||
});
|
||||
|
||||
test('cannot navigate to new SSH targets route when ssh feature is disabled', async function (assert) {
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(`[href="${urls.newTarget}"]`);
|
||||
await click(commonSelectors.HREF(urls.newTarget));
|
||||
|
||||
assert.false(featuresService.isEnabled('ssh-target'));
|
||||
assert.true(
|
||||
instances.scopes.project.authorized_collection_actions.targets.includes(
|
||||
'create',
|
||||
),
|
||||
);
|
||||
assert.dom('.info-field').exists({ count: 1 });
|
||||
assert.dom('.info-field .hds-form-helper-text').includesText('TCP');
|
||||
assert.dom(selectors.FIELD_INFO).isVisible({ count: 1 });
|
||||
assert.dom(selectors.FIELD_INFO_LABEL).includesText('TCP');
|
||||
});
|
||||
|
||||
test('can cancel create new TCP target', async function (assert) {
|
||||
@@ -191,9 +196,9 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
const tcpTargetCount = getTCPTargetCount();
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(`[href="${urls.newTarget}"]`);
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('.rose-form-actions [type="button"]');
|
||||
await click(commonSelectors.HREF(urls.newTarget));
|
||||
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
|
||||
await click(commonSelectors.CANCEL_BTN);
|
||||
|
||||
assert.strictEqual(currentURL(), urls.targets);
|
||||
assert.strictEqual(getTargetCount(), targetCount);
|
||||
@@ -203,30 +208,23 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
test('can add aliases during target creation', async function (assert) {
|
||||
const targetCount = getTargetCount();
|
||||
const tcpTargetCount = getTCPTargetCount();
|
||||
await visit(urls.targets);
|
||||
const name = 'target';
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(`[href="${urls.newTarget}"]`);
|
||||
await fillIn('[name="name"]', name);
|
||||
await click(commonSelectors.HREF(urls.newTarget));
|
||||
await fillIn(commonSelectors.FIELD_NAME, name);
|
||||
|
||||
assert.ok(
|
||||
assert.true(
|
||||
instances.scopes.global.authorized_collection_actions.aliases.includes(
|
||||
'create',
|
||||
),
|
||||
);
|
||||
|
||||
await fillIn(
|
||||
'[name="with_aliases"] tbody tr:nth-of-type(1) input',
|
||||
'alias 1',
|
||||
);
|
||||
await click('[name="with_aliases"] tbody tr:nth-of-type(1) button');
|
||||
|
||||
await fillIn(
|
||||
'[name="with_aliases"] tbody tr:nth-of-type(2) input',
|
||||
'alias 2',
|
||||
);
|
||||
await click('[name="with_aliases"] tbody tr:nth-of-type(2) button');
|
||||
await click(SAVE_BTN_SELECTOR);
|
||||
await fillIn(selectors.FIELD_ALIASES, 'alias 1');
|
||||
await click(selectors.FIELD_ALIASES_ADD_BTN);
|
||||
await fillIn(selectors.FIELD_ALIASES, 'alias 2');
|
||||
await click(selectors.FIELD_ALIASES_ADD_BTN);
|
||||
await click(commonSelectors.SAVE_BTN);
|
||||
|
||||
assert.strictEqual(getTargetCount(), targetCount + 1);
|
||||
const target = this.server.schema.targets.findBy({ name });
|
||||
@@ -239,14 +237,14 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
|
||||
test('can cancel create new SSH target', async function (assert) {
|
||||
featuresService.enable('ssh-target');
|
||||
|
||||
const targetCount = getTargetCount();
|
||||
const sshTargetCount = getSSHTargetCount();
|
||||
await visit(urls.targets);
|
||||
await click(`[href="${urls.newTarget}"]`);
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('[value="ssh"]');
|
||||
await click('.rose-form-actions [type="button"]');
|
||||
|
||||
await click(commonSelectors.HREF(urls.newTarget));
|
||||
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
|
||||
await click(selectors.FIELD_TYPE_VALUE('ssh'));
|
||||
await click(commonSelectors.CANCEL_BTN);
|
||||
|
||||
assert.strictEqual(currentURL(), urls.targets);
|
||||
assert.strictEqual(getTargetCount(), targetCount);
|
||||
@@ -268,19 +266,26 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
name: 'name',
|
||||
description: 'Name is required.',
|
||||
},
|
||||
{
|
||||
name: 'attributes.default_port',
|
||||
description: 'Default port is required.',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
await visit(urls.newTCPTarget);
|
||||
await click(SAVE_BTN_SELECTOR);
|
||||
|
||||
await click(commonSelectors.SAVE_BTN);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.ALERT_TOAST_BODY)
|
||||
.hasText('The request was invalid.');
|
||||
assert.dom('.hds-form-error__message').hasText('Name is required.');
|
||||
assert.dom(selectors.FIELD_NAME_ERROR).hasText('Name is required.');
|
||||
assert
|
||||
.dom(selectors.FIELD_DEFAULT_PORT_ERROR)
|
||||
.hasText('Default port is required.');
|
||||
});
|
||||
|
||||
test('saving a new SSH target with invalid fields displays error messages', async function (assert) {
|
||||
@@ -304,38 +309,39 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
);
|
||||
});
|
||||
await visit(urls.newSSHTarget);
|
||||
await click(SAVE_BTN_SELECTOR);
|
||||
|
||||
await click(commonSelectors.SAVE_BTN);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.ALERT_TOAST_BODY)
|
||||
.hasText('The request was invalid.');
|
||||
assert.dom('.hds-form-error__message').hasText('Name is required.');
|
||||
assert.dom(selectors.FIELD_NAME_ERROR).hasText('Name is required.');
|
||||
});
|
||||
|
||||
test('can save address', async function (assert) {
|
||||
featuresService.enable('target-network-address');
|
||||
|
||||
const targetCount = getTargetCount();
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(`[href="${urls.newTarget}"]`);
|
||||
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await fillIn('[name="address"]', '0.0.0.0');
|
||||
await click(SAVE_BTN_SELECTOR);
|
||||
await click(commonSelectors.HREF(urls.newTarget));
|
||||
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
|
||||
await fillIn(selectors.FIELD_ADDRESS, selectors.FIELD_ADDRESS_VALUE);
|
||||
await click(commonSelectors.SAVE_BTN);
|
||||
|
||||
assert.strictEqual(getTargetCount(), targetCount + 1);
|
||||
assert.strictEqual(
|
||||
this.server.schema.targets.all().models[getTargetCount() - 1].address,
|
||||
'0.0.0.0',
|
||||
selectors.FIELD_ADDRESS_VALUE,
|
||||
);
|
||||
});
|
||||
|
||||
test('address field does not exist when target network address feature is disabled', async function (assert) {
|
||||
await visit(urls.targets);
|
||||
await click(`[href="${urls.newTarget}"]`);
|
||||
|
||||
await click(commonSelectors.HREF(urls.newTarget));
|
||||
|
||||
assert.false(featuresService.isEnabled('target-network-address'));
|
||||
assert.dom('[name="address"]').doesNotExist();
|
||||
assert.dom(selectors.FIELD_ADDRESS).doesNotExist();
|
||||
});
|
||||
|
||||
test('users cannot directly navigate to new storage bucket route without proper authorization', async function (assert) {
|
||||
@@ -343,8 +349,7 @@ module('Acceptance | targets | create', function (hooks) {
|
||||
instances.scopes.project.authorized_collection_actions.targets.filter(
|
||||
(item) => item !== 'create',
|
||||
);
|
||||
|
||||
await visit(urls.newSSHTarget);
|
||||
await visit(urls.newTCPTarget);
|
||||
|
||||
assert.false(
|
||||
instances.scopes.project.authorized_collection_actions.targets.includes(
|
||||
|
||||
@@ -11,6 +11,7 @@ import { setupIndexedDb } from 'api/test-support/helpers/indexed-db';
|
||||
import { Response } from 'miragejs';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
import * as commonSelectors from 'admin/tests/helpers/selectors';
|
||||
import * as selectors from './selectors';
|
||||
|
||||
module('Acceptance | targets | delete', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
@@ -18,10 +19,6 @@ module('Acceptance | targets | delete', function (hooks) {
|
||||
setupIndexedDb(hooks);
|
||||
|
||||
let getTargetCount;
|
||||
const MANAGE_DROPDOWN_SELECTOR =
|
||||
'[data-test-manage-targets-dropdown] button:first-child';
|
||||
const DELETE_ACTION_SELECTOR =
|
||||
'[data-test-manage-targets-dropdown] ul li button';
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
@@ -68,9 +65,10 @@ module('Acceptance | targets | delete', function (hooks) {
|
||||
const targetCount = getTargetCount();
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(`[href="${urls.target}"]`);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
await click(commonSelectors.HREF(urls.target));
|
||||
await click(selectors.MANAGE_DROPDOWN);
|
||||
await click(selectors.MANAGE_DROPDOWN_DELETE);
|
||||
|
||||
assert.strictEqual(getTargetCount(), targetCount - 1);
|
||||
});
|
||||
|
||||
@@ -80,9 +78,9 @@ module('Acceptance | targets | delete', function (hooks) {
|
||||
const targetCount = getTargetCount();
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(`[href="${urls.target}"]`);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
await click(commonSelectors.HREF(urls.target));
|
||||
await click(selectors.MANAGE_DROPDOWN);
|
||||
await click(selectors.MANAGE_DROPDOWN_DELETE);
|
||||
await click(commonSelectors.MODAL_WARNING_CONFIRM_BTN);
|
||||
|
||||
assert
|
||||
@@ -98,9 +96,9 @@ module('Acceptance | targets | delete', function (hooks) {
|
||||
const targetCount = getTargetCount();
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(`[href="${urls.target}"]`);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
await click(commonSelectors.HREF(urls.target));
|
||||
await click(selectors.MANAGE_DROPDOWN);
|
||||
await click(selectors.MANAGE_DROPDOWN_DELETE);
|
||||
await click(commonSelectors.MODAL_WARNING_CANCEL_BTN);
|
||||
|
||||
assert.strictEqual(getTargetCount(), targetCount);
|
||||
@@ -112,11 +110,9 @@ module('Acceptance | targets | delete', function (hooks) {
|
||||
instances.target.authorized_actions =
|
||||
instances.target.authorized_actions.filter((item) => item !== 'delete');
|
||||
|
||||
await click(`[href="${urls.target}"]`);
|
||||
await click(commonSelectors.HREF(urls.target));
|
||||
|
||||
assert
|
||||
.dom('.rose-layout-page-actions .rose-dropdown-button-danger')
|
||||
.doesNotExist();
|
||||
assert.dom(selectors.MANAGE_DROPDOWN_DELETE).doesNotExist();
|
||||
});
|
||||
|
||||
test('deleting a target which errors displays error messages', async function (assert) {
|
||||
@@ -133,9 +129,9 @@ module('Acceptance | targets | delete', function (hooks) {
|
||||
);
|
||||
});
|
||||
|
||||
await click(`[href="${urls.target}"]`);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
await click(commonSelectors.HREF(urls.target));
|
||||
await click(selectors.MANAGE_DROPDOWN);
|
||||
await click(selectors.MANAGE_DROPDOWN_DELETE);
|
||||
|
||||
assert.dom(commonSelectors.ALERT_TOAST_BODY).hasText('Oops.');
|
||||
});
|
||||
|
||||
@@ -18,23 +18,13 @@ import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
import { TYPE_TARGET_TCP, TYPE_TARGET_SSH } from 'api/models/target';
|
||||
import { STATUS_SESSION_ACTIVE } from 'api/models/session';
|
||||
import * as commonSelectors from 'admin/tests/helpers/selectors';
|
||||
import * as selectors from './selectors';
|
||||
|
||||
module('Acceptance | targets | list', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
setupIndexedDb(hooks);
|
||||
|
||||
const SEARCH_INPUT_SELECTOR = '.search-filtering [type="search"]';
|
||||
const NO_RESULTS_MSG_SELECTOR = '[data-test-no-target-results]';
|
||||
const FILTER_DROPDOWN_SELECTOR = (name) =>
|
||||
`.search-filtering [name="${name}"] button`;
|
||||
const FILTER_APPLY_BUTTON_SELECTOR =
|
||||
'.search-filtering [data-test-dropdown-apply-button]';
|
||||
const ACTIVE_SESSIONS_SELECTOR = (id) =>
|
||||
`tbody [data-test-targets-table-row="${id}"] .hds-table__td:nth-child(3) a`;
|
||||
const SESSIONS_ID_SELECTOR = (id) =>
|
||||
`tbody [data-test-sessions-table-row="${id}"] .hds-table__td:first-child`;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
@@ -92,7 +82,7 @@ module('Acceptance | targets | list', function (hooks) {
|
||||
test('can navigate to targets with proper authorization', async function (assert) {
|
||||
await visit(urls.orgScope);
|
||||
|
||||
await click(`[href="${urls.projectScope}"]`);
|
||||
await click(commonSelectors.HREF(urls.projectScope));
|
||||
|
||||
assert.true(
|
||||
instances.scopes.project.authorized_collection_actions.targets.includes(
|
||||
@@ -104,14 +94,14 @@ module('Acceptance | targets | list', function (hooks) {
|
||||
'create',
|
||||
),
|
||||
);
|
||||
assert.dom(`[href="${urls.targets}"]`).exists();
|
||||
assert.dom(commonSelectors.HREF(urls.targets)).isVisible();
|
||||
});
|
||||
|
||||
test('user cannot navigate to index without either list or create actions', async function (assert) {
|
||||
instances.scopes.project.authorized_collection_actions.targets = [];
|
||||
await visit(urls.orgScope);
|
||||
|
||||
await click(`[href="${urls.projectScope}"]`);
|
||||
await click(commonSelectors.HREF(urls.projectScope));
|
||||
|
||||
assert.false(
|
||||
instances.scopes.project.authorized_collection_actions.targets.includes(
|
||||
@@ -135,7 +125,7 @@ module('Acceptance | targets | list', function (hooks) {
|
||||
);
|
||||
await visit(urls.orgScope);
|
||||
|
||||
await click(`[href="${urls.projectScope}"]`);
|
||||
await click(commonSelectors.HREF(urls.projectScope));
|
||||
|
||||
assert.true(
|
||||
instances.scopes.project.authorized_collection_actions.targets.includes(
|
||||
@@ -147,7 +137,7 @@ module('Acceptance | targets | list', function (hooks) {
|
||||
'list',
|
||||
),
|
||||
);
|
||||
assert.dom(`[href="${urls.targets}"]`).exists();
|
||||
assert.dom(commonSelectors.HREF(urls.targets)).isVisible();
|
||||
});
|
||||
|
||||
test('user can navigate to index with only list action', async function (assert) {
|
||||
@@ -157,7 +147,7 @@ module('Acceptance | targets | list', function (hooks) {
|
||||
);
|
||||
await visit(urls.orgScope);
|
||||
|
||||
await click(`[href="${urls.projectScope}"]`);
|
||||
await click(commonSelectors.HREF(urls.projectScope));
|
||||
|
||||
assert.false(
|
||||
instances.scopes.project.authorized_collection_actions.targets.includes(
|
||||
@@ -169,70 +159,75 @@ module('Acceptance | targets | list', function (hooks) {
|
||||
'list',
|
||||
),
|
||||
);
|
||||
assert.dom(`[href="${urls.targets}"]`).exists();
|
||||
assert.dom(commonSelectors.HREF(urls.targets)).isVisible();
|
||||
});
|
||||
|
||||
test('user can search for a specifc target by id', async function (assert) {
|
||||
test('user can search for a specific target by id', async function (assert) {
|
||||
await visit(urls.projectScope);
|
||||
|
||||
await click(`[href="${urls.targets}"]`);
|
||||
await click(commonSelectors.HREF(urls.targets));
|
||||
|
||||
assert.dom(`[href="${urls.tcpTarget}"]`).exists();
|
||||
assert.dom(`[href="${urls.sshTarget}"]`).exists();
|
||||
assert.dom(commonSelectors.HREF(urls.tcpTarget)).isVisible();
|
||||
assert.dom(commonSelectors.HREF(urls.sshTarget)).isVisible();
|
||||
|
||||
await fillIn(SEARCH_INPUT_SELECTOR, instances.sshTarget.id);
|
||||
await waitFor(`[href="${urls.tcpTarget}"]`, { count: 0 });
|
||||
await fillIn(commonSelectors.SEARCH_INPUT, instances.sshTarget.id);
|
||||
await waitFor(commonSelectors.HREF(urls.tcpTarget), { count: 0 });
|
||||
|
||||
assert.dom(`[href="${urls.sshTarget}"]`).exists();
|
||||
assert.dom(`[href="${urls.tcpTarget}"]`).doesNotExist();
|
||||
assert.dom(commonSelectors.HREF(urls.sshTarget)).isVisible();
|
||||
assert.dom(commonSelectors.HREF(urls.tcpTarget)).doesNotExist();
|
||||
});
|
||||
|
||||
test('user can search for targets and get no results', async function (assert) {
|
||||
await visit(urls.projectScope);
|
||||
|
||||
await click(`[href="${urls.targets}"]`);
|
||||
await click(commonSelectors.HREF(urls.targets));
|
||||
|
||||
assert.dom(`[href="${urls.tcpTarget}"]`).exists();
|
||||
assert.dom(`[href="${urls.sshTarget}"]`).exists();
|
||||
assert.dom(commonSelectors.HREF(urls.tcpTarget)).isVisible();
|
||||
assert.dom(commonSelectors.HREF(urls.sshTarget)).isVisible();
|
||||
|
||||
await fillIn(SEARCH_INPUT_SELECTOR, 'fake target that does not exist');
|
||||
await waitFor(NO_RESULTS_MSG_SELECTOR, { count: 1 });
|
||||
await fillIn(
|
||||
commonSelectors.SEARCH_INPUT,
|
||||
'fake target that does not exist',
|
||||
);
|
||||
await waitFor(selectors.NO_RESULTS_MSG, { count: 1 });
|
||||
|
||||
assert.dom(`[href="${urls.sshTarget}"]`).doesNotExist();
|
||||
assert.dom(`[href="${urls.tcpTarget}"]`).doesNotExist();
|
||||
assert.dom(NO_RESULTS_MSG_SELECTOR).includesText('No results found');
|
||||
assert.dom(commonSelectors.HREF(urls.sshTarget)).doesNotExist();
|
||||
assert.dom(commonSelectors.HREF(urls.tcpTarget)).doesNotExist();
|
||||
assert.dom(selectors.NO_RESULTS_MSG).includesText('No results found');
|
||||
});
|
||||
|
||||
test('user can filter for targets by type', async function (assert) {
|
||||
await visit(urls.projectScope);
|
||||
|
||||
await click(`[href="${urls.targets}"]`);
|
||||
await click(commonSelectors.HREF(urls.targets));
|
||||
|
||||
assert.dom(`[href="${urls.tcpTarget}"]`).exists();
|
||||
assert.dom(`[href="${urls.sshTarget}"]`).exists();
|
||||
assert.dom(commonSelectors.HREF(urls.tcpTarget)).isVisible();
|
||||
assert.dom(commonSelectors.HREF(urls.sshTarget)).isVisible();
|
||||
|
||||
await click(FILTER_DROPDOWN_SELECTOR('type'));
|
||||
await click(`input[value="tcp"]`);
|
||||
await click(FILTER_APPLY_BUTTON_SELECTOR);
|
||||
await click(commonSelectors.FILTER_DROPDOWN('type'));
|
||||
await click(commonSelectors.FILTER_DROPDOWN_ITEM('tcp'));
|
||||
await click(commonSelectors.FILTER_DROPDOWN_ITEM_APPLY_BTN('type'));
|
||||
|
||||
assert.dom(`[href="${urls.sshTarget}"]`).doesNotExist();
|
||||
assert.dom(`[href="${urls.tcpTarget}"]`).exists();
|
||||
assert.dom(commonSelectors.HREF(urls.sshTarget)).doesNotExist();
|
||||
assert.dom(commonSelectors.HREF(urls.tcpTarget)).isVisible();
|
||||
});
|
||||
|
||||
test('user can filter for targets by active sessions', async function (assert) {
|
||||
await visit(urls.projectScope);
|
||||
|
||||
await click(`[href="${urls.targets}"]`);
|
||||
await click(commonSelectors.HREF(urls.targets));
|
||||
|
||||
assert.dom(`[href="${urls.tcpTarget}"]`).exists();
|
||||
assert.dom(`[href="${urls.sshTarget}"]`).exists();
|
||||
assert.dom(commonSelectors.HREF(urls.tcpTarget)).isVisible();
|
||||
assert.dom(commonSelectors.HREF(urls.sshTarget)).isVisible();
|
||||
|
||||
await click(FILTER_DROPDOWN_SELECTOR('active-sessions'));
|
||||
await click(`input[value="yes"]`);
|
||||
await click(FILTER_APPLY_BUTTON_SELECTOR);
|
||||
await click(commonSelectors.FILTER_DROPDOWN('active-sessions'));
|
||||
await click(commonSelectors.FILTER_DROPDOWN_ITEM('yes'));
|
||||
await click(
|
||||
commonSelectors.FILTER_DROPDOWN_ITEM_APPLY_BTN('active-sessions'),
|
||||
);
|
||||
|
||||
assert.dom(`[href="${urls.sshTarget}"]`).exists();
|
||||
assert.dom(`[href="${urls.tcpTarget}"]`).doesNotExist();
|
||||
assert.dom(commonSelectors.HREF(urls.sshTarget)).isVisible();
|
||||
assert.dom(commonSelectors.HREF(urls.tcpTarget)).doesNotExist();
|
||||
});
|
||||
|
||||
test('active sessions filter is hidden if user does not have permission to list sessions', async function (assert) {
|
||||
@@ -242,18 +237,20 @@ module('Acceptance | targets | list', function (hooks) {
|
||||
);
|
||||
await visit(urls.projectScope);
|
||||
|
||||
await click(`[href="${urls.targets}"]`);
|
||||
await click(commonSelectors.HREF(urls.targets));
|
||||
|
||||
assert.dom(FILTER_DROPDOWN_SELECTOR('active-sessions')).doesNotExist();
|
||||
assert
|
||||
.dom(commonSelectors.FILTER_DROPDOWN('active-sessions'))
|
||||
.doesNotExist();
|
||||
});
|
||||
|
||||
test('user can navigate to active sessions from targets table', async function (assert) {
|
||||
await visit(urls.projectScope);
|
||||
|
||||
await click(`[href="${urls.targets}"]`);
|
||||
await click(ACTIVE_SESSIONS_SELECTOR(instances.sshTarget.id));
|
||||
await click(commonSelectors.HREF(urls.targets));
|
||||
await click(selectors.TABLE_ACTIVE_SESSIONS(instances.sshTarget.id));
|
||||
|
||||
assert.strictEqual(currentRouteName(), 'scopes.scope.sessions.index');
|
||||
assert.dom(SESSIONS_ID_SELECTOR(instances.session.id)).exists();
|
||||
assert.dom(selectors.TABLE_SESSIONS_ID(instances.session.id)).isVisible();
|
||||
});
|
||||
});
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, currentURL, click, find } from '@ember/test-helpers';
|
||||
import { visit, currentURL, click } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'admin/tests/helpers';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import { setupIndexedDb } from 'api/test-support/helpers/indexed-db';
|
||||
@@ -12,6 +12,7 @@ import a11yAudit from 'ember-a11y-testing/test-support/audit';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
import { TYPE_TARGET_TCP, TYPE_TARGET_SSH } from 'api/models/target';
|
||||
import * as commonSelectors from 'admin/tests/helpers/selectors';
|
||||
import * as selectors from './selectors';
|
||||
|
||||
module('Acceptance | targets | read', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
@@ -20,11 +21,6 @@ module('Acceptance | targets | read', function (hooks) {
|
||||
|
||||
let featuresService;
|
||||
let aliasResource;
|
||||
const ALIASES_SIDEBAR = '.target-sidebar-aliases';
|
||||
const ALIASES_SIDEBAR_LIST = '.link-list-item';
|
||||
const LINK_TO_NEW_ALIAS = '.target-sidebar-aliases .hds-button';
|
||||
const VIEW_MORE_BTN = '[data-test-view-more]';
|
||||
const FLYOUT_COMPONENT = '[data-test-flyout]';
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
@@ -84,7 +80,6 @@ module('Acceptance | targets | read', function (hooks) {
|
||||
urls.tcpTarget = `${urls.targets}/${instances.tcpTarget.id}`;
|
||||
urls.unknownTarget = `${urls.targets}/foo`;
|
||||
urls.aliases = `${urls.globalScope}/aliases`;
|
||||
|
||||
urls.alias = `${urls.tcpTarget}/${aliasResource.id}`;
|
||||
|
||||
await authenticateSession({ username: 'admin' });
|
||||
@@ -92,22 +87,26 @@ module('Acceptance | targets | read', function (hooks) {
|
||||
|
||||
test('visiting ssh target', async function (assert) {
|
||||
featuresService.enable('ssh-target');
|
||||
await visit(urls.projectScope);
|
||||
|
||||
await visit(urls.targets);
|
||||
await click(commonSelectors.HREF(urls.targets));
|
||||
await a11yAudit();
|
||||
|
||||
assert.strictEqual(currentURL(), urls.targets);
|
||||
|
||||
await click(`[href="${urls.sshTarget}"]`);
|
||||
await click(commonSelectors.HREF(urls.sshTarget));
|
||||
await a11yAudit();
|
||||
|
||||
assert.strictEqual(currentURL(), urls.sshTarget);
|
||||
});
|
||||
|
||||
test('visiting tcp target', async function (assert) {
|
||||
await visit(urls.targets);
|
||||
await visit(urls.projectScope);
|
||||
|
||||
await click(commonSelectors.HREF(urls.targets));
|
||||
assert.strictEqual(currentURL(), urls.targets);
|
||||
|
||||
await click(`[href="${urls.tcpTarget}"]`);
|
||||
await click(commonSelectors.HREF(urls.tcpTarget));
|
||||
await a11yAudit();
|
||||
|
||||
assert.strictEqual(currentURL(), urls.tcpTarget);
|
||||
@@ -119,7 +118,7 @@ module('Acceptance | targets | read', function (hooks) {
|
||||
instances.sshTarget.authorized_actions =
|
||||
instances.sshTarget.authorized_actions.filter((item) => item !== 'read');
|
||||
|
||||
await click(`[href="${urls.targets}"]`);
|
||||
await click(commonSelectors.HREF(urls.targets));
|
||||
|
||||
assert.dom(commonSelectors.TABLE_RESOURCE_LINK(urls.tcpTarget)).isVisible();
|
||||
assert
|
||||
@@ -133,7 +132,7 @@ module('Acceptance | targets | read', function (hooks) {
|
||||
instances.tcpTarget.authorized_actions =
|
||||
instances.tcpTarget.authorized_actions.filter((item) => item !== 'read');
|
||||
|
||||
await click(`[href="${urls.targets}"]`);
|
||||
await click(commonSelectors.HREF(urls.targets));
|
||||
|
||||
assert.dom(commonSelectors.TABLE_RESOURCE_LINK(urls.sshTarget)).isVisible();
|
||||
assert
|
||||
@@ -153,13 +152,15 @@ module('Acceptance | targets | read', function (hooks) {
|
||||
test('users can link to docs page for target', async function (assert) {
|
||||
await visit(urls.projectScope);
|
||||
|
||||
await click(`[href="${urls.targets}"]`);
|
||||
await click(commonSelectors.HREF(urls.targets));
|
||||
|
||||
assert
|
||||
.dom(
|
||||
`[href="https://developer.hashicorp.com/boundary/docs/concepts/domain-model/targets"]`,
|
||||
commonSelectors.HREF(
|
||||
'https://developer.hashicorp.com/boundary/docs/concepts/domain-model/targets',
|
||||
),
|
||||
)
|
||||
.exists();
|
||||
.isVisible();
|
||||
});
|
||||
|
||||
test('users can navigate to target and incorrect url auto-corrects', async function (assert) {
|
||||
@@ -175,21 +176,26 @@ module('Acceptance | targets | read', function (hooks) {
|
||||
instances.tcpTarget.update({
|
||||
aliases: [{ id: aliasResource.id, value: aliasResource.value }],
|
||||
});
|
||||
await visit(urls.tcpTarget);
|
||||
assert.dom(ALIASES_SIDEBAR).exists();
|
||||
assert.dom(ALIASES_SIDEBAR_LIST).exists();
|
||||
assert.strictEqual(
|
||||
find(ALIASES_SIDEBAR_LIST).textContent.trim(),
|
||||
'alias 1',
|
||||
);
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(commonSelectors.HREF(urls.tcpTarget));
|
||||
|
||||
assert.dom(selectors.ALIASES_SIDEBAR).isVisible();
|
||||
assert.dom(selectors.ALIASES_SIDEBAR_LIST).isVisible();
|
||||
assert.dom(selectors.ALIASES_SIDEBAR_LIST).hasText('alias 1');
|
||||
});
|
||||
|
||||
test('cannot view aliases list on the right sidebar if there is no alias associated with the target', async function (assert) {
|
||||
aliasResource.authorized_collection_actions = ['create'];
|
||||
await visit(urls.tcpTarget);
|
||||
assert.dom(ALIASES_SIDEBAR).exists();
|
||||
assert.dom(LINK_TO_NEW_ALIAS).hasText('Add an alias');
|
||||
assert.dom(ALIASES_SIDEBAR_LIST).doesNotExist();
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(commonSelectors.HREF(urls.tcpTarget));
|
||||
|
||||
assert.dom(selectors.ALIASES_SIDEBAR).isVisible();
|
||||
assert
|
||||
.dom(selectors.ALIASES_NEW_LINK)
|
||||
.hasText(selectors.ALIASES_NEW_LINK_TEXT);
|
||||
assert.dom(selectors.ALIASES_SIDEBAR_LIST).doesNotExist();
|
||||
});
|
||||
|
||||
test('user should not see add a new alias button without proper auth ', async function (assert) {
|
||||
@@ -197,11 +203,13 @@ module('Acceptance | targets | read', function (hooks) {
|
||||
instances.scopes.global.authorized_collection_actions['aliases'].filter(
|
||||
(item) => item !== 'create',
|
||||
);
|
||||
await visit(urls.tcpTarget);
|
||||
await visit(urls.targets);
|
||||
|
||||
assert.dom(ALIASES_SIDEBAR).doesNotExist();
|
||||
assert.dom(LINK_TO_NEW_ALIAS).doesNotExist();
|
||||
assert.dom(ALIASES_SIDEBAR_LIST).doesNotExist();
|
||||
await click(commonSelectors.HREF(urls.tcpTarget));
|
||||
|
||||
assert.dom(selectors.ALIASES_SIDEBAR).doesNotExist();
|
||||
assert.dom(selectors.ALIASES_NEW_LINK).doesNotExist();
|
||||
assert.dom(selectors.ALIASES_SIDEBAR_LIST).doesNotExist();
|
||||
});
|
||||
|
||||
test('can click `view more aliases` to see the remaining associated aliases if there are more than 3', async function (assert) {
|
||||
@@ -213,11 +221,15 @@ module('Acceptance | targets | read', function (hooks) {
|
||||
{ id: aliasResource.id, value: 'alias 4' },
|
||||
],
|
||||
});
|
||||
await visit(urls.tcpTarget);
|
||||
await visit(urls.targets);
|
||||
|
||||
assert.dom(ALIASES_SIDEBAR).exists();
|
||||
assert.dom(VIEW_MORE_BTN).exists();
|
||||
await click(VIEW_MORE_BTN);
|
||||
assert.dom(FLYOUT_COMPONENT).exists();
|
||||
await click(commonSelectors.HREF(urls.tcpTarget));
|
||||
|
||||
assert.dom(selectors.ALIASES_SIDEBAR).isVisible();
|
||||
assert.dom(selectors.ALIASES_VIEW_MORE_BTN).isVisible();
|
||||
|
||||
await click(selectors.ALIASES_VIEW_MORE_BTN);
|
||||
|
||||
assert.dom(selectors.ALIASES_FLYOUT).isVisible();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
export const FIELD_TYPE_CHECKED = '[name="Type"]:checked';
|
||||
export const FIELD_TYPE_VALUE = (type) => `[value=${type}]`;
|
||||
export const FIELD_DEFAULT_PORT_LABEL = '[data-test-default-port-label]';
|
||||
export const FIELD_INFO = '.info-field';
|
||||
export const FIELD_INFO_LABEL = '.info-field .hds-form-helper-text';
|
||||
export const FIELD_ALIASES =
|
||||
'[name="with_aliases"] tbody tr:last-of-type input';
|
||||
export const FIELD_ALIASES_ADD_BTN =
|
||||
'[name="with_aliases"] tbody tr:last-of-type button';
|
||||
export const FIELD_ADDRESS = '[name="address"]';
|
||||
export const FIELD_ADDRESS_VALUE = '0.0.0.0';
|
||||
export const FIELD_NAME_ERROR = '[data-test-error-message-name]';
|
||||
export const FIELD_DEFAULT_PORT_ERROR =
|
||||
'[data-test-error-message-default-port]';
|
||||
|
||||
export const NEW_TARGET_BTN = '[data-test-new-target-button';
|
||||
export const MANAGE_DROPDOWN = '[data-test-manage-targets-dropdown] button';
|
||||
export const MANAGE_DROPDOWN_DELETE =
|
||||
'[data-test-manage-targets-dropdown] ul li:last-child button';
|
||||
|
||||
export const ALIASES_SIDEBAR = '.target-sidebar-aliases';
|
||||
export const ALIASES_SIDEBAR_LIST = '.target-sidebar-aliases .link-list-item';
|
||||
export const ALIASES_NEW_LINK = '.target-sidebar-aliases .hds-button';
|
||||
export const ALIASES_NEW_LINK_TEXT = 'Add an alias';
|
||||
export const ALIASES_VIEW_MORE_BTN = '[data-test-aliases-view-more]';
|
||||
export const ALIASES_FLYOUT = '[data-test-aliases-flyout]';
|
||||
|
||||
export const NO_RESULTS_MSG = '[data-test-no-target-results]';
|
||||
export const TABLE_ACTIVE_SESSIONS = (id) =>
|
||||
`tbody [data-test-targets-table-row="${id}"] .hds-table__td:nth-child(3) a`;
|
||||
export const TABLE_SESSIONS_ID = (id) =>
|
||||
`tbody [data-test-sessions-table-row="${id}"] .hds-table__td:first-child`;
|
||||
@@ -11,6 +11,7 @@ import { setupIndexedDb } from 'api/test-support/helpers/indexed-db';
|
||||
import { Response } from 'miragejs';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
import * as commonSelectors from 'admin/tests/helpers/selectors';
|
||||
import * as selectors from './selectors';
|
||||
|
||||
module('Acceptance | targets | update', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
@@ -28,11 +29,9 @@ module('Acceptance | targets | update', function (hooks) {
|
||||
target: null,
|
||||
};
|
||||
const urls = {
|
||||
orgScope: null,
|
||||
projectScope: null,
|
||||
targets: null,
|
||||
target: null,
|
||||
newTarget: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(async function () {
|
||||
@@ -51,12 +50,9 @@ module('Acceptance | targets | update', function (hooks) {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
// Generate route URLs for resources
|
||||
urls.orgScope = `/scopes/${instances.scopes.org.id}/scopes`;
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.targets = `${urls.projectScope}/targets`;
|
||||
urls.target = `${urls.targets}/${instances.target.id}`;
|
||||
urls.unknownTarget = `${urls.targets}/foo`;
|
||||
urls.newTarget = `${urls.targets}/new`;
|
||||
|
||||
await authenticateSession({});
|
||||
});
|
||||
@@ -66,27 +62,28 @@ module('Acceptance | targets | update', function (hooks) {
|
||||
assert.notEqual(instances.target.name, 'random string');
|
||||
assert.notEqual(instances.target.worker_filter, 'random filter');
|
||||
|
||||
await click(`[href="${urls.target}"]`);
|
||||
await click('.rose-form-actions [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('.rose-form-actions [type="submit"]');
|
||||
await click(commonSelectors.HREF(urls.target));
|
||||
await click(commonSelectors.EDIT_BTN, 'Activate edit mode');
|
||||
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
|
||||
await click(commonSelectors.SAVE_BTN);
|
||||
|
||||
assert.strictEqual(currentURL(), urls.target);
|
||||
assert.strictEqual(
|
||||
this.server.schema.targets.first().name,
|
||||
'random string',
|
||||
commonSelectors.FIELD_NAME_VALUE,
|
||||
);
|
||||
});
|
||||
|
||||
test('can cancel changes to existing target', async function (assert) {
|
||||
await visit(urls.targets);
|
||||
await click(`[href="${urls.target}"]`);
|
||||
await click('.rose-form-actions [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('.rose-form-actions [type="button"]');
|
||||
|
||||
assert.notEqual(instances.target.name, 'random string');
|
||||
assert.dom('[name="name"]').hasValue(instances.target.name);
|
||||
await click(commonSelectors.HREF(urls.target));
|
||||
await click(commonSelectors.EDIT_BTN, 'Activate edit mode');
|
||||
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
|
||||
await click(commonSelectors.CANCEL_BTN);
|
||||
|
||||
assert.notEqual(instances.target.name, commonSelectors.FIELD_NAME_VALUE);
|
||||
assert.dom(commonSelectors.FIELD_NAME).hasValue(instances.target.name);
|
||||
});
|
||||
|
||||
test('saving an existing target with invalid fields displays error messages', async function (assert) {
|
||||
@@ -110,60 +107,66 @@ module('Acceptance | targets | update', function (hooks) {
|
||||
},
|
||||
);
|
||||
});
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(`[href="${urls.target}"]`);
|
||||
await click('.rose-form-actions [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('[type="submit"]');
|
||||
await click(commonSelectors.HREF(urls.target));
|
||||
await click(commonSelectors.EDIT_BTN, 'Activate edit mode');
|
||||
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
|
||||
await click(commonSelectors.SAVE_BTN);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.ALERT_TOAST_BODY)
|
||||
.hasText('The request was invalid.');
|
||||
assert.dom('.hds-form-error__message').hasText('Name is required.');
|
||||
assert.dom(selectors.FIELD_NAME_ERROR).hasText('Name is required.');
|
||||
});
|
||||
|
||||
test('can discard unsaved target changes via dialog', async function (assert) {
|
||||
const confirmService = this.owner.lookup('service:confirm');
|
||||
confirmService.enabled = true;
|
||||
assert.notEqual(instances.target.name, 'random string');
|
||||
assert.notEqual(instances.target.name, commonSelectors.FIELD_NAME_VALUE);
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(`[href="${urls.target}"]`);
|
||||
await click('.rose-form-actions [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click(commonSelectors.HREF(urls.target));
|
||||
await click(commonSelectors.EDIT_BTN, 'Activate edit mode');
|
||||
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
|
||||
|
||||
assert.strictEqual(currentURL(), urls.target);
|
||||
|
||||
await click(`[href="${urls.targets}"]`);
|
||||
await click(commonSelectors.HREF(urls.targets));
|
||||
|
||||
assert.dom(commonSelectors.MODAL_WARNING).isVisible();
|
||||
|
||||
await click(commonSelectors.MODAL_WARNING_CONFIRM_BTN);
|
||||
|
||||
assert.strictEqual(currentURL(), urls.targets);
|
||||
assert.notEqual(this.server.schema.targets.first().name, 'random string');
|
||||
assert.notEqual(
|
||||
this.server.schema.targets.first().name,
|
||||
commonSelectors.FIELD_NAME_VALUE,
|
||||
);
|
||||
});
|
||||
|
||||
test('can click cancel on discard dialog box for unsaved target changes', async function (assert) {
|
||||
const confirmService = this.owner.lookup('service:confirm');
|
||||
confirmService.enabled = true;
|
||||
assert.notEqual(instances.target.name, 'random string');
|
||||
assert.notEqual(instances.target.name, commonSelectors.FIELD_NAME_VALUE);
|
||||
await visit(urls.targets);
|
||||
|
||||
await click(`[href="${urls.target}"]`);
|
||||
await click('.rose-form-actions [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click(commonSelectors.HREF(urls.target));
|
||||
await click(commonSelectors.EDIT_BTN, 'Activate edit mode');
|
||||
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
|
||||
|
||||
assert.strictEqual(currentURL(), urls.target);
|
||||
await click(`[href="${urls.targets}"]`);
|
||||
|
||||
await click(commonSelectors.HREF(urls.targets));
|
||||
|
||||
assert.dom(commonSelectors.MODAL_WARNING).isVisible();
|
||||
|
||||
await click(commonSelectors.MODAL_WARNING_CANCEL_BTN);
|
||||
|
||||
assert.strictEqual(currentURL(), urls.target);
|
||||
assert.notEqual(this.server.schema.targets.first().name, 'random string');
|
||||
assert.notEqual(
|
||||
this.server.schema.targets.first().egressWorkerFilter,
|
||||
'random string',
|
||||
this.server.schema.targets.first().name,
|
||||
commonSelectors.FIELD_NAME_VALUE,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -172,9 +175,9 @@ module('Acceptance | targets | update', function (hooks) {
|
||||
instances.target.authorized_actions =
|
||||
instances.target.authorized_actions.filter((item) => item !== 'update');
|
||||
|
||||
await click(`[href="${urls.target}"]`);
|
||||
await click(commonSelectors.HREF(urls.target));
|
||||
|
||||
assert.dom('.rose-form-actions [type="button"]').doesNotExist();
|
||||
assert.dom(commonSelectors.EDIT_BTN).doesNotExist();
|
||||
});
|
||||
|
||||
test('saving address with existing host sources brings up confirmation modal and removes host sources', async function (assert) {
|
||||
@@ -203,18 +206,20 @@ module('Acceptance | targets | update', function (hooks) {
|
||||
|
||||
const url = `${urls.targets}/${target.id}`;
|
||||
await visit(urls.targets);
|
||||
await click(`[href="${url}"]`);
|
||||
|
||||
await click('.rose-form-actions [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="address"]', '0.0.0.0');
|
||||
await click('[type="submit"]');
|
||||
await click(commonSelectors.HREF(url));
|
||||
|
||||
await click(commonSelectors.EDIT_BTN, 'Activate edit mode');
|
||||
await fillIn(selectors.FIELD_ADDRESS, selectors.FIELD_ADDRESS_VALUE);
|
||||
await click(commonSelectors.SAVE_BTN);
|
||||
|
||||
assert.dom(commonSelectors.MODAL_WARNING).isVisible();
|
||||
|
||||
await click(commonSelectors.MODAL_WARNING_CONFIRM_BTN);
|
||||
|
||||
assert.strictEqual(
|
||||
this.server.schema.targets.find(target.id).address,
|
||||
'0.0.0.0',
|
||||
selectors.FIELD_ADDRESS_VALUE,
|
||||
);
|
||||
assert.strictEqual(
|
||||
this.server.schema.targets.find(target.id).hostSets.length,
|
||||
@@ -248,13 +253,14 @@ module('Acceptance | targets | update', function (hooks) {
|
||||
|
||||
const url = `${urls.targets}/${target.id}`;
|
||||
await visit(urls.targets);
|
||||
await click(`[href="${url}"]`);
|
||||
|
||||
await click('.rose-form-actions [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="address"]', '0.0.0.0');
|
||||
await click('[type="submit"]');
|
||||
await click(commonSelectors.HREF(url));
|
||||
await click(commonSelectors.EDIT_BTN, 'Activate edit mode');
|
||||
await fillIn(selectors.FIELD_ADDRESS, selectors.FIELD_ADDRESS_VALUE);
|
||||
await click(commonSelectors.SAVE_BTN);
|
||||
|
||||
assert.dom(commonSelectors.MODAL_WARNING).isVisible();
|
||||
|
||||
await click(commonSelectors.MODAL_WARNING_CANCEL_BTN);
|
||||
|
||||
assert.strictEqual(
|
||||
|
||||
Reference in new issue
Block a user