@@ -152,19 +152,24 @@ it.each(["save", "send", "question"] as const)(
152152 } else {
153153 await userEvent . keyboard ( action === "send" ? "{Control>}{Enter}{/Control}" : "{Enter}" ) ;
154154 }
155- const savedPrompt = screen . container . querySelector ( "output" ) ?. dataset . prompt ;
156- expect ( savedPrompt === prompt , "Rejected comments must leave the saved prompt unchanged" ) . toBe (
157- true ,
158- ) ;
159- expect ( onSend ) . not . toHaveBeenCalled ( ) ;
155+ await vi . waitFor ( ( ) => {
156+ const savedPrompt = screen . container . querySelector ( "output" ) ?. dataset . prompt ;
157+ expect (
158+ savedPrompt === prompt ,
159+ "Rejected comments must leave the saved prompt unchanged" ,
160+ ) . toBe ( true ) ;
161+ expect ( onSend ) . not . toHaveBeenCalled ( ) ;
162+ } ) ;
160163 if ( action !== "question" ) {
161164 await expect . element ( comment ) . toHaveValue ( oversizedComment ) ;
162165 await comment . fill ( "ok" ) ;
163166 await userEvent . keyboard ( action === "send" ? "{Control>}{Enter}{/Control}" : "{Enter}" ) ;
164- expect ( screen . container . querySelector ( "output" ) ?. dataset . prompt ) . toBe (
165- `See ${ serializeAssistantCitation ( withAssistantCitationComment ( sourceCitation , "ok" ) ) } ` ,
166- ) ;
167- expect ( onSend ) . toHaveBeenCalledTimes ( action === "send" ? 1 : 0 ) ;
167+ await vi . waitFor ( ( ) => {
168+ expect ( screen . container . querySelector ( "output" ) ?. dataset . prompt ) . toBe (
169+ `See ${ serializeAssistantCitation ( withAssistantCitationComment ( sourceCitation , "ok" ) ) } ` ,
170+ ) ;
171+ expect ( onSend ) . toHaveBeenCalledTimes ( action === "send" ? 1 : 0 ) ;
172+ } ) ;
168173 }
169174 } ,
170175) ;
0 commit comments