File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
tests/common/widgets/chat Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,46 @@ export function createOptionsTests(
139139 ) ;
140140 } ) ;
141141
142+ test ( 'disables clear button when chat is in progress' , async ( ) => {
143+ const searchClient = createSearchClient ( ) ;
144+ const chat = new Chat ( { } ) ;
145+
146+ await setup ( {
147+ instantSearchOptions : {
148+ indexName : 'indexName' ,
149+ searchClient,
150+ } ,
151+ widgetParams : {
152+ javascript : createDefaultWidgetParams ( chat ) ,
153+ react : createDefaultWidgetParams ( chat ) ,
154+ vue : { } ,
155+ } ,
156+ } ) ;
157+
158+ await openChat ( act ) ;
159+
160+ await act ( async ( ) => {
161+ chat . _state . messages = [
162+ {
163+ id : '1' ,
164+ role : 'user' as const ,
165+ parts : [ { type : 'text' as const , text : 'hello' } ] ,
166+ } ,
167+ ] ;
168+ await wait ( 0 ) ;
169+ } ) ;
170+
171+ const clearButton = document . querySelector ( '.ais-ChatHeader-clear' ) ;
172+ expect ( clearButton ) . not . toBeDisabled ( ) ;
173+
174+ await act ( async ( ) => {
175+ chat . _state . status = 'streaming' ;
176+ await wait ( 0 ) ;
177+ } ) ;
178+
179+ expect ( clearButton ) . toBeDisabled ( ) ;
180+ } ) ;
181+
142182 describe ( 'cssClasses' , ( ) => {
143183 test ( 'adds custom CSS classes' , async ( ) => {
144184 const searchClient = createSearchClient ( ) ;
You can’t perform that action at this time.
0 commit comments