Skip to content

Commit 0a2d743

Browse files
authored
fix: 🐛 Fix removing worker tag (#2928)
1 parent fbd6130 commit 0a2d743

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

ui/admin/app/components/form/worker/create-worker-led/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ unzip *.zip ;\\
184184

185185
@action
186186
removeWorkerTagByIndex(index) {
187-
this.workerTags.removeAt(index);
187+
this.workerTags.splice(index, 1);
188188
}
189189

190190
@action

ui/admin/tests/integration/components/form/worker/create-worker-led-test.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { module, test } from 'qunit';
77
import { setupRenderingTest } from 'ember-qunit';
8-
import { render } from '@ember/test-helpers';
8+
import { click, fillIn, render } from '@ember/test-helpers';
99
import { hbs } from 'ember-cli-htmlbars';
1010
import { v4 as uuidv4 } from 'uuid';
1111
import { setupIntl } from 'ember-intl/test-support';
@@ -85,5 +85,39 @@ module(
8585

8686
assert.dom('[name="cluster_id"]').hasNoValue();
8787
});
88+
89+
test('it adds and removes worker tags', async function (assert) {
90+
this.model = {};
91+
this.submit = () => {};
92+
this.cancel = () => {};
93+
94+
const KEY_VALUE_INPUT_SELECTOR = (row, column) =>
95+
`[name="worker_tags"] tbody :nth-child(${row}) td:nth-child(${column}) input`;
96+
const KEY_VALUE_BUTTON_SELECTOR = (row) =>
97+
`[name="worker_tags"] tbody :nth-child(${row}) button`;
98+
const KEY_VALUE_ROW = '[name="worker_tags"] tbody tr';
99+
100+
await render(
101+
hbs`<Form::Worker::CreateWorkerLed @model={{this.model}} @submit={{this.submit}} @cancel={{this.cancel}} />`,
102+
);
103+
104+
assert.dom(KEY_VALUE_ROW).exists({ count: 1 });
105+
106+
// Test adding a worker tag
107+
await fillIn(KEY_VALUE_INPUT_SELECTOR(1, 1), 'environment');
108+
await fillIn(KEY_VALUE_INPUT_SELECTOR(1, 2), 'dev');
109+
await click(KEY_VALUE_BUTTON_SELECTOR(1));
110+
111+
await fillIn(KEY_VALUE_INPUT_SELECTOR(2, 1), 'environment');
112+
await fillIn(KEY_VALUE_INPUT_SELECTOR(2, 2), 'test');
113+
await click(KEY_VALUE_BUTTON_SELECTOR(2));
114+
115+
assert.dom(KEY_VALUE_ROW).exists({ count: 3 });
116+
117+
// Remove the worker tag
118+
await click(KEY_VALUE_BUTTON_SELECTOR(1));
119+
120+
assert.dom(KEY_VALUE_ROW).exists({ count: 2 });
121+
});
88122
},
89123
);

0 commit comments

Comments
 (0)