diff --git a/playwright/support/helper.ts b/playwright/support/helper.ts index f33aa191f1..1822df2625 100644 --- a/playwright/support/helper.ts +++ b/playwright/support/helper.ts @@ -350,3 +350,8 @@ export const continuePressingSHIFTTAB = async (page: Page, count: number) => { await Promise.all(promises); }; + +export const waitForAnimationEnd = (locator: Locator) => + locator.evaluate((element) => + Promise.all(element.getAnimations().map((animation) => animation.finished)) + ); diff --git a/src/components/dialog/dialog.pw.tsx b/src/components/dialog/dialog.pw.tsx index cb007a28cc..b45aab7c21 100644 --- a/src/components/dialog/dialog.pw.tsx +++ b/src/components/dialog/dialog.pw.tsx @@ -25,6 +25,7 @@ import toastComponent from "../../../playwright/components/toast"; import { checkAccessibility, getStyle, + waitForAnimationEnd, } from "../../../playwright/support/helper"; import { CHARACTERS, SIZE } from "../../../playwright/support/constants"; @@ -374,6 +375,7 @@ test.describe( await openToastButton.click(); const toast = toastComponent(page); + await waitForAnimationEnd(toast); await expect(toast).toBeFocused(); }); diff --git a/src/components/drawer/__snapshots__/drawer.spec.tsx.snap b/src/components/drawer/__snapshots__/drawer.spec.tsx.snap index 05f92616ad..50710a2fd4 100644 --- a/src/components/drawer/__snapshots__/drawer.spec.tsx.snap +++ b/src/components/drawer/__snapshots__/drawer.spec.tsx.snap @@ -55,6 +55,7 @@ exports[`Drawer uncontrolled matches snapshot 1`] = ` {stickyHeader && ( diff --git a/src/components/drawer/drawer.pw.tsx b/src/components/drawer/drawer.pw.tsx index 1982132083..5a5b770c06 100644 --- a/src/components/drawer/drawer.pw.tsx +++ b/src/components/drawer/drawer.pw.tsx @@ -17,6 +17,7 @@ import { checkAccessibility, assertCssValueIsApproximately, isInViewport, + waitForAnimationEnd, } from "../../../playwright/support/helper"; test.describe( @@ -361,6 +362,10 @@ test.describe("Accessibility tests for Drawer component", () => { ); + await waitForAnimationEnd( + page.locator('[data-element="drawer-content"]') + ); + const drawerToggleButton = drawerToggle(page); await drawerToggleButton.click(); const sidebar = drawerSidebar(page);