@@ -56,14 +56,16 @@ test('Standard Alert Group is not a toast alert group', () => {
5656 expect ( screen . getByText ( 'alert title' ) . parentElement ) . not . toHaveClass ( 'pf-m-toast' ) ;
5757} ) ;
5858
59- test ( 'Toast Alert Group contains expected modifier class' , ( ) => {
59+ test ( 'Toast Alert Group contains expected modifier class' , async ( ) => {
6060 render (
6161 < AlertGroup isToast aria-label = "group label" >
6262 < Alert variant = "warning" title = "alert title" />
6363 </ AlertGroup >
6464 ) ;
6565
66- expect ( screen . getByLabelText ( 'group label' ) ) . toHaveClass ( 'pf-m-toast' ) ;
66+ // Wait for the portal to be created and rendered
67+ const alertGroup = await screen . findByLabelText ( 'group label' ) ;
68+ expect ( alertGroup ) . toHaveClass ( 'pf-m-toast' ) ;
6769} ) ;
6870
6971test ( 'Calls the callback set by updateTransitionEnd when transition ends and animations are enabled' , async ( ) => {
@@ -90,7 +92,8 @@ test('Calls the callback set by updateTransitionEnd when transition ends and ani
9092 </ AlertGroup >
9193 ) ;
9294
93- await user . click ( screen . getByLabelText ( 'Close' ) ) ;
95+ const closeButton = await screen . findByLabelText ( 'Close' ) ;
96+ await user . click ( closeButton ) ;
9497 expect ( mockCallback ) . not . toHaveBeenCalled ( ) ;
9598 fireEvent . transitionEnd ( screen . getByText ( 'Test Alert' ) . closest ( '.pf-v6-c-alert-group__item' ) as HTMLElement ) ;
9699 expect ( mockCallback ) . toHaveBeenCalled ( ) ;
@@ -120,7 +123,8 @@ test('Does not call the callback set by updateTransitionEnd when transition ends
120123 </ AlertGroup >
121124 ) ;
122125
123- await user . click ( screen . getByLabelText ( 'Close' ) ) ;
126+ const closeButton = await screen . findByLabelText ( 'Close' ) ;
127+ await user . click ( closeButton ) ;
124128 expect ( mockCallback ) . toHaveBeenCalledTimes ( 1 ) ;
125129 // The transitionend event firing should not cause the callback to be called again
126130 fireEvent . transitionEnd ( screen . getByText ( 'Test Alert' ) . closest ( '.pf-v6-c-alert-group__item' ) as HTMLElement ) ;
0 commit comments