mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-28 08:52:45 +00:00
perf(test): remove last-route polling in partial reply gating
This commit is contained in:
@@ -224,20 +224,11 @@ describe("partial reply gating", () => {
|
|||||||
replyResolver,
|
replyResolver,
|
||||||
);
|
);
|
||||||
|
|
||||||
let stored: Record<string, { lastChannel?: string; lastTo?: string }> | null = null;
|
// `monitorWebChannel(..., keepAlive=false)` waits for background tasks, including last-route writes.
|
||||||
for (let attempt = 0; attempt < 50; attempt += 1) {
|
const stored = JSON.parse(await fs.readFile(store.storePath, "utf8")) as Record<
|
||||||
stored = JSON.parse(await fs.readFile(store.storePath, "utf8")) as Record<
|
string,
|
||||||
string,
|
{ lastChannel?: string; lastTo?: string }
|
||||||
{ lastChannel?: string; lastTo?: string }
|
>;
|
||||||
>;
|
|
||||||
if (stored[mainSessionKey]?.lastChannel && stored[mainSessionKey]?.lastTo) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 5));
|
|
||||||
}
|
|
||||||
if (!stored) {
|
|
||||||
throw new Error("store not loaded");
|
|
||||||
}
|
|
||||||
expect(stored[mainSessionKey]?.lastChannel).toBe("whatsapp");
|
expect(stored[mainSessionKey]?.lastChannel).toBe("whatsapp");
|
||||||
expect(stored[mainSessionKey]?.lastTo).toBe("+1000");
|
expect(stored[mainSessionKey]?.lastTo).toBe("+1000");
|
||||||
|
|
||||||
@@ -286,27 +277,10 @@ describe("partial reply gating", () => {
|
|||||||
replyResolver,
|
replyResolver,
|
||||||
);
|
);
|
||||||
|
|
||||||
let stored: Record<
|
const stored = JSON.parse(await fs.readFile(store.storePath, "utf8")) as Record<
|
||||||
string,
|
string,
|
||||||
{ lastChannel?: string; lastTo?: string; lastAccountId?: string }
|
{ lastChannel?: string; lastTo?: string; lastAccountId?: string }
|
||||||
> | null = null;
|
>;
|
||||||
for (let attempt = 0; attempt < 50; attempt += 1) {
|
|
||||||
stored = JSON.parse(await fs.readFile(store.storePath, "utf8")) as Record<
|
|
||||||
string,
|
|
||||||
{ lastChannel?: string; lastTo?: string; lastAccountId?: string }
|
|
||||||
>;
|
|
||||||
if (
|
|
||||||
stored[groupSessionKey]?.lastChannel &&
|
|
||||||
stored[groupSessionKey]?.lastTo &&
|
|
||||||
stored[groupSessionKey]?.lastAccountId
|
|
||||||
) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 5));
|
|
||||||
}
|
|
||||||
if (!stored) {
|
|
||||||
throw new Error("store not loaded");
|
|
||||||
}
|
|
||||||
expect(stored[groupSessionKey]?.lastChannel).toBe("whatsapp");
|
expect(stored[groupSessionKey]?.lastChannel).toBe("whatsapp");
|
||||||
expect(stored[groupSessionKey]?.lastTo).toBe("123@g.us");
|
expect(stored[groupSessionKey]?.lastTo).toBe("123@g.us");
|
||||||
expect(stored[groupSessionKey]?.lastAccountId).toBe("work");
|
expect(stored[groupSessionKey]?.lastAccountId).toBe("work");
|
||||||
|
|||||||
Reference in New Issue
Block a user