test(webui): trim redundant browser coverage

This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-27 13:03:37 +08:00
1 parent 8857d4f9c8
commit 960bfa9a83
10 files changed
+187 -260

No files matched your search

+16 -14
View File
@@ -1,27 +1,28 @@
import { expect, test } from "@playwright/test";
import { expect, test, type Page } from "@playwright/test";
const cases = [
{ name: "desktop", width: 1280, touch: false, extra: "" },
{ name: "tablet", width: 1280, touch: true, extra: "" },
{ name: "small desktop", width: 600, touch: false, extra: "" },
{ name: "phone", width: 390, touch: true, extra: "" },
{ name: "narrow desktop pane", width: 1024, touch: false, extra: "&containerWidth=480" },
{ name: "tablet", width: 1280, touch: true },
{ name: "small desktop", width: 600, touch: false },
];
async function expectAlignedWorkspaceGlyph(page: Page) {
const attachment = page.getByRole("button", { name: "Attach files" }).locator("svg");
const workspace = page.getByRole("button", { name: "Switch directory" }).locator('[data-product-icon="workspace"]');
await expect(workspace).toBeVisible();
await page.evaluate(() => document.fonts.ready);
const attachmentBox = (await attachment.boundingBox())!;
const workspaceBox = (await workspace.boundingBox())!;
expect(workspaceBox.x).toBeCloseTo(attachmentBox.x, 1);
}
for (const variant of ["hero", "thread"]) for (const c of cases) {
test.describe(`${variant} ${c.name}`, () => {
test.use({ viewport: { width: c.width, height: 900 }, hasTouch: c.touch, reducedMotion: "reduce" });
test("aligns the directory glyph with the attachment glyph", async ({ page }) => {
await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en"));
await page.route("**/api/commands", route => route.fulfill({ json: { commands: [] } }));
await page.goto(`/browser/fixture.html?case=workspace-alignment&composerVariant=${variant}${c.extra}`);
const attachment = page.getByRole("button", { name: "Attach files" }).locator("svg");
const workspace = page.getByRole("button", { name: "Switch directory" }).locator('[data-product-icon="workspace"]');
await expect(workspace).toBeVisible();
await page.evaluate(() => document.fonts.ready);
const attachmentBox = (await attachment.boundingBox())!;
const workspaceBox = (await workspace.boundingBox())!;
expect(workspaceBox.x).toBeCloseTo(attachmentBox.x, 1);
await page.goto(`/browser/fixture.html?case=workspace-alignment&composerVariant=${variant}`);
await expectAlignedWorkspaceGlyph(page);
expect(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth)).toBe(false);
});
});
@@ -34,6 +35,7 @@ for (const variant of ["hero", "thread"]) for (const width of [280, 320, 390, 60
await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en"));
await page.route("**/api/commands", route => route.fulfill({ json: { commands: [] } }));
await page.goto(`/browser/fixture.html?case=workspace-alignment&composerVariant=${variant}${width === 1024 ? "&containerWidth=480" : ""}`);
if ([390, 1024, 1280].includes(width)) await expectAlignedWorkspaceGlyph(page);
const workspace = page.getByRole("button", { name: "Switch directory" });
const access = page.getByRole("button", { name: "Workspace access mode: Full Access" });
await expect(access).toBeVisible();