test: trim UI and entry test overhead

This commit is contained in:
Peter Steinberger
2026-04-17 20:23:07 +01:00
parent 087f1584df
commit 809f42eeea
4 changed files with 39 additions and 35 deletions

View File

@@ -17,15 +17,16 @@ import { renderSideResult } from "./side-result-render.ts";
describe("context notice", () => {
afterEach(() => {
document.documentElement.style.removeProperty("--warn");
document.documentElement.style.removeProperty("--danger");
vi.restoreAllMocks();
resetContextNoticeThemeCacheForTest();
});
it("renders only for fresh high current usage", () => {
const container = document.createElement("div");
document.documentElement.style.setProperty("--warn", "rgb(1, 2, 3)");
document.documentElement.style.setProperty("--danger", "tomato");
vi.spyOn(window, "getComputedStyle").mockReturnValue({
getPropertyValue: (name: string) =>
name === "--warn" ? "#010203" : name === "--danger" ? "#040506" : "",
} as CSSStyleDeclaration);
resetContextNoticeThemeCacheForTest();
expect(
@@ -58,6 +59,7 @@ describe("context notice", () => {
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")).toContain("4, 5, 6");
expect(notice?.style.getPropertyValue("--ctx-color")).not.toContain("NaN");
expect(notice?.style.getPropertyValue("--ctx-bg")).not.toContain("NaN");

View File

@@ -12,6 +12,10 @@ import type { SessionsListResult } from "../types.ts";
import type { MessageGroup } from "../types/chat-types.ts";
import { renderChat, type ChatProps } from "./chat.ts";
vi.mock("../markdown.ts", () => ({
toSanitizedMarkdownHtml: (value: string) => value,
}));
vi.mock("./markdown-sidebar.ts", async () => {
const { html } = await import("lit");
return {