Skip to content

Commit 0a5767b

Browse files
committed
Fix and refactor code editor acceptance test
1 parent db05770 commit 0a5767b

File tree

6 files changed

+16
-17
lines changed

6 files changed

+16
-17
lines changed

ui/admin/tests/acceptance/credential-store/create-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ module('Acceptance | credential-stores | create', function (hooks) {
104104

105105
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
106106
await click(selectors.TYPE_VAULT);
107-
await waitFor(selectors.CODE_EDITOR_CM_LOADED);
107+
await waitFor(commonSelectors.CODE_EDITOR_CM);
108108

109-
const editorElement = find(selectors.CODE_EDITOR_BODY);
109+
const editorElement = find(commonSelectors.CODE_EDITOR_CODE);
110110
const editorView = editorElement.editor;
111111
editorView.dispatch({
112112
changes: {
@@ -117,7 +117,7 @@ module('Acceptance | credential-stores | create', function (hooks) {
117117

118118
await click(commonSelectors.SAVE_BTN);
119119

120-
assert.dom(selectors.CODE_BLOCK_BODY).doesNotExist();
120+
assert.dom(commonSelectors.CODE_EDITOR).doesNotExist();
121121
assert.strictEqual(getVaultCredentialStoresCount(), count + 1);
122122
});
123123

ui/admin/tests/acceptance/credential-store/credentials/create-test.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,21 +203,24 @@ module(
203203
await click(commonSelectors.HREF(urls.newCredential));
204204
await click(selectors.FIELD_TYPE_JSON);
205205

206-
await waitFor('.cm-editor');
206+
await waitFor(commonSelectors.CODE_EDITOR_CM);
207207

208-
const editorElement = find('.hds-code-editor__editor');
208+
const editorElement = find(commonSelectors.CODE_EDITOR_CODE);
209209
const editorView = editorElement.editor;
210210
editorView.dispatch({
211211
changes: {
212212
from: editorView.state.selection.main.from,
213-
insert: selectors.FIELD_EDITOR_VALUE,
213+
insert: '{"test": "value"}',
214214
},
215215
});
216-
assert.dom(selectors.EDITOR).includesText(selectors.FIELD_EDITOR_VALUE);
216+
217+
assert
218+
.dom(commonSelectors.CODE_EDITOR_CODE)
219+
.includesText('{"test": "value"}');
217220
await click(selectors.FIELD_TYPE_USERNAME_PASSWORD);
218221

219222
await click(selectors.FIELD_TYPE_JSON);
220-
assert.dom(selectors.EDITOR).includesText('{}');
223+
assert.dom(commonSelectors.CODE_EDITOR_CODE).includesText('{}');
221224
});
222225

223226
test('users cannot navigate to new credential route without proper authorization', async function (assert) {

ui/admin/tests/acceptance/credential-store/credentials/selectors.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@
66
export const FIELD_TYPE_SSH = '[value=ssh_private_key]';
77
export const FIELD_TYPE_USERNAME_PASSWORD = '[value=username_password]';
88
export const FIELD_TYPE_JSON = '[value=json]';
9-
export const FIELD_EDITOR = '[data-test-code-editor-field-editor] textarea';
10-
export const FIELD_EDITOR_VALUE = '{"test": "value"}';
119
export const FIELD_PASSWORD_ERROR = '[data-test-error-message-password]';
1210
export const FIELD_SSH_PRIVATE_KEY = '[name=private_key]';
1311
export const FIELD_SSH_PRIVATE_KEY_ERROR =
1412
'[data-test-error-message-private-key]';
1513
export const FIELD_SSH_PRIVATE_KEY_PASSPHRASE = '[name=private_key_passphrase]';
1614

17-
export const EDITOR = '[data-test-code-editor-field-editor]';
1815
export const MANAGE_DROPDOWN = '[data-test-manage-credentials-dropdown] button';
1916
export const MANAGE_DROPDOWN_DELETE =
2017
'[data-test-manage-credentials-dropdown] ul li button';

ui/admin/tests/acceptance/credential-store/credentials/update-test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,9 @@ module(
571571
await click(selectors.REPLACE_SECRET_BTN);
572572

573573
assert.dom(selectors.REPLACE_SECRET_BTN).doesNotExist();
574-
await waitUntil(() => assert.dom('.cm-editor').isVisible());
574+
await waitUntil(() =>
575+
assert.dom(commonSelectors.CODE_EDITOR_CM).isVisible(),
576+
);
575577
});
576578
},
577579
);

ui/admin/tests/acceptance/credential-store/selectors.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ export const DELETE_ACTION =
1616
// Search filtering selectors
1717
export const NO_RESULTS_MSG = '[data-test-no-credential-store-results]';
1818

19-
export const CODE_EDITOR_CM_LOADED = '.cm-editor';
20-
export const CODE_EDITOR_BODY = '.hds-code-editor__editor';
2119
export const CODE_BLOCK_BODY = '.hds-code-block__code';
2220
export const EDITOR_WORKER_FILTER_VALUE = '"dev" in "/tags/env"';
2321

ui/admin/tests/acceptance/credential-store/update-test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,9 @@ module('Acceptance | credential-stores | update', function (hooks) {
388388
await click(commonSelectors.HREF(urls.workerFilter));
389389
await click(selectors.MANAGE_DROPDOWN);
390390
await click(selectors.EDIT_WORKER_FILTER_ACTION);
391-
await waitFor(selectors.CODE_EDITOR_CM_LOADED);
391+
await waitFor(commonSelectors.CODE_EDITOR_CM);
392392

393-
const editorElement = find(selectors.CODE_EDITOR_BODY);
393+
const editorElement = find(commonSelectors.CODE_EDITOR_CODE);
394394
const editorView = editorElement.editor;
395395
editorView.dispatch({
396396
changes: {
@@ -400,7 +400,6 @@ module('Acceptance | credential-stores | update', function (hooks) {
400400
});
401401

402402
await click(commonSelectors.SAVE_BTN);
403-
404403
assert.dom(selectors.CODE_BLOCK_BODY).exists();
405404
assert.dom(selectors.CODE_BLOCK_BODY).includesText('"bar" in "/tags/foo"');
406405
});

0 commit comments

Comments
 (0)