@@ -3,14 +3,13 @@ import os from "node:os";
33import path from "node:path" ;
44import { describe , expect , test , vi } from "vitest" ;
55import { WebSocket } from "ws" ;
6- import type { GetReplyOptions } from "../auto-reply/types.js" ;
76import { emitAgentEvent , registerAgentRunContext } from "../infra/agent-events.js" ;
87import { extractFirstTextBlock } from "../shared/chat-message-content.js" ;
98import { GATEWAY_CLIENT_MODES , GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js" ;
109import {
1110 connectOk ,
12- getReplyFromConfig ,
1311 installGatewayTestHooks ,
12+ mockGetReplyFromConfigOnce ,
1413 onceMessage ,
1514 rpcReq ,
1615 testState ,
@@ -166,8 +165,7 @@ describe("gateway server chat", () => {
166165 const blockedReply = new Promise < void > ( ( resolve ) => {
167166 releaseBlockedReply = resolve ;
168167 } ) ;
169- const replySpy = vi . mocked ( getReplyFromConfig ) ;
170- replySpy . mockImplementationOnce ( async ( _ctx : unknown , opts ?: GetReplyOptions ) => {
168+ mockGetReplyFromConfigOnce ( async ( _ctx , opts ) => {
171169 await new Promise < void > ( ( resolve ) => {
172170 let settled = false ;
173171 const finish = ( ) => {
@@ -564,11 +562,10 @@ describe("gateway server chat", () => {
564562
565563 test ( "routes /btw replies through side-result events without transcript injection" , async ( ) => {
566564 await withMainSessionStore ( async ( ) => {
567- const replyMock = vi . mocked ( getReplyFromConfig ) ;
568- replyMock . mockResolvedValueOnce ( {
565+ mockGetReplyFromConfigOnce ( async ( ) => ( {
569566 text : "323" ,
570567 btw : { question : "what is 17 * 19?" } ,
571- } ) ;
568+ } ) ) ;
572569 const sideResultPromise = onceMessage (
573570 ws ,
574571 ( o ) =>
@@ -620,8 +617,7 @@ describe("gateway server chat", () => {
620617
621618 test ( "routes block-streamed /btw replies through side-result events" , async ( ) => {
622619 await withMainSessionStore ( async ( ) => {
623- const replyMock = vi . mocked ( getReplyFromConfig ) ;
624- replyMock . mockImplementationOnce ( async ( _ctx : unknown , opts ?: GetReplyOptions ) => {
620+ mockGetReplyFromConfigOnce ( async ( _ctx , opts ) => {
625621 await opts ?. onBlockReply ?.( {
626622 text : "first chunk" ,
627623 btw : { question : "what changed?" } ,
0 commit comments