From 2a78e199841cd7d8fd555a05d0caa6705e6bad90 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 27 Jul 2026 01:38:48 -0700 Subject: [PATCH] test(gateway): keep observer suite within lint cap --- .../session-observer-bookkeeping.test.ts | 28 ++++++++++++++++++- src/gateway/session-observer.test.ts | 24 ---------------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/gateway/session-observer-bookkeeping.test.ts b/src/gateway/session-observer-bookkeeping.test.ts index fa14359f5fef..5fe19fd4b5b0 100644 --- a/src/gateway/session-observer-bookkeeping.test.ts +++ b/src/gateway/session-observer-bookkeeping.test.ts @@ -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(); + }); }); diff --git a/src/gateway/session-observer.test.ts b/src/gateway/session-observer.test.ts index b8c098b67017..db609908e7c1 100644 --- a/src/gateway/session-observer.test.ts +++ b/src/gateway/session-observer.test.ts @@ -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);