Skip to content

Commit d9675cc

Browse files
committed
test(gateway): reset shared discovery state in the fixture-reset owner
The chat.history thinkingDefault regression on CI was a pre-existing isolate:false leak: a sibling test's agentDiscoveryMock catalog fixture (reasoning:false) survived on globalThis and clamped the level to off. The shared fixture-reset owner now clears discovery state for both full and suite-backed resets, and the test publishes its own catalog fixture.
1 parent ed47688 commit d9675cc

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎src/gateway/server.chat.gateway-server-chat.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,6 +2426,9 @@ describe("gateway server chat", () => {
24262426
},
24272427
},
24282428
});
2429+
agentDiscoveryMock.enabled = true;
2430+
agentDiscoveryMock.models = [{ id: "gpt-5", provider: "openai", reasoning: true }];
2431+
await prepareGatewayReplyRuntimeForTest({ force: true });
24292432

24302433
const historyRes = await rpcReq<{
24312434
thinkingLevel?: string;
@@ -2436,6 +2439,7 @@ describe("gateway server chat", () => {
24362439
expect(historyRes.payload?.thinkingLevel).toBe("minimal");
24372440
expect(historyRes.payload?.sessionInfo?.thinkingLevel).toBeUndefined();
24382441
} finally {
2442+
Object.assign(agentDiscoveryMock, { enabled: false, models: [] });
24392443
testState.agentConfig = undefined;
24402444
testState.agentsConfig = undefined;
24412445
testState.sessionStorePath = undefined;

‎src/gateway/test-helpers.server.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,9 @@ function resetGatewayLifecycleTestState(options: { preserveRuntimeBindings: bool
359359
function resetGatewayMutableTestFixtures(): void {
360360
testTailnetIPv4.value = undefined;
361361
testTailscaleWhois.value = null;
362+
agentDiscoveryMock.enabled = false;
363+
agentDiscoveryMock.discoverCalls = 0;
364+
agentDiscoveryMock.models = [];
362365
testState.gatewayBind = DEFAULT_GATEWAY_TEST_BIND;
363366
testState.gatewayAuth = { mode: "token", token: "test-gateway-token-1234567890" };
364367
testState.gatewayControlUi = undefined;
@@ -480,9 +483,6 @@ async function resetGatewayTestState(options: { uniqueConfigRoot: boolean }) {
480483
const mod = await getServerModule();
481484
await mod.resetPreparedModelCatalogForTest();
482485
gatewayReplyRuntimePrepared = false;
483-
agentDiscoveryMock.enabled = false;
484-
agentDiscoveryMock.discoverCalls = 0;
485-
agentDiscoveryMock.models = [];
486486
}
487487

488488
async function cleanupGatewayTestHome(options: { restoreEnv: boolean }) {

0 commit comments

Comments
 (0)