Skip to content

Commit db05770

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

File tree

7 files changed

+48
-41
lines changed

7 files changed

+48
-41
lines changed

ui/admin/app/components/form/field/json-secret/index.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
@isLintingEnabled={{true}}
2828
@language='json'
2929
@onInput={{@onInput}}
30+
data-test-code-editor
3031
/>
3132
{{/if}}
3233
</div>

ui/admin/app/components/worker-filter-generator/index.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
@language='shell'
1212
@value={{or (get @model @name) ''}}
1313
@onInput={{fn this.setWorkerFilter @model @name}}
14+
data-test-code-editor
1415
/>
1516
</F.Control>
1617
{{#if (get @model.errors @name)}}

ui/admin/tests/acceptance/storage-buckets/create-test.js

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ module('Acceptance | storage-buckets | create', function (hooks) {
6161
const storageBucketCount = getStorageBucketCount();
6262
await visit(urls.storageBuckets);
6363

64-
await click(`[href="${urls.newStorageBucket}"]`);
64+
await click(commonSelectors.HREF(urls.newStorageBucket));
6565
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
6666
await select(selectors.FIELD_SCOPE, 'global');
67-
await waitFor(selectors.CODE_EDITOR_CM_LOADED);
67+
await waitFor(commonSelectors.CODE_EDITOR_CM);
6868

69-
const editorElement = find(selectors.EDITOR_WORKER_FILTER);
69+
const editorElement = find(commonSelectors.CODE_EDITOR_CODE);
7070
const editorView = editorElement.editor;
7171
editorView.dispatch({
7272
changes: {
7373
from: editorView.state.selection.main.from,
74-
insert: selectors.EDITOR_WORKER_FILTER_VALUE,
74+
insert: '"dev" in "/tags/env"',
7575
},
7676
});
7777

@@ -87,27 +87,28 @@ module('Acceptance | storage-buckets | create', function (hooks) {
8787

8888
assert.strictEqual(storageBucket.name, commonSelectors.FIELD_NAME_VALUE);
8989
assert.strictEqual(storageBucket.scopeId, 'global');
90+
9091
assert
9192
.dom(selectors.READONLY_WORKER_FILTER)
92-
.hasText(selectors.EDITOR_WORKER_FILTER_VALUE);
93+
.hasText('"dev" in "/tags/env"');
9394
assert.strictEqual(getStorageBucketCount(), storageBucketCount + 1);
9495
});
9596

9697
test('users can create a new storage bucket aws plugin type with org scope', async function (assert) {
9798
const storageBucketCount = getStorageBucketCount();
9899
await visit(urls.storageBuckets);
99100

100-
await click(`[href="${urls.newStorageBucket}"]`);
101+
await click(commonSelectors.HREF(urls.newStorageBucket));
101102
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
102103
await select(selectors.FIELD_SCOPE, instances.scopes.org.id);
103-
await waitFor(selectors.CODE_EDITOR_CM_LOADED);
104+
await waitFor(commonSelectors.CODE_EDITOR_CM);
104105

105-
const editorElement = find(selectors.EDITOR_WORKER_FILTER);
106+
const editorElement = find(commonSelectors.CODE_EDITOR_CODE);
106107
const editorView = editorElement.editor;
107108
editorView.dispatch({
108109
changes: {
109110
from: editorView.state.selection.main.from,
110-
insert: selectors.EDITOR_WORKER_FILTER_VALUE,
111+
insert: '"dev" in "/tags/env"',
111112
},
112113
});
113114

@@ -134,7 +135,7 @@ module('Acceptance | storage-buckets | create', function (hooks) {
134135

135136
// Navigate to new storage bucket
136137
await visit(urls.storageBuckets);
137-
await click(`[href="${urls.newStorageBucket}"]`);
138+
await click(commonSelectors.HREF(urls.newStorageBucket));
138139

139140
// Fill the form
140141
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
@@ -150,14 +151,14 @@ module('Acceptance | storage-buckets | create', function (hooks) {
150151
);
151152
await fillIn(selectors.FIELD_ACCESS_KEY, selectors.FIELD_ACCESS_KEY_VALUE);
152153
await fillIn(selectors.FIELD_SECRET_KEY, selectors.FIELD_SECRET_KEY_VALUE);
153-
await waitFor(selectors.CODE_EDITOR_CM_LOADED);
154+
await waitFor(commonSelectors.CODE_EDITOR_CM);
154155

155-
const editorElement = find(selectors.EDITOR_WORKER_FILTER);
156+
const editorElement = find(commonSelectors.CODE_EDITOR_CODE);
156157
const editorView = editorElement.editor;
157158
editorView.dispatch({
158159
changes: {
159160
from: editorView.state.selection.main.from,
160-
insert: selectors.EDITOR_WORKER_FILTER_VALUE,
161+
insert: '"dev" in "/tags/env"',
161162
},
162163
});
163164

@@ -185,22 +186,22 @@ module('Acceptance | storage-buckets | create', function (hooks) {
185186
const storageBucketCount = getStorageBucketCount();
186187
await visit(urls.storageBuckets);
187188

188-
await click(`[href="${urls.newStorageBucket}"]`);
189+
await click(commonSelectors.HREF(urls.newStorageBucket));
189190
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
190191

191192
// There are 2 credential types
192193
assert.dom(selectors.GROUP_CREDENTIAL_TYPE).exists({ count: 2 });
193194

194195
await click(selectors.FIELD_DYNAMIC_CREDENTIAL);
195196
await fillIn(selectors.FIELD_ROLE_ARN, selectors.FIELD_ROLE_ARN_VALUE);
196-
await waitFor(selectors.CODE_EDITOR_CM_LOADED);
197+
await waitFor(commonSelectors.CODE_EDITOR_CM);
197198

198-
const editorElement = find(selectors.EDITOR_WORKER_FILTER);
199+
const editorElement = find(commonSelectors.CODE_EDITOR_CODE);
199200
const editorView = editorElement.editor;
200201
editorView.dispatch({
201202
changes: {
202203
from: editorView.state.selection.main.from,
203-
insert: selectors.EDITOR_WORKER_FILTER_VALUE,
204+
insert: '"dev" in "/tags/env"',
204205
},
205206
});
206207

@@ -219,21 +220,21 @@ module('Acceptance | storage-buckets | create', function (hooks) {
219220
const storageBucketCount = getStorageBucketCount();
220221
await visit(urls.storageBuckets);
221222

222-
await click(`[href="${urls.newStorageBucket}"]`);
223+
await click(commonSelectors.HREF(urls.newStorageBucket));
223224
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
224225
assert.dom(selectors.GROUP_CREDENTIAL_TYPE).exists({ count: 2 });
225226

226227
await click(selectors.FIELD_STATIC_CREDENTIAL);
227228
await fillIn(selectors.FIELD_ACCESS_KEY, selectors.FIELD_ACCESS_KEY_VALUE);
228229
await fillIn(selectors.FIELD_SECRET_KEY, selectors.FIELD_SECRET_KEY_VALUE);
229-
await waitFor(selectors.CODE_EDITOR_CM_LOADED);
230+
await waitFor(commonSelectors.CODE_EDITOR_CM);
230231

231-
const editorElement = find(selectors.EDITOR_WORKER_FILTER);
232+
const editorElement = find(commonSelectors.CODE_EDITOR_CODE);
232233
const editorView = editorElement.editor;
233234
editorView.dispatch({
234235
changes: {
235236
from: editorView.state.selection.main.from,
236-
insert: selectors.EDITOR_WORKER_FILTER_VALUE,
237+
insert: '"dev" in "/tags/env"',
237238
},
238239
});
239240

@@ -254,7 +255,7 @@ module('Acceptance | storage-buckets | create', function (hooks) {
254255

255256
// Navigate to new storage bucket
256257
await visit(urls.storageBuckets);
257-
await click(`[href="${urls.newStorageBucket}"]`);
258+
await click(commonSelectors.HREF(urls.newStorageBucket));
258259

259260
// Fill the form
260261
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
@@ -269,14 +270,14 @@ module('Acceptance | storage-buckets | create', function (hooks) {
269270
);
270271
await fillIn(selectors.FIELD_ACCESS_KEY, selectors.FIELD_ACCESS_KEY_VALUE);
271272
await fillIn(selectors.FIELD_SECRET_KEY, selectors.FIELD_SECRET_KEY_VALUE);
272-
await waitFor(selectors.CODE_EDITOR_CM_LOADED);
273+
await waitFor(commonSelectors.CODE_EDITOR_CM);
273274

274-
const editorElement = find(selectors.EDITOR_WORKER_FILTER);
275+
const editorElement = find(commonSelectors.CODE_EDITOR_CODE);
275276
const editorView = editorElement.editor;
276277
editorView.dispatch({
277278
changes: {
278279
from: editorView.state.selection.main.from,
279-
insert: selectors.EDITOR_WORKER_FILTER_VALUE,
280+
insert: '"dev" in "/tags/env"',
280281
},
281282
});
282283

@@ -303,7 +304,7 @@ module('Acceptance | storage-buckets | create', function (hooks) {
303304
const storageBucketCount = getStorageBucketCount();
304305
await visit(urls.storageBuckets);
305306

306-
await click(`[href="${urls.newStorageBucket}"]`);
307+
await click(commonSelectors.HREF(urls.newStorageBucket));
307308
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
308309

309310
await click(commonSelectors.CANCEL_BTN);
@@ -334,15 +335,15 @@ module('Acceptance | storage-buckets | create', function (hooks) {
334335
});
335336
await visit(urls.storageBuckets);
336337

337-
await click(`[href="${urls.newStorageBucket}"]`);
338-
await waitFor(selectors.CODE_EDITOR_CM_LOADED);
338+
await click(commonSelectors.HREF(urls.newStorageBucket));
339+
await waitFor(commonSelectors.CODE_EDITOR_CM);
339340

340-
const editorElement = find(selectors.EDITOR_WORKER_FILTER);
341+
const editorElement = find(commonSelectors.CODE_EDITOR_CODE);
341342
const editorView = editorElement.editor;
342343
editorView.dispatch({
343344
changes: {
344345
from: editorView.state.selection.main.from,
345-
insert: selectors.EDITOR_WORKER_FILTER_VALUE,
346+
insert: '"dev" in "/tags/env"',
346347
},
347348
});
348349
await click(commonSelectors.SAVE_BTN);

ui/admin/tests/acceptance/storage-buckets/delete-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module('Acceptance | storage-buckets | delete', function (hooks) {
7575
const storageBucketCount = getStorageBucketCount();
7676
await visit(urls.globalScope);
7777

78-
await click(`[href="${urls.storageBuckets}"]`);
78+
await click(commonSelectors.HREF(urls.storageBuckets));
7979
await click(DROPDOWN_BUTTON_SELECTOR);
8080
await click(DELETE_DROPDOWN_SELECTOR);
8181

ui/admin/tests/acceptance/storage-buckets/selectors.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ export const FIELD_SECRET_KEY_EDIT_BTN =
3030
export const FIELD_WORKER_FILTER = '[name=worker_filter]';
3131
export const FIELD_WORKER_FILTER_ERROR = '[data-test-worker-filter-error]';
3232
export const READONLY_WORKER_FILTER = '[data-test-worker-filter]';
33-
export const CODE_EDITOR_CM_LOADED = '.cm-editor';
34-
export const EDITOR_WORKER_FILTER = '.hds-code-editor__editor';
35-
export const EDITOR_WORKER_FILTER_VALUE = '"dev" in "/tags/env"';
33+
3634
export const TOAST = '[role=alert] div';
3735
export const TOAST_SUCCESSFUL_VALUE = 'Saved successfully.';
3836

ui/admin/tests/acceptance/storage-buckets/update-test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module('Acceptance | storage-buckets | update', function (hooks) {
5656
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
5757
await click(commonSelectors.SAVE_BTN, 'Click save');
5858

59-
assert.dom(`[href="${urls.storageBucket}"]`).isVisible();
59+
assert.dom(commonSelectors.HREF(urls.storageBucket)).isVisible();
6060
assert
6161
.dom(commonSelectors.FIELD_NAME)
6262
.hasValue(commonSelectors.FIELD_NAME_VALUE);
@@ -163,16 +163,16 @@ module('Acceptance | storage-buckets | update', function (hooks) {
163163
);
164164
});
165165

166-
await click(`[href="${urls.storageBucket}"]`);
166+
await click(commonSelectors.HREF(urls.storageBucket));
167167
await click(commonSelectors.EDIT_BTN, 'Activate edit mode');
168-
await waitFor(selectors.CODE_EDITOR_CM_LOADED);
168+
await waitFor(commonSelectors.CODE_EDITOR_CM);
169169

170-
const editorElement = find(selectors.EDITOR_WORKER_FILTER);
170+
const editorElement = find(commonSelectors.CODE_EDITOR_CODE);
171171
const editorView = editorElement.editor;
172172
editorView.dispatch({
173173
changes: {
174174
from: editorView.state.selection.main.from,
175-
insert: selectors.EDITOR_WORKER_FILTER_VALUE,
175+
insert: '"dev" in "/tags/env"',
176176
},
177177
});
178178
await click(commonSelectors.SAVE_BTN);
@@ -229,11 +229,11 @@ module('Acceptance | storage-buckets | update', function (hooks) {
229229
await click(commonSelectors.HREF(urls.storageBucketMinio));
230230

231231
assert.dom(selectors.READONLY_WORKER_FILTER).isVisible();
232-
assert.dom(commonSelectors.CODE_EDITOR_CONTENT).doesNotExist();
232+
assert.dom(commonSelectors.CODE_EDITOR).doesNotExist();
233233

234234
await click(commonSelectors.EDIT_BTN, 'Click edit mode');
235235

236-
assert.dom(commonSelectors.CODE_EDITOR_CONTENT).isVisible();
236+
assert.dom(commonSelectors.CODE_EDITOR).isVisible();
237237
assert.dom(selectors.READONLY_WORKER_FILTER).doesNotExist();
238238
});
239239
});

ui/admin/tests/helpers/selectors.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,11 @@ export const TABLE_SORT_BTN_ARROW_UP = (column) =>
9696
export const TABLE_SORT_BTN_ARROW_DOWN = (column) =>
9797
`thead tr th:nth-child(${column}) button .hds-icon-arrow-down`;
9898

99+
// Check if we delete it
99100
export const CODE_EDITOR_CONTENT =
100101
'[data-test-code-editor-field-editor] textarea';
102+
// Perhaps, new?
103+
export const CODE_EDITOR = '[data-test-code-editor]';
104+
export const CODE_EDITOR_CODE =
105+
'[data-test-code-editor] .hds-code-editor__editor';
106+
export const CODE_EDITOR_CM = '[data-test-code-editor] .cm-editor';

0 commit comments

Comments
 (0)