-
-
Notifications
You must be signed in to change notification settings - Fork 80.8k
Expand file tree
/
Copy pathavatar-initials.e2e.test.ts
More file actions
78 lines (66 loc) · 2.99 KB
/
Copy pathavatar-initials.e2e.test.ts
File metadata and controls
78 lines (66 loc) · 2.99 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Control UI proof: agent chip avatar fallbacks keep complete graphemes for
// flag/ZWJ emoji and ordinary Unicode letters (no UTF-16 mid-cluster cuts).
import { mkdir } from "node:fs/promises";
import path from "node:path";
import { chromium, type Browser } from "playwright";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import {
canRunPlaywrightChromium,
installMockGateway,
resolvePlaywrightChromiumExecutablePath,
startControlUiE2eServer,
type ControlUiE2eServer,
} from "../test-helpers/control-ui-e2e.ts";
const chromiumExecutablePath = resolvePlaywrightChromiumExecutablePath(chromium.executablePath());
const chromiumAvailable = canRunPlaywrightChromium(chromiumExecutablePath);
const allowMissingChromium = process.env.OPENCLAW_UI_E2E_ALLOW_MISSING_CHROMIUM === "1";
const describeControlUiE2e = chromiumAvailable || !allowMissingChromium ? describe : describe.skip;
const artifactDir = path.join(process.cwd(), ".artifacts", "control-ui-e2e", "avatar-initials");
const CASES = [
{ assistantName: "🇺🇸Team", expectedInitial: "🇺🇸", shot: "flag-avatar.png" },
{ assistantName: "👨💻Dev", expectedInitial: "👨💻", shot: "zwj-avatar.png" },
{ assistantName: "東京", expectedInitial: "東", shot: "tokyo-avatar.png" },
] as const;
let browser: Browser;
let server: ControlUiE2eServer;
describeControlUiE2e("Control UI avatar grapheme initials E2E", () => {
beforeAll(async () => {
if (!chromiumAvailable) {
throw new Error(`Playwright Chromium is unavailable at ${chromiumExecutablePath}`);
}
server = await startControlUiE2eServer();
browser = await chromium.launch({ executablePath: chromiumExecutablePath });
await mkdir(artifactDir, { recursive: true });
});
afterAll(async () => {
await browser?.close();
await server?.close();
});
it("renders complete flag, ZWJ, and Unicode letter initials in the agent chip", async () => {
const proof: Record<string, string> = {};
for (const testCase of CASES) {
const context = await browser.newContext({
locale: "en-US",
serviceWorkers: "block",
viewport: { height: 900, width: 1280 },
});
const page = await context.newPage();
await installMockGateway(page, { assistantName: testCase.assistantName });
try {
const response = await page.goto(server.baseUrl);
expect(response?.status()).toBe(200);
const avatar = page.locator(".sidebar-agent-card__avatar-text");
await avatar.waitFor();
await expect.poll(() => avatar.textContent()).toBe(testCase.expectedInitial);
proof[testCase.shot] = (await avatar.textContent()) ?? "";
await page.locator(".sidebar-agent-card").screenshot({
path: path.join(artifactDir, testCase.shot),
});
} finally {
await context.close();
}
}
console.log("control-ui avatar-initials e2e proof:", JSON.stringify(proof));
console.log("control-ui avatar-initials artifact dir:", artifactDir);
});
});