51 lines
2.2 KiB
TypeScript
51 lines
2.2 KiB
TypeScript
import { expect, test } from "@playwright/experimental-ct-react";
|
|
import AxeBuilder from "@axe-core/playwright";
|
|
|
|
import { ChatInterimVisualFixture as VisualFixture } from "../../apps/web/app/components/screens/chat/chat-interim.visual-fixture";
|
|
|
|
const VISUAL_SCREENS = ["index", "detail"] as const;
|
|
|
|
test.describe("AK-P15b team chat interim UI pixel baseline", () => {
|
|
for (const screen of VISUAL_SCREENS) {
|
|
test(`${screen} stays visually stable in light mode`, async ({ mount, page }) => {
|
|
const component = await mount(
|
|
<div data-testid={`ak-p15b-${screen}`} style={{ width: "1280px", minHeight: "720px" }}>
|
|
<VisualFixture screen={screen} />
|
|
</div>
|
|
);
|
|
|
|
await page.evaluate(async () => {
|
|
await document.fonts.ready;
|
|
});
|
|
|
|
await expect(component.locator(`[data-ui-id='ui.chat.channel${screen === "index" ? "List" : "Detail"}']`)).toHaveCount(1);
|
|
if (screen === "index") {
|
|
await expect(component.locator("[data-channel-id]").first()).toHaveCSS("width", "1232px");
|
|
}
|
|
await expect(component).toHaveScreenshot(`ak-p15b-chat-${screen}.png`);
|
|
});
|
|
}
|
|
|
|
test("index keeps mobile navigation accessible with 44px touch targets", async ({ mount, page }) => {
|
|
await page.setViewportSize({ width: 390, height: 844 });
|
|
const component = await mount(
|
|
<div style={{ width: "390px", minHeight: "844px" }}>
|
|
<VisualFixture screen="index" enableNavigation />
|
|
</div>
|
|
);
|
|
|
|
const mobileNavigation = component.locator("[data-ui-id='ui.chat.mobileNavigation']");
|
|
await expect(mobileNavigation).toBeVisible();
|
|
const targets = component.locator("button:not([disabled])");
|
|
for (let index = 0; index < (await targets.count()); index += 1) {
|
|
const box = await targets.nth(index).boundingBox();
|
|
expect(box, `touch target ${index} must be rendered`).not.toBeNull();
|
|
expect(box!.height, `touch target ${index} height`).toBeGreaterThanOrEqual(44);
|
|
expect(box!.width, `touch target ${index} width`).toBeGreaterThanOrEqual(44);
|
|
}
|
|
|
|
const results = await new AxeBuilder({ page }).include("[data-ui-id='ui.chat.channelList']").withTags(["wcag2a", "wcag2aa"]).analyze();
|
|
expect(results.violations).toEqual([]);
|
|
});
|
|
});
|