mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 21:00:20 +00:00
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:
@@ -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");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user