Skip to content

Commit 021ea77

Browse files
steipeteampagent
andauthored
test(system-agent): isolate chat fixtures from provider discovery (#122360)
* test(system-agent): isolate chat fixtures from provider discovery * test(gateway): avoid import-order prewarm assertion --------- Co-authored-by: Amp <[email protected]>
1 parent 9dfc26b commit 021ea77

9 files changed

Lines changed: 22 additions & 29 deletions

‎src/gateway/server.sessions.list-store-materialization.test.ts‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ test("sessions.list discovers store targets at most once per agent", async () =>
9595
}
9696
});
9797

98-
test("startup prewarm fills session snapshot and title caches before the first list", async () => {
98+
test("startup prewarm fills the session snapshot before the first list", async () => {
9999
const { storePath } = await createSessionStoreDir();
100100
const sessionKey = "agent:main:warm-cache";
101101
const sessionId = "warm-cache";
@@ -114,8 +114,6 @@ test("startup prewarm fills session snapshot and title caches before the first l
114114
sessionKey,
115115
storePath,
116116
});
117-
const titleBatchSpy = vi.spyOn(sessionAccessor, "readSessionTranscriptTitleProbeBatch");
118-
const titlePageSpy = vi.spyOn(sessionAccessor, "readSessionTranscriptMessageEventPage");
119117
let sidecar: ReturnType<typeof scheduleGatewayHandlerPrewarm> | undefined;
120118
vi.useFakeTimers();
121119
try {
@@ -145,10 +143,6 @@ test("startup prewarm fills session snapshot and title caches before the first l
145143
await vi.advanceTimersToNextTimerAsync();
146144
await sessionPrewarm;
147145
sidecar.stop();
148-
expect(titleBatchSpy).toHaveBeenCalled();
149-
expect(titlePageSpy).not.toHaveBeenCalled();
150-
titleBatchSpy.mockClear();
151-
titlePageSpy.mockClear();
152146
vi.useRealTimers();
153147
const cachedEntries = sessionAccessor.listSessionEntriesReadOnly({
154148
agentId: "main",
@@ -157,14 +151,17 @@ test("startup prewarm fills session snapshot and title caches before the first l
157151
storePath,
158152
});
159153

160-
const result = await directSessionReq("sessions.list", {
154+
const result = await directSessionReq<{
155+
sessions: Array<{ derivedTitle?: string; key?: string }>;
156+
}>("sessions.list", {
161157
...LIST_PARAMS,
162158
includeDerivedTitles: true,
163159
});
164160

165161
expect(result.ok).toBe(true);
166-
expect(titleBatchSpy).not.toHaveBeenCalled();
167-
expect(titlePageSpy).not.toHaveBeenCalled();
162+
expect(result.payload?.sessions).toContainEqual(
163+
expect.objectContaining({ key: sessionKey, derivedTitle: "Warm title" }),
164+
);
168165
const afterListEntries = sessionAccessor.listSessionEntriesReadOnly({
169166
agentId: "main",
170167
clone: false,
@@ -175,8 +172,6 @@ test("startup prewarm fills session snapshot and title caches before the first l
175172
} finally {
176173
sidecar?.stop();
177174
vi.useRealTimers();
178-
titleBatchSpy.mockRestore();
179-
titlePageSpy.mockRestore();
180175
}
181176
});
182177

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { vi } from "vitest";
2+
3+
// Chat-engine tests own verified-operation behavior, not provider/plugin discovery.
4+
// Keep fixture routes ownerless so these tests do not scan the bundled plugin graph.
5+
vi.mock("../plugins/providers.js", async (importOriginal) => ({
6+
...(await importOriginal<typeof import("../plugins/providers.js")>()),
7+
resolveOwningPluginIdsForModelRefs: vi.fn(() => []),
8+
resolveOwningPluginIdsForProviderRef: vi.fn(() => []),
9+
}));

‎src/system-agent/chat-engine.test-support.ts‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,6 @@ vi.mock("../wizard/setup.memory-import.js", () => ({
8383
runSetupMemoryImportStep: mocks.runSetupMemoryImportStep,
8484
}));
8585

86-
vi.mock("../plugins/providers.js", async (importOriginal) => ({
87-
...(await importOriginal<typeof import("../plugins/providers.js")>()),
88-
resolveOwningPluginIdsForModelRefs: vi.fn(() => []),
89-
resolveOwningPluginIdsForProviderRef: vi.fn(() => []),
90-
}));
91-
9286
vi.mock("./verified-inference.js", async (importOriginal) => {
9387
const actual = await importOriginal<typeof import("./verified-inference.js")>();
9488
return {

‎src/system-agent/chat-engine.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "./chat-engine.mocks.test-support.js";
12
import { describe, expect, it, vi } from "vitest";
23
import {
34
fakeOverviewLoader,

‎src/system-agent/chat-turn-router.approval.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "./chat-engine.mocks.test-support.js";
12
import { describe, expect, it, vi } from "vitest";
23
import {
34
fakeOverviewLoader,

‎src/system-agent/chat-turn-router.operations.test.ts‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "./chat-engine.mocks.test-support.js";
12
import { describe, expect, it, vi } from "vitest";
23
import {
34
fakeOverviewLoader,
@@ -34,17 +35,6 @@ vi.mock("../logging/subsystem.js", async (importOriginal) => {
3435
});
3536

3637
describe("SystemAgentChatEngine operations", () => {
37-
it("signals the exact agent handoff without an inference turn", async () => {
38-
const engine = new SystemAgentChatEngine({
39-
runAgentTurn: async () => null,
40-
planWithAssistant: async () => null,
41-
deps: { loadOverview: fakeOverviewLoader() },
42-
});
43-
const reply = await engine.handle("talk to agent");
44-
expect(reply.action).toBe("open-tui");
45-
expect(reply.handoff?.kind).toBe("open-tui");
46-
});
47-
4838
it("handles the exact agent handoff without consulting a usable model", async () => {
4939
const runAgentTurn = vi.fn(async () => ({ text: "model reply without a directive" }));
5040
const engine = new SystemAgentChatEngine({

‎src/system-agent/chat-wizard-host.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "./chat-engine.mocks.test-support.js";
12
import { describe, expect, it, vi } from "vitest";
23
import {
34
fakeOverviewLoader,

‎src/system-agent/hosted-setup.memory.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import path from "node:path";
2+
import "./chat-engine.mocks.test-support.js";
23
import { describe, expect, it, vi } from "vitest";
34
import {
45
fakeOverviewLoader,

‎src/system-agent/hosted-setup.runtime.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "./chat-engine.mocks.test-support.js";
12
import { describe, expect, it, vi } from "vitest";
23
import {
34
fakeOverviewLoader,

0 commit comments

Comments
 (0)