perf(test): trim duplicate e2e suites and harden signal hooks

This commit is contained in:
Peter Steinberger
2026-02-13 16:46:31 +00:00
parent 45b9aad0f4
commit 1eccfa8934
8 changed files with 79 additions and 319 deletions

View File

@@ -16,7 +16,7 @@ vi.mock("./agent-paths.js", () => ({
resolveOpenClawAgentDir: () => "/tmp/openclaw",
}));
describe("loadModelCatalog", () => {
describe("loadModelCatalog e2e smoke", () => {
beforeEach(() => {
resetModelCatalogCacheForTest();
});
@@ -27,10 +27,8 @@ describe("loadModelCatalog", () => {
vi.restoreAllMocks();
});
it("retries after import failure without poisoning the cache", async () => {
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
it("recovers after an import failure on the next load", async () => {
let call = 0;
__setModelCatalogImportForTest(async () => {
call += 1;
if (call === 1) {
@@ -47,41 +45,9 @@ describe("loadModelCatalog", () => {
});
const cfg = {} as OpenClawConfig;
const first = await loadModelCatalog({ config: cfg });
expect(first).toEqual([]);
const second = await loadModelCatalog({ config: cfg });
expect(second).toEqual([{ id: "gpt-4.1", name: "GPT-4.1", provider: "openai" }]);
expect(call).toBe(2);
expect(warnSpy).toHaveBeenCalledTimes(1);
});
it("returns partial results on discovery errors", async () => {
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
__setModelCatalogImportForTest(
async () =>
({
AuthStorage: class {},
ModelRegistry: class {
getAll() {
return [
{ id: "gpt-4.1", name: "GPT-4.1", provider: "openai" },
{
get id() {
throw new Error("boom");
},
provider: "openai",
name: "bad",
},
];
}
},
}) as unknown as PiSdkModule,
);
const result = await loadModelCatalog({ config: {} as OpenClawConfig });
expect(result).toEqual([{ id: "gpt-4.1", name: "GPT-4.1", provider: "openai" }]);
expect(warnSpy).toHaveBeenCalledTimes(1);
expect(await loadModelCatalog({ config: cfg })).toEqual([]);
expect(await loadModelCatalog({ config: cfg })).toEqual([
{ id: "gpt-4.1", name: "GPT-4.1", provider: "openai" },
]);
});
});