Tests: fix fresh-main regressions (#53011)

* Tests: fix fresh-main regressions

* Tests: avoid chat notice cache priming

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
This commit is contained in:
Luke
2026-03-24 03:54:50 +11:00
committed by GitHub
parent c55d4f63eb
commit d98e3a1ea9
3 changed files with 78 additions and 23 deletions

View File

@@ -63,10 +63,72 @@ describe("chat context notice", () => {
document.body.innerHTML = "";
});
it("falls back to default notice colors when theme vars are not hex", async () => {
const container = document.createElement("div");
document.body.append(container);
document.documentElement.style.setProperty("--warn", "rgb(1, 2, 3)");
document.documentElement.style.setProperty("--danger", "tomato");
render(
renderChat(
createProps({
sessions: {
ts: 0,
path: "",
count: 1,
defaults: { modelProvider: "openai", model: "gpt-5", contextTokens: null },
sessions: [
{
key: "main",
kind: "direct",
updatedAt: null,
totalTokens: 3_800,
inputTokens: 3_800,
contextTokens: 4_000,
},
],
},
}),
),
container,
);
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
const notice = container.querySelector<HTMLElement>(".context-notice");
expect(notice).not.toBeNull();
expect(notice?.style.getPropertyValue("--ctx-color")).toContain("rgb(");
expect(notice?.style.getPropertyValue("--ctx-color")).not.toContain("NaN");
expect(notice?.style.getPropertyValue("--ctx-bg")).not.toContain("NaN");
document.documentElement.style.removeProperty("--warn");
document.documentElement.style.removeProperty("--danger");
});
it("keeps the warning icon badge-sized", async () => {
const container = document.createElement("div");
document.body.append(container);
render(renderChat(createProps()), container);
render(
renderChat(
createProps({
sessions: {
ts: 0,
path: "",
count: 1,
defaults: { modelProvider: "openai", model: "gpt-5", contextTokens: null },
sessions: [
{
key: "main",
kind: "direct",
updatedAt: null,
totalTokens: 3_800,
inputTokens: 3_800,
contextTokens: 4_000,
},
],
},
}),
),
container,
);
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
const icon = container.querySelector<SVGElement>(".context-notice__icon");
@@ -80,22 +142,4 @@ describe("chat context notice", () => {
expect(iconStyle.height).toBe("16px");
expect(icon.getBoundingClientRect().width).toBeLessThan(24);
});
it("falls back to default notice colors when theme vars are not hex", async () => {
const container = document.createElement("div");
document.body.append(container);
document.documentElement.style.setProperty("--warn", "rgb(1, 2, 3)");
document.documentElement.style.setProperty("--danger", "tomato");
render(renderChat(createProps()), container);
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
const notice = container.querySelector<HTMLElement>(".context-notice");
expect(notice).not.toBeNull();
expect(notice?.style.getPropertyValue("--ctx-color")).toContain("rgb(");
expect(notice?.style.getPropertyValue("--ctx-color")).not.toContain("NaN");
expect(notice?.style.getPropertyValue("--ctx-bg")).not.toContain("NaN");
document.documentElement.style.removeProperty("--warn");
document.documentElement.style.removeProperty("--danger");
});
});