/
SkipLink.ct.tsx
36 lines (28 loc) · 986 Bytes
/
SkipLink.ct.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import * as React from "react";
import { test, expect } from "@playwright/experimental-ct-react";
import SkipLinkStory from "./SkipLink.ct-story";
import RenderInRtl from "../utils/rtl/RenderInRtl";
test.describe("visual SkipLink", () => {
const forceShow = () => {
const link = document.querySelector("[data-test=SkipLink]>a");
link?.classList.remove("[&:not(:focus)]:sr-only");
};
test("default", async ({ mount }) => {
const component = await mount(<SkipLinkStory />);
await expect(component).toHaveScreenshot();
});
test("focus", async ({ mount }) => {
const component = await mount(<SkipLinkStory />);
await component.evaluate(forceShow);
await expect(component).toHaveScreenshot();
});
test("rtl", async ({ mount }) => {
const component = await mount(
<RenderInRtl>
<SkipLinkStory />
</RenderInRtl>,
);
await component.evaluate(forceShow);
await expect(component).toHaveScreenshot();
});
});