test(perf): trim fixed waits in relay and startup tests

This commit is contained in:
Peter Steinberger
2026-03-02 17:30:22 +00:00
parent 310dd24ce3
commit 34ff873a7e
5 changed files with 22 additions and 29 deletions

View File

@@ -71,6 +71,7 @@ describe("diffs plugin registration", () => {
},
pluginConfig: {
defaults: {
mode: "view",
theme: "light",
background: false,
layout: "split",

View File

@@ -48,18 +48,14 @@ describe("googlechatPlugin gateway.startAccount", () => {
statusPatchSink: (next) => patches.push({ ...next }),
}),
);
await new Promise((resolve) => setTimeout(resolve, 20));
let settled = false;
void task.then(() => {
settled = true;
});
await new Promise((resolve) => setTimeout(resolve, 20));
await vi.waitFor(() => {
expect(hoisted.startGoogleChatMonitor).toHaveBeenCalledOnce();
});
expect(settled).toBe(false);
expect(hoisted.startGoogleChatMonitor).toHaveBeenCalledOnce();
expect(unregister).not.toHaveBeenCalled();
abort.abort();

View File

@@ -115,16 +115,15 @@ describe("linePlugin gateway.startAccount", () => {
}),
);
// Allow async internals (probeLineBot await) to flush
await new Promise((r) => setTimeout(r, 20));
expect(monitorLineProvider).toHaveBeenCalledWith(
expect.objectContaining({
channelAccessToken: "token",
channelSecret: "secret",
accountId: "default",
}),
);
await vi.waitFor(() => {
expect(monitorLineProvider).toHaveBeenCalledWith(
expect.objectContaining({
channelAccessToken: "token",
channelSecret: "secret",
accountId: "default",
}),
);
});
abort.abort();
await task;

View File

@@ -48,17 +48,14 @@ describe("nextcloudTalkPlugin gateway.startAccount", () => {
abortSignal: abort.signal,
}),
);
await new Promise((resolve) => setTimeout(resolve, 20));
let settled = false;
void task.then(() => {
settled = true;
});
await new Promise((resolve) => setTimeout(resolve, 20));
await vi.waitFor(() => {
expect(hoisted.monitorNextcloudTalkProvider).toHaveBeenCalledOnce();
});
expect(settled).toBe(false);
expect(hoisted.monitorNextcloudTalkProvider).toHaveBeenCalledOnce();
expect(stop).not.toHaveBeenCalled();
abort.abort();