Files
openidea/e2e/fixtures.ts
l0ng-ai 909225858c test(e2e): Run specs with the macOS keymap on every host; update stale specs
CI runs Chromium on Linux, where the workbench picked the Linux keymap and
the ⌘-shortcut specs failed. Present a macOS user agent and platform.
Settings and workbench specs now match the current page tree and stripes.

Claude-Session: https://claude.ai/code/session_01B65qLEKnkeYTGdbwhLpjCu
2026-10-22 22:09:08 +08:00

49 lines
1.9 KiB
TypeScript

/** Shared helpers: open the workbench with the injected sample project and fail on page errors. */
import { expect, test as base, type Page } from "@playwright/test";
export const PROJECT = "acme-api";
export const test = base.extend<{ workbench: Page }>({
workbench: async ({ page }, provide) => {
const errors: string[] = [];
page.on("pageerror", (e) => errors.push(e.message));
// CodeMirror picks Mod-key bindings from navigator.platform, not the user agent.
await page.addInitScript(() => Object.defineProperty(Navigator.prototype, "platform", { get: () => "MacIntel" }));
await page.goto("/");
await expect(page.getByRole("tree", { name: "Project" })).toBeVisible();
await expect(page.getByRole("treeitem", { name: /acme-api/ })).toBeVisible();
await provide(page);
expect(errors, "uncaught page errors").toEqual([]);
},
});
export { expect };
/** Tool windows currently laid out (visible) in the workbench. */
export async function visibleToolWindows(page: Page): Promise<string[]> {
return page
.locator("section[aria-label]")
.evaluateAll((els) =>
els
.filter((e) => (e as HTMLElement).offsetParent !== null && e.getBoundingClientRect().width > 0)
.map((e) => e.getAttribute("aria-label") ?? ""),
);
}
export async function doubleShift(page: Page) {
await page.keyboard.press("Shift");
await page.keyboard.press("Shift");
}
/** Opens a top-level sample file from the Project tree and waits for the editor. */
export async function openFromTree(page: Page, name: string) {
await page.getByRole("treeitem", { name, exact: true }).dblclick();
await expect(page.getByRole("tablist", { name: "Editor tabs" }).getByRole("tab", { name })).toHaveAttribute(
"aria-selected",
"true",
);
const editor = page.locator(".cm-editor").first();
await expect(editor.locator(".cm-content")).not.toBeEmpty();
return editor;
}