@@ -56,14 +56,16 @@ test('Standard Alert Group is not a toast alert group', () => {
56
56
expect ( screen . getByText ( 'alert title' ) . parentElement ) . not . toHaveClass ( 'pf-m-toast' ) ;
57
57
} ) ;
58
58
59
- test ( 'Toast Alert Group contains expected modifier class' , ( ) => {
59
+ test ( 'Toast Alert Group contains expected modifier class' , async ( ) => {
60
60
render (
61
61
< AlertGroup isToast aria-label = "group label" >
62
62
< Alert variant = "warning" title = "alert title" />
63
63
</ AlertGroup >
64
64
) ;
65
65
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' ) ;
67
69
} ) ;
68
70
69
71
test ( '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
90
92
</ AlertGroup >
91
93
) ;
92
94
93
- await user . click ( screen . getByLabelText ( 'Close' ) ) ;
95
+ const closeButton = await screen . findByLabelText ( 'Close' ) ;
96
+ await user . click ( closeButton ) ;
94
97
expect ( mockCallback ) . not . toHaveBeenCalled ( ) ;
95
98
fireEvent . transitionEnd ( screen . getByText ( 'Test Alert' ) . closest ( '.pf-v6-c-alert-group__item' ) as HTMLElement ) ;
96
99
expect ( mockCallback ) . toHaveBeenCalled ( ) ;
@@ -120,7 +123,8 @@ test('Does not call the callback set by updateTransitionEnd when transition ends
120
123
</ AlertGroup >
121
124
) ;
122
125
123
- await user . click ( screen . getByLabelText ( 'Close' ) ) ;
126
+ const closeButton = await screen . findByLabelText ( 'Close' ) ;
127
+ await user . click ( closeButton ) ;
124
128
expect ( mockCallback ) . toHaveBeenCalledTimes ( 1 ) ;
125
129
// The transitionend event firing should not cause the callback to be called again
126
130
fireEvent . transitionEnd ( screen . getByText ( 'Test Alert' ) . closest ( '.pf-v6-c-alert-group__item' ) as HTMLElement ) ;
0 commit comments