mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 18:24:35 +00:00
test: dedupe and optimize test suites
This commit is contained in:
@@ -87,6 +87,7 @@ vi.mock("./session.js", () => {
|
||||
});
|
||||
|
||||
import { monitorWebInbox, resetWebInboundDedupe } from "./inbound.js";
|
||||
let createWaSocket: typeof import("./session.js").createWaSocket;
|
||||
|
||||
async function waitForMessage(onMessage: ReturnType<typeof vi.fn>) {
|
||||
await vi.waitFor(() => expect(onMessage).toHaveBeenCalledTimes(1), {
|
||||
@@ -97,12 +98,19 @@ async function waitForMessage(onMessage: ReturnType<typeof vi.fn>) {
|
||||
}
|
||||
|
||||
describe("web inbound media saves with extension", () => {
|
||||
async function getMockSocket() {
|
||||
return (await createWaSocket(false, false)) as unknown as {
|
||||
ev: import("node:events").EventEmitter;
|
||||
};
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
saveMediaBufferSpy.mockClear();
|
||||
resetWebInboundDedupe();
|
||||
});
|
||||
|
||||
beforeAll(async () => {
|
||||
({ createWaSocket } = await import("./session.js"));
|
||||
await fs.rm(HOME, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
@@ -118,12 +126,7 @@ describe("web inbound media saves with extension", () => {
|
||||
accountId: "default",
|
||||
authDir: path.join(HOME, "wa-auth"),
|
||||
});
|
||||
const { createWaSocket } = await import("./session.js");
|
||||
const realSock = await (
|
||||
createWaSocket as unknown as () => Promise<{
|
||||
ev: import("node:events").EventEmitter;
|
||||
}>
|
||||
)();
|
||||
const realSock = await getMockSocket();
|
||||
|
||||
realSock.ev.emit("messages.upsert", {
|
||||
type: "notify",
|
||||
@@ -202,12 +205,7 @@ describe("web inbound media saves with extension", () => {
|
||||
accountId: "default",
|
||||
authDir: path.join(HOME, "wa-auth"),
|
||||
});
|
||||
const { createWaSocket } = await import("./session.js");
|
||||
const realSock = await (
|
||||
createWaSocket as unknown as () => Promise<{
|
||||
ev: import("node:events").EventEmitter;
|
||||
}>
|
||||
)();
|
||||
const realSock = await getMockSocket();
|
||||
|
||||
const upsert = {
|
||||
type: "notify",
|
||||
|
||||
Reference in New Issue
Block a user