Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions playwright/e2e/element-examples/carousel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ test.describe('si-carousel', () => {
);
};

// Carousel navigation uses a requestAnimationFrame loop, which is not exposed
// through document.getAnimations(). In snapshot-update mode Playwright can
// therefore capture the page while the viewport is still scrolling. The
// component removes its temporary inline scroll behavior once that loop has
// settled, giving the test a deterministic completion signal.
const waitForNavigationToSettle = async (page: Page): Promise<void> => {
const viewport = page.locator('si-carousel .carousel-viewport');
await expect
.poll(() => viewport.evaluate(element => element.style.scrollSnapType))
.toBe('');
};

test(example, async ({ page, si }) => {
await si.visitExample(example, false);
await expect(page.locator('si-carousel')).toBeVisible();
Expand Down Expand Up @@ -55,6 +67,7 @@ test.describe('si-carousel', () => {
for (let i = 0; i < 5; i++) {
await nextButton.click();
}
await waitForNavigationToSettle(page);
await expect(page.locator('button[aria-label^="Slide 6 of"] span').first()).toHaveClass(
/active/
);
Expand All @@ -64,6 +77,7 @@ test.describe('si-carousel', () => {
for (let i = 0; i < 3; i++) {
await nextButton.click();
}
await waitForNavigationToSettle(page);
await expect(page.locator('button[aria-label^="Slide 9 of"] span').first()).toHaveClass(
/active/
);
Expand Down
Loading