11import { test , expect } from '@playwright/test'
2- import { assertNoConsoleErrors , withAnimationObserver , waitForActiveAnimations } from './utils'
2+ import { assertNoConsoleErrors , withAnimationObserver } from './utils'
33
44test . describe ( 'Framework examples animate on interaction' , ( ) => {
55 test . beforeEach ( async ( { page } ) => {
@@ -9,10 +9,20 @@ test.describe('Framework examples animate on interaction', () => {
99
1010 test ( 'Vue example animates on remove' , async ( { page } ) => {
1111 const assertNoErrorsLater = await assertNoConsoleErrors ( page )
12+ await page . locator ( '.vue-example' ) . scrollIntoViewIfNeeded ( )
13+ await page . waitForTimeout ( 100 )
1214 const observer = await withAnimationObserver ( page , '.vue-example ul' )
1315 await page . locator ( '.vue-example ul li' ) . first ( ) . click ( )
14- await page . waitForTimeout ( 50 )
15- expect ( await observer . count ( ) ) . toBeGreaterThan ( 0 )
16+
17+ // Check multiple times to catch animations on slow systems
18+ let animationCount = 0
19+ for ( let i = 0 ; i < 10 ; i ++ ) {
20+ animationCount = await observer . count ( )
21+ if ( animationCount > 0 ) break
22+ await page . waitForTimeout ( 50 )
23+ }
24+
25+ expect ( animationCount ) . toBeGreaterThan ( 0 )
1626 await assertNoErrorsLater ( )
1727 } )
1828
@@ -34,16 +44,28 @@ test.describe('Framework examples animate on interaction', () => {
3444 await assertNoErrorsLater ( )
3545 } )
3646
37- test ( 'Solid example animates on toggle' , async ( { page } ) => {
47+ test ( 'Solid example animates on toggle' , async ( { page, browserName } ) => {
3848 const assertNoErrorsLater = await assertNoConsoleErrors ( page )
3949 // Scroll to make sure the Solid example is visible
4050 await page . locator ( '.solid-example' ) . scrollIntoViewIfNeeded ( )
41- await page . waitForTimeout ( 200 ) // Give more time for any scroll-triggered layouts
51+ // WebKit needs more time on slow systems
52+ await page . waitForTimeout ( browserName === 'webkit' ? 1000 : 500 )
53+
54+ // Set up observer before clicking to catch animations
4255 const observer = await withAnimationObserver ( page , '.solid-example .parent' )
56+
57+ // Click and immediately start checking for animations
4358 await page . getByRole ( 'button' , { name : 'Toggle Drawer' } ) . click ( )
44- await page . waitForTimeout ( 100 ) // Additional wait for animation to start
45- await waitForActiveAnimations ( page , '.solid-example .parent' )
46- expect ( await observer . count ( ) ) . toBeGreaterThan ( 0 )
59+
60+ // Check multiple times to catch animations on slow systems
61+ let animationCount = 0
62+ for ( let i = 0 ; i < 20 ; i ++ ) { // More attempts for slow systems
63+ animationCount = await observer . count ( )
64+ if ( animationCount > 0 ) break
65+ await page . waitForTimeout ( 50 )
66+ }
67+
68+ expect ( animationCount ) . toBeGreaterThan ( 0 )
4769 await assertNoErrorsLater ( )
4870 } )
4971
@@ -65,11 +87,19 @@ test.describe('Framework examples animate on interaction', () => {
6587 const assertNoErrorsLater = await assertNoConsoleErrors ( page )
6688 // Scroll to make sure the Angular example is visible
6789 await page . locator ( '.angular-example' ) . scrollIntoViewIfNeeded ( )
68- await page . waitForTimeout ( 100 ) // Give time for any scroll-triggered layouts
90+ await page . waitForTimeout ( 200 ) // Give time for any scroll-triggered layouts
6991 const observer = await withAnimationObserver ( page , '.angular-example' )
7092 await page . locator ( '.angular-example .toggle-story-btn' ) . first ( ) . click ( )
71- await waitForActiveAnimations ( page , '.angular-example' )
72- expect ( await observer . count ( ) ) . toBeGreaterThan ( 0 )
93+
94+ // Check multiple times to catch animations on slow systems
95+ let animationCount = 0
96+ for ( let i = 0 ; i < 10 ; i ++ ) {
97+ animationCount = await observer . count ( )
98+ if ( animationCount > 0 ) break
99+ await page . waitForTimeout ( 50 )
100+ }
101+
102+ expect ( animationCount ) . toBeGreaterThan ( 0 )
73103 await assertNoErrorsLater ( )
74104 } )
75105} )
0 commit comments