fix: stabilize windows queue + pairing tests

This commit is contained in:
Peter Steinberger
2026-01-16 04:02:43 +00:00
parent 01c8d099ad
commit e6364d031d
2 changed files with 18 additions and 10 deletions

View File

@@ -2,6 +2,7 @@ import path from "node:path";
import { afterEach, describe, expect, it, vi } from "vitest";
import { pollUntil } from "../../test/helpers/poll.js";
import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js";
import {
isEmbeddedPiRunActive,
@@ -109,7 +110,6 @@ describe("queue followups", () => {
});
it("summarizes dropped followups when cap is exceeded", async () => {
vi.useFakeTimers();
await withTempHome(async (home) => {
const prompts: string[] = [];
vi.mocked(runEmbeddedPiAgent).mockImplementation(async (params) => {
@@ -133,8 +133,10 @@ describe("queue followups", () => {
vi.mocked(isEmbeddedPiRunActive).mockReturnValue(false);
await getReplyFromConfig({ Body: "three", From: "+1002", To: "+2000" }, {}, cfg);
await vi.runAllTimersAsync();
await Promise.resolve();
await pollUntil(
async () => (prompts.some((p) => p.includes("[Queue overflow]")) ? true : null),
{ timeoutMs: 2000 },
);
expect(prompts.some((p) => p.includes("[Queue overflow]"))).toBe(true);
});

View File

@@ -323,6 +323,11 @@ describe("node bridge server", { timeout: suiteTimeoutMs }, () => {
resolveDisconnected = resolve;
});
let pendingRequest: {
requestId: string;
nodeId: string;
ts: number;
} | null = null;
const server = await startNodeBridgeServer({
host: "127.0.0.1",
port: 0,
@@ -330,6 +335,13 @@ describe("node bridge server", { timeout: suiteTimeoutMs }, () => {
onAuthenticated: async (node) => {
lastAuthed = node;
},
onPairRequested: async (request) => {
pendingRequest = {
requestId: request.requestId,
nodeId: request.nodeId,
ts: request.ts,
};
},
onDisconnected: async (node) => {
disconnected = node;
resolveDisconnected?.();
@@ -351,13 +363,7 @@ describe("node bridge server", { timeout: suiteTimeoutMs }, () => {
});
// Approve the pending request from the gateway side.
const pending = await pollUntil(
async () => {
const list = await listNodePairing(baseDir);
return list.pending.find((p) => p.nodeId === "n4");
},
{ timeoutMs: pairingTimeoutMs },
);
const pending = await pollUntil(async () => pendingRequest, { timeoutMs: pairingTimeoutMs });
expect(pending).toBeTruthy();
if (!pending) throw new Error("expected a pending request");
const approved = await approveNodePairing(pending.requestId, baseDir);