mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05: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,
|
||||
);
|
||||
|
||||
let stored: Record<string, { lastChannel?: string; lastTo?: 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 }
|
||||
>;
|
||||
if (stored[mainSessionKey]?.lastChannel && stored[mainSessionKey]?.lastTo) {
|
||||
break;
|
||||
}
|
||||
await new Promise((resolve) => setTimeout(resolve, 5));
|
||||
}
|
||||
if (!stored) {
|
||||
throw new Error("store not loaded");
|
||||
}
|
||||
// `monitorWebChannel(..., keepAlive=false)` waits for background tasks, including last-route writes.
|
||||
const stored = JSON.parse(await fs.readFile(store.storePath, "utf8")) as Record<
|
||||
string,
|
||||
{ lastChannel?: string; lastTo?: string }
|
||||
>;
|
||||
expect(stored[mainSessionKey]?.lastChannel).toBe("whatsapp");
|
||||
expect(stored[mainSessionKey]?.lastTo).toBe("+1000");
|
||||
|
||||
@@ -286,27 +277,10 @@ describe("partial reply gating", () => {
|
||||
replyResolver,
|
||||
);
|
||||
|
||||
let stored: Record<
|
||||
const stored = JSON.parse(await fs.readFile(store.storePath, "utf8")) as Record<
|
||||
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]?.lastTo).toBe("123@g.us");
|
||||
expect(stored[groupSessionKey]?.lastAccountId).toBe("work");
|
||||
|
||||
Reference in New Issue
Block a user