File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -433,12 +433,22 @@ export class App {
433433 */
434434 async findAlertText ( title : string , description ?: string ) : Promise < void > {
435435 const document = await this . document ( ) ;
436- const alert = await document . findByRole ( "alert" , {
437- name : title ,
438- } ) ;
439- if ( description ) {
440- await alert . findByText ( description ) ;
441- }
436+ await waitFor ( async ( ) => {
437+ const alerts = await document . findAllByRole ( "alert" , {
438+ name : title ,
439+ } ) ;
440+ if ( description ) {
441+ const matchingDescriptions = await Promise . all (
442+ alerts . map ( async ( alert ) => {
443+ const matches = await alert . queryAllByText ( description ) ;
444+ return matches . length > 0 ;
445+ } )
446+ ) ;
447+ if ( ! matchingDescriptions . some ( ( x ) => x ) ) {
448+ throw new Error ( "No description match in matching alerts" ) ;
449+ }
450+ }
451+ } , defaultWaitForOptions ) ;
442452 }
443453
444454 /**
You can’t perform that action at this time.
0 commit comments