
















@@ -1,4 +1,4 @@
1-import { describe, expect, test } from "vitest";
1+import { describe, expect, test, vi } from "vitest";
22import { WebSocket } from "ws";
33import {
44approveNodePairing,
@@ -137,9 +137,8 @@ async function expectRePairingRequest(params: {
137137commands: params.reconnectCommands,
138138});
139139140-const deadline = Date.now() + 2_000;
141140let lastNodes: Array<{ nodeId: string; connected?: boolean; commands?: string[] }> = [];
142-while (Date.now() < deadline) {
141+await vi.waitFor(async () => {
143142const list = await rpcReq<{
144143nodes?: Array<{ nodeId: string; connected?: boolean; commands?: string[] }>;
145144}>(controlWs, "node.list", {});
@@ -151,10 +150,10 @@ async function expectRePairingRequest(params: {
151150JSON.stringify(node?.commands?.toSorted() ?? []) ===
152151JSON.stringify(params.expectedVisibleCommands)
153152) {
154-break;
153+return;
155154}
156-await new Promise((resolve) => setTimeout(resolve, 25));
157-}
155+throw new Error(`node commands not visible yet: ${JSON.stringify(lastNodes)}`);
156+});
158157159158expect(
160159lastNodes
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。