test(gateway): keep observer suite within lint cap

This commit is contained in:
Peter Steinberger
2026-07-27 01:38:48 -07:00
parent 45095c51b4
commit 2a78e19984
2 changed files with 27 additions and 25 deletions
@@ -1,4 +1,6 @@
import { describe, expect, it } from "vitest";
import { describe, expect, it, vi } from "vitest";
import type { OpenClawConfig } from "../config/types.openclaw.js";
import { createHarness, persistedLiveDigest } from "./session-observer.test-utils.js";
describe("session observer run bookkeeping", () => {
it("bounds dormant runs and preserves revision continuity for evicted entries", async () => {
@@ -38,4 +40,28 @@ describe("session observer run bookkeeping", () => {
expect(runs.has("run-0")).toBe(false);
expect(runs.has("run-599")).toBe(true);
});
it("reads a persisted global companion through its canonical agent store key", () => {
const config = {
gateway: { controlUi: { sessionObserver: true } },
session: { scope: "global" as const },
agents: {
defaults: { utilityModel: "openai/gpt-test" },
list: [{ id: "main", default: true }, { id: "work" }],
},
} satisfies OpenClawConfig;
const digest = persistedLiveDigest({ agentId: "work", sessionKey: "global" });
const readSession = vi.fn(() => ({
sessionId: "global-session-id",
updatedAt: 1_000,
observerDigest: digest,
}));
const harness = createHarness({ subscribe: false, config, readSession });
const snapshot = harness.observer.getCompanionSnapshot("agent:work:main");
expect(readSession).toHaveBeenCalledWith("global", "work");
expect(snapshot).toMatchObject({ agentId: "work", digest, runId: digest.runId });
harness.observer.dispose();
});
});
-24
View File
@@ -188,30 +188,6 @@ describe("session observer", () => {
harness.observer.dispose();
});
it("reads a persisted global companion through its canonical agent store key", () => {
const config = {
gateway: { controlUi: { sessionObserver: true } },
session: { scope: "global" as const },
agents: {
defaults: { utilityModel: "openai/gpt-test" },
list: [{ id: "main", default: true }, { id: "work" }],
},
} satisfies OpenClawConfig;
const digest = persistedLiveDigest({ agentId: "work", sessionKey: "global" });
const readSession = vi.fn(() => ({
sessionId: "global-session-id",
updatedAt: 1_000,
observerDigest: digest,
}));
const harness = createHarness({ subscribe: false, config, readSession });
const snapshot = harness.observer.getCompanionSnapshot("agent:work:main");
expect(readSession).toHaveBeenCalledWith("global", "work");
expect(snapshot).toMatchObject({ agentId: "work", digest, runId: digest.runId });
harness.observer.dispose();
});
it("terminalizes a preamble-only digest without a utility model", async () => {
vi.useFakeTimers();
vi.setSystemTime(0);