fix(test): reset A2UI cache between tests to prevent CI flakiness

This commit is contained in:
Gareth Jones 2026-01-26 22:20:39 -08:00
parent 796d5421e5
commit c10d759c44
2 changed files with 16 additions and 2 deletions

View File

@ -12,6 +12,12 @@ export const CANVAS_WS_PATH = "/__clawdbot/ws";
let cachedA2uiRootReal: string | null | undefined;
let resolvingA2uiRoot: Promise<string | null> | null = null;
/** Reset the A2UI root cache (for testing). */
export function resetA2uiCache(): void {
cachedA2uiRootReal = undefined;
resolvingA2uiRoot = null;
}
async function resolveA2uiRoot(): Promise<string | null> {
const here = path.dirname(fileURLToPath(import.meta.url));
const candidates = [

View File

@ -3,14 +3,22 @@ import { createServer } from "node:http";
import type { AddressInfo } from "node:net";
import os from "node:os";
import path from "node:path";
import { describe, expect, it, vi } from "vitest";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { WebSocket } from "ws";
import { rawDataToString } from "../infra/ws.js";
import { defaultRuntime } from "../runtime.js";
import { CANVAS_HOST_PATH, CANVAS_WS_PATH, injectCanvasLiveReload } from "./a2ui.js";
import {
CANVAS_HOST_PATH,
CANVAS_WS_PATH,
injectCanvasLiveReload,
resetA2uiCache,
} from "./a2ui.js";
import { createCanvasHostHandler, startCanvasHost } from "./server.js";
describe("canvas host", () => {
beforeEach(() => {
resetA2uiCache();
});
it("injects live reload script", () => {
const out = injectCanvasLiveReload("<html><body>Hello</body></html>");
expect(out).toContain(CANVAS_WS_PATH);