@@ -8,6 +8,7 @@ import { setupRenderingTest } from 'ember-qunit';
88import { render , click , fillIn , triggerKeyEvent } from '@ember/test-helpers' ;
99import sinon from 'sinon' ;
1010import hbs from 'htmlbars-inline-precompile' ;
11+ import { GENERAL } from 'vault/tests/helpers/general-selectors' ;
1112
1213module ( '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