Skip to content

Commit a935d5a

Browse files
committed
Core: Cover reduced motion in checklist story
1 parent 87bd086 commit a935d5a

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎code/core/src/manager/components/sidebar/ChecklistWidget.stories.tsx‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,23 @@ const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
5252
const play: PlayFunction = async ({ canvasElement, step }) => {
5353
await wait(3000);
5454

55-
await step('Verify the outline animation is finite', async () => {
55+
await step('Verify the outline animation respects motion preferences', async () => {
5656
const cardContent = canvasElement.querySelector('#storybook-checklist-widget');
5757
await expect(cardContent).not.toBeNull();
5858

5959
const cardOutline = cardContent?.parentElement;
6060
await expect(cardOutline).not.toBeNull();
6161

6262
const styles = window.getComputedStyle(cardOutline!, '::before');
63-
await expect(styles.animationIterationCount).toBe('1, 1');
64-
await expect(styles.animationFillMode).toBe('forwards, forwards');
63+
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
64+
65+
if (prefersReducedMotion) {
66+
await expect(styles.animationName).toBe('none');
67+
await expect(styles.opacity).toBe('0');
68+
} else {
69+
await expect(styles.animationIterationCount).toBe('1, 1');
70+
await expect(styles.animationFillMode).toBe('forwards, forwards');
71+
}
6572
});
6673

6774
await step('Complete viewports task', () => {

0 commit comments

Comments
 (0)