test(coding-agent): flush immediate before asserting tiny-title prewarm
Re-applies the race fix from7b21716754that563f00fe31dropped as 'unrelated': InteractiveMode.init() defers the prewarm behind setImmediate, and init()'s own awaits are microtasks that can resolve without yielding to the immediate queue, so asserting right after await init() races under CI's chunked load. Flush one immediate tick before asserting.
This commit is contained in:
@@ -87,6 +87,14 @@ describe("InteractiveMode tiny-title prewarm", () => {
|
||||
const prewarm = vi.spyOn(tinyTitleClient, "prewarm").mockImplementation(() => {});
|
||||
|
||||
await mode.init();
|
||||
// The prewarm call is deferred behind a setImmediate queued during
|
||||
// init() (see interactive-mode.ts); init()'s own awaits are promise
|
||||
// microtasks that can resolve without yielding to the immediate
|
||||
// queue, so the prewarm may not have fired yet when init() settles.
|
||||
// Flush one immediate tick before asserting.
|
||||
const immediateFlushed = Promise.withResolvers<void>();
|
||||
setImmediate(immediateFlushed.resolve);
|
||||
await immediateFlushed.promise;
|
||||
|
||||
expect(prewarm).toHaveBeenCalledWith("lfm2-350m");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user