@@ -3,32 +3,41 @@ describe('Alert Group Animations Demo Test', () => {
33 cy . visit ( 'http://localhost:3000/alert-group-animations-demo-nav-link' ) ;
44 } ) ;
55
6- it ( 'Renders alert group item initially with animation class ' , ( ) => {
6+ it ( 'Renders alert group item with animation' , ( ) => {
77 cy . clock ( ) ;
88 cy . get ( '#add-alert-button' ) . click ( ) ;
9- cy . get ( '.pf-v6-c-alert-group__item' ) . should ( 'have.class' , 'pf-m-offstage-top' ) ;
10- cy . tick ( 100 ) ;
11- cy . get ( '#alert-close-button' ) . click ( ) ;
12- // Slightly more time than the fadeShort token used for timeout in component code
13- cy . tick ( 150 ) ;
14- cy . get ( '.pf-v6-c-alert' ) . should ( 'not.exist' ) ;
15- } ) ;
16-
17- it ( 'Renders alert group item with animation class removed after rendering' , ( ) => {
18- cy . get ( '#add-alert-button' ) . click ( ) ;
19- cy . get ( '.pf-v6-c-alert-group__item' ) . should ( 'not.have.class' , 'pf-m-offstage-top' ) ;
20- cy . get ( '#alert-close-button' ) . click ( ) ;
9+ cy . get ( '.pf-v6-c-alert-group__item' ) . then ( ( $groupItem ) => {
10+ const currentItem = $groupItem . get ( 0 ) ;
11+ const height = currentItem . offsetHeight ;
12+ expect ( height ) . to . equal ( 0 ) ;
13+ } ) ;
14+ cy . tick ( 1000 ) ;
15+ cy . get ( '.pf-v6-c-alert-group__item' ) . then ( ( $groupItem ) => {
16+ const currentItem = $groupItem . get ( 0 ) ;
17+ const height = currentItem . offsetHeight ;
18+ expect ( height ) . to . be . greaterThan ( 0 ) ;
19+ } ) ;
20+ cy . clock ( ) . invoke ( 'restore' ) ;
21+ cy . get ( '#alert-close-button' ) . click ( { waitForAnimations : true } ) ;
2122 cy . get ( '.pf-v6-c-alert' ) . should ( 'not.exist' ) ;
2223 } ) ;
2324
24- it ( 'Adds animation class to alert group item before alert is removed ' , ( ) => {
25- cy . get ( '#add-alert-button' ) . click ( ) ;
25+ it ( 'Removes alert group item with animation ' , ( ) => {
26+ let left : number ;
2627 cy . clock ( ) ;
28+ cy . get ( '#add-alert-button' ) . click ( ) ;
29+ cy . tick ( 1000 ) ;
30+ cy . get ( '.pf-v6-c-alert-group__item' ) . then ( ( $groupItem ) => {
31+ const currentItem = $groupItem . get ( 0 ) ;
32+ left = currentItem . getBoundingClientRect ( ) . left ;
33+ } ) ;
2734 cy . get ( '#alert-close-button' ) . click ( ) ;
28- // Slightly less time than the fadeShort token used for timeout in component code
2935 cy . tick ( 50 ) ;
30- cy . get ( '.pf-v6-c-alert-group__item' ) . should ( 'have.class' , 'pf-m-offstage-right' ) ;
31- cy . tick ( 100 ) ;
32- cy . get ( '.pf-v6-c-alert' ) . should ( 'not.exist' ) ;
36+ cy . get ( '.pf-v6-c-alert-group__item' ) . then ( ( $groupItem ) => {
37+ const currentItem = $groupItem . get ( 0 ) ;
38+ const leftAfterAnimation = currentItem . getBoundingClientRect ( ) . left ;
39+
40+ expect ( left ) . to . be . lessThan ( leftAfterAnimation ) ;
41+ } ) ;
3342 } ) ;
3443} ) ;
0 commit comments