Files
openidea/e2e/windowGroupTabColor.spec.ts
T
wangfeiandhapput 2478f67066 fix(workbench): keep project tab tint on hover (#5477)
Follow-up to #4481: hovering a coloured project tab made the custom colour disappear. The hover rule layered the opaque `--bg-hover` surface on top of the tint (`linear-gradient(var(--bg-hover), var(--bg-hover)), var(--tab-tint-mix)`), so while the pointer was over the tab only the plain grey hover surface remained.
The hover rule now mixes the project colour into the hover surface instead, mirroring how the selected rule mixes into `--bg-island`:
```css
.item[data-tinted]:hover {
  background: color-mix(in srgb, var(--project-color) 12%, var(--bg-hover));
}

Co-authored-by: happut <2594794+happut@users.noreply.github.com>
2026-11-24 00:10:02 +08:00

41 lines
1.8 KiB
TypeScript

import { expect, test } from "./fixtures";
test("hovering a tinted project tab keeps its colour", async ({ workbench: page }) => {
await page.evaluate(async () => {
const tabColors = "/src/workbench/tabColors.ts";
const windowGroups = "/src/platform/windowGroups.ts";
const { setTabColorOverride } = await import(/* @vite-ignore */ tabColors);
const { useWindowGroup } = await import(/* @vite-ignore */ windowGroups);
setTabColorOverride("/tinted", "#d24b8f");
useWindowGroup.setState({
tabs: [
{ label: "main", name: "acme-api", root: "/plain", current: true },
{ label: "second", name: "acme-api", root: "/plain2", current: false },
{ label: "third", name: "acme-api", root: "/tinted", current: false },
],
});
});
const plain = page.locator('[data-project-tab="second"]');
const tinted = page.locator('[data-project-tab="third"]');
await expect(tinted).toBeVisible();
// A blank strip inside the tab: right of the hover close button, left of the centred label.
const strip = async (tab: typeof plain) => {
const box = (await tab.boundingBox())!;
return { x: box.x + 34, y: box.y + box.height / 2 - 5, width: 8, height: 10 };
};
const shoot = async (tab: typeof plain) => page.screenshot({ clip: await strip(tab), animations: "disabled" });
await tinted.hover();
const tintedHover = await shoot(tinted);
await page.mouse.move(700, 600);
const tintedRest = await shoot(tinted);
await plain.hover();
const plainHover = await shoot(plain);
// The opaque hover surface must not swallow the tint: a tinted tab renders differently from a plain one.
expect(tintedHover.equals(plainHover)).toBe(false);
// Hover still gives feedback on the tinted tab itself.
expect(tintedHover.equals(tintedRest)).toBe(false);
});