Skip to content

Commit 9c50aa4

Browse files
Merge remote-tracking branch 'remotes/from/ce/release/1.21.x' into release/1.21.x
2 parents 9a9a614 + 85e2b4a commit 9c50aa4

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

ui/lib/core/addon/components/string-list.hbs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@
5959
</div>
6060
{{/each}}
6161
{{#if this.indicesWithComma}}
62-
<Hds::Alert @type="inline" @color="warning" as |A|>
62+
<Hds::Alert @type="inline" @color="warning" data-test-validation-warning={{@attrName}} as |A|>
6363
<A.Description>
64-
Input contains a comma. Please separate values into individual rows.
64+
Input contains a comma. To enter multiple values, use separate rows. If commas are part of your value, disregard this
65+
message.
6566
</A.Description>
6667
</Hds::Alert>
6768
{{/if}}

ui/tests/integration/components/string-list-test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { setupRenderingTest } from 'ember-qunit';
88
import { render, click, fillIn, triggerKeyEvent } from '@ember/test-helpers';
99
import sinon from 'sinon';
1010
import hbs from 'htmlbars-inline-precompile';
11+
import { GENERAL } from 'vault/tests/helpers/general-selectors';
1112

1213
module('Integration | Component | string list', function (hooks) {
1314
setupRenderingTest(hooks);
@@ -137,4 +138,29 @@ module('Integration | Component | string list', function (hooks) {
137138
assert.dom('[data-test-string-list-input="0"]').hasValue('bar');
138139
assert.dom('[data-test-string-list-input="1"]').hasValue('');
139140
});
141+
142+
test('it shows a warning when input contains a comma', async function (assert) {
143+
await render(
144+
hbs`<StringList @inputValue={{this.inputValue}} @onChange={{this.spy}} @attrName="paramA" />`
145+
);
146+
await fillIn('[data-test-string-list-input="0"]', 'foo,bar');
147+
await click('[data-test-string-list-button="add"]');
148+
await fillIn('[data-test-string-list-input="1"]', 'no comma');
149+
assert
150+
.dom(GENERAL.validationWarningByAttr('paramA'))
151+
.exists()
152+
.hasText(
153+
'Input contains a comma. To enter multiple values, use separate rows. If commas are part of your value, disregard this message.'
154+
);
155+
assert
156+
.dom(`[data-test-string-list-row="0"] ${GENERAL.icon('alert-triangle')}`)
157+
.exists('input containing comma has an alert icon');
158+
assert
159+
.dom(`[data-test-string-list-row="1"] ${GENERAL.icon('alert-triangle')}`)
160+
.doesNotExist('input without comma does NOT have an alert icon');
161+
// Update input to assert warning disappears
162+
await fillIn('[data-test-string-list-input="0"]', 'foobar');
163+
assert.dom(GENERAL.validationWarningByAttr('paramA')).doesNotExist();
164+
assert.dom(GENERAL.icon('alert-triangle')).doesNotExist();
165+
});
140166
});

0 commit comments

Comments
 (0)