Skip to content

Commit

Permalink
Merge pull request #6400 from Sage/fix-animation-issues-pw
Browse files Browse the repository at this point in the history
Fix animation issues pw
  • Loading branch information
edleeks87 authored Oct 31, 2023
2 parents 763f1f2 + 7e46efd commit a05132f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions playwright/support/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
);
2 changes: 2 additions & 0 deletions src/components/dialog/dialog.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -374,6 +375,7 @@ test.describe(
await openToastButton.click();

const toast = toastComponent(page);
await waitForAnimationEnd(toast);
await expect(toast).toBeFocused();
});

Expand Down
1 change: 1 addition & 0 deletions src/components/drawer/__snapshots__/drawer.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ exports[`Drawer uncontrolled matches snapshot 1`] = `
<styled.div
animationDuration="0.5s"
className="open"
data-element="drawer-content"
expandedWidth="20%"
>
<Styled(Box)
Expand Down
1 change: 1 addition & 0 deletions src/components/drawer/drawer.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export const Drawer = ({
className={getClassNames()}
ref={drawerSidebarContentRef}
backgroundColor={backgroundColor}
data-element="drawer-content"
>
{stickyHeader && (
<StyledSidebarHeader isExpanded={isExpanded}>
Expand Down
5 changes: 5 additions & 0 deletions src/components/drawer/drawer.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
checkAccessibility,
assertCssValueIsApproximately,
isInViewport,
waitForAnimationEnd,
} from "../../../playwright/support/helper";

test.describe(
Expand Down Expand Up @@ -361,6 +362,10 @@ test.describe("Accessibility tests for Drawer component", () => {
<DrawerCustom showControls animationDuration={animationDuration} />
);

await waitForAnimationEnd(
page.locator('[data-element="drawer-content"]')
);

const drawerToggleButton = drawerToggle(page);
await drawerToggleButton.click();
const sidebar = drawerSidebar(page);
Expand Down

0 comments on commit a05132f

Please sign in to comment.