test(gateway): expect lightweight session list rows

This commit is contained in:
Vincent Koc
2026-05-02 21:37:06 -07:00
parent b1d7901a79
commit a7d3da71f7
2 changed files with 20 additions and 7 deletions

View File

@@ -12,7 +12,7 @@ import {
const { createSessionStoreDir, openClient } = setupGatewaySessionsTestHarness();
test("sessions.list surfaces transcript usage and model fallbacks from the transcript", async () => {
test("sessions.list keeps bulk rows lightweight and uses persisted model fields", async () => {
const { dir } = await createSessionStoreDir();
testState.agentConfig = {
models: {
@@ -92,10 +92,10 @@ test("sessions.list surfaces transcript usage and model fallbacks from the trans
);
expect(parent?.childSessions).toEqual(["agent:main:dashboard:child"]);
expect(child?.parentSessionKey).toBe("agent:main:main");
expect(child?.totalTokens).toBe(3_000);
expect(child?.totalTokensFresh).toBe(true);
expect(child?.contextTokens).toBe(1_048_576);
expect(child?.estimatedCostUsd).toBe(0.0042);
expect(child?.totalTokens).toBeUndefined();
expect(child?.totalTokensFresh).toBe(false);
expect(child?.contextTokens).toBeUndefined();
expect(child?.estimatedCostUsd).toBeUndefined();
expect(child?.modelProvider).toBe("anthropic");
expect(child?.model).toBe("claude-sonnet-4-6");
@@ -146,10 +146,14 @@ test("sessions.list uses the gateway model catalog for effective thinking defaul
expect(respond).toHaveBeenCalledWith(
true,
expect.objectContaining({
defaults: expect.objectContaining({
thinkingDefault: "medium",
}),
sessions: expect.arrayContaining([
expect.objectContaining({
key: "agent:main:main",
thinkingDefault: "medium",
thinkingDefault: undefined,
thinkingOptions: [],
}),
]),
}),

View File

@@ -1169,7 +1169,16 @@ describe("listSessionsFromStore selected model display", () => {
expect(listed.path).toBe(expected.path);
expect(listed.count).toBe(expected.count);
expect(listed.defaults).toEqual(expected.defaults);
expect(listed.sessions).toEqual(expected.sessions);
expect(listed.sessions).toHaveLength(expected.sessions.length);
expect(listed.sessions[0]).toEqual(
expect.objectContaining({
key: "agent:main:sess-yield-0",
derivedTitle: "title 0",
lastMessagePreview: "last 0",
}),
);
expect(listed.sessions[0]?.agentRuntime).toBeUndefined();
expect(listed.sessions[0]?.thinkingOptions).toEqual([]);
} finally {
fs.rmSync(tmpDir, { recursive: true, force: true });
}