feat(webui): support custom background images (#6674)

This commit is contained in:
chengyongru authored and GitHub committed 2026-11-16 22:08:55 +08:00
1 parent 92d23d2d2b
commit e91906bc3a
29 files changed
+1259 -3

No files matched your search

+24
View File
@@ -11,6 +11,30 @@ test("appearance puts interface settings before activity display", async ({ page
]);
});
test("reading preview and theme cards let a custom background through", async ({ page }) => {
await page.emulateMedia({ colorScheme: "light" });
await page.goto("/browser/fixture.html?case=appearance");
const card = page.locator(".appearance-reading-card");
const preview = page.locator(".appearance-reading-preview");
const theme = page.locator(".appearance-theme-card").first();
const canvas = page.locator("[data-appearance-fixture]");
await canvas.evaluate(element => element.setAttribute("data-theme-surface", ""));
await expect(canvas).not.toHaveCSS("background-color", "rgba(0, 0, 0, 0)");
await page.evaluate(() => { document.documentElement.dataset.customBackground = ""; });
await expect(canvas).toHaveCSS("background-color", "rgba(0, 0, 0, 0)");
for (const surface of [card, preview, theme]) {
expect(await surface.evaluate(node => getComputedStyle(node).backgroundColor)).toMatch(/^rgba\(/);
}
await page.getByRole("radio", { name: "Dark", exact: true }).click();
await expect(page.locator("html")).toHaveClass(/dark/);
for (const surface of [card, preview, theme]) {
expect(await surface.evaluate(node => getComputedStyle(node).backgroundColor)).toMatch(/^rgba\(/);
}
await page.evaluate(() => { delete document.documentElement.dataset.customBackground; });
await expect(canvas).not.toHaveCSS("background-color", "rgba(0, 0, 0, 0)");
expect(await card.evaluate(node => getComputedStyle(node).backgroundColor)).toMatch(/^rgb\(/);
});
test("system theme stays live, explicit choices persist, and tabs agree", async ({ page, context }) => {
await page.emulateMedia({ colorScheme: "light" });
await page.goto("/browser/fixture.html?case=appearance");
+14
View File
@@ -260,3 +260,17 @@ test("message lists and quotes retain their existing whitespace and scrolling",
overflowX: getComputedStyle(node).overflowX,
}))).toEqual({ display: "block", whiteSpace: "pre", overflowX: "auto" });
});
test("inline code uses a translucent surface over a custom background", async ({ page }) => {
await page.goto("/browser/fixture.html?case=code-wrapping");
const code = page.getByTestId("inline-code-wrapping").locator(".markdown-inline-code").first();
await expect(code).toBeVisible();
const original = await code.evaluate(element => getComputedStyle(element).backgroundColor);
await page.evaluate(() => { document.documentElement.dataset.customBackground = ""; });
for (let i = 0; i < 2; i++) {
await expect(code).toHaveCSS("background-color", /rgba\(.+, 0\.45\)/);
await page.evaluate(() => document.documentElement.classList.toggle("dark"));
}
await page.evaluate(() => { delete document.documentElement.dataset.customBackground; });
await expect(code).toHaveCSS("background-color", original);
});
+16
View File
@@ -90,6 +90,22 @@ for (const dark of [false, true]) {
}
}
test("custom backgrounds remain visible through diff surfaces in both themes", async ({ page }) => {
await page.goto("/browser/fixture.html?case=file-diff");
const diff = page.getByRole("region", { name: "Status.tsx", exact: true }).getByTestId("file-edit-diff");
const context = diff.locator("[data-line][data-line-type=context]").first();
await expect(context).toBeVisible();
await page.evaluate(() => { document.documentElement.dataset.customBackground = ""; });
for (let i = 0; i < 2; i++) {
await expect(context).toHaveCSS("background-color", "rgba(0, 0, 0, 0)");
await expect(diff).toHaveCSS("backdrop-filter", "blur(12px)");
await expect(diff.locator("[data-line][data-line-type=change-addition]")).toContainText("ready");
await page.getByRole("button", { name: "Toggle theme" }).click();
}
await page.evaluate(() => { delete document.documentElement.dataset.customBackground; });
await expect(context).not.toHaveCSS("background-color", "rgba(0, 0, 0, 0)");
});
test("large diffs retain bounded expansion, release and truncated-file actions", async ({ page }) => {
const errors: string[] = [];
page.on("pageerror", error => errors.push(error.message));