Skip to content

Commit 1db1e75

Browse files
committed
test: add e2e test for finishing transitions
1 parent 5ca1eb8 commit 1db1e75

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { expect, test } from "../../../../playwright/coverage-fixture"
2+
import { mountedStory } from "../../../../playwright/mounted-story"
3+
import { applyVisualTheme, visualThemes } from "../../../../playwright/themes"
4+
5+
test("finishes theme color transitions before contrast checks read them", async ({ mount, page }) => {
6+
const component = mountedStory(await mount("welcome"))
7+
const action = component.getByRole("button", { name: /provider/i }).first()
8+
await expect(action).toBeVisible()
9+
10+
// The gallery starts in the dark theme, so this switch starts the Button border-color transition.
11+
await applyVisualTheme(
12+
page,
13+
visualThemes.find((theme) => theme.name === "high-contrast-light")!,
14+
)
15+
16+
const runningTransitions = await page.evaluate(
17+
() =>
18+
document
19+
.getAnimations()
20+
.filter((animation) => animation instanceof CSSTransition && animation.playState === "running").length,
21+
)
22+
expect(runningTransitions).toBe(0)
23+
// Read once instead of toHaveCSS, which retries until the transition ends on its own.
24+
expect(await action.evaluate((element) => getComputedStyle(element).borderTopColor)).toBe("rgb(15, 74, 133)")
25+
})

0 commit comments

Comments
 (0)