Files
openclaw/extensions/imessage/src/doctor.test.ts
Omar Shahine 9434228cdc fix(imessage): dedupe accounts sharing the local Messages source (#86705)
Merged via squash.

Prepared head SHA: fcfe97d7c8
Co-authored-by: omarshahine <10343873+omarshahine@users.noreply.github.com>
Co-authored-by: omarshahine <10343873+omarshahine@users.noreply.github.com>
Reviewed-by: @omarshahine
2026-05-26 01:39:12 -07:00

69 lines
2.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { imessageDoctor } from "./doctor.js";
describe("imessageDoctor.collectPreviewWarnings", () => {
it("flags accounts that share the local Messages source", async () => {
const warnings = await imessageDoctor.collectPreviewWarnings?.({
cfg: {
channels: {
imessage: {
accounts: {
"swang430-gmail-com": {},
default: {},
},
},
},
} as never,
doctorFixCommand: "openclaw doctor --fix",
});
expect(warnings).toHaveLength(1);
const warning = warnings?.[0] ?? "";
expect(warning).toContain(
'channels.imessage: accounts "swang430-gmail-com" and "default" watch the same local Messages source (cliPath=imsg).',
);
expect(warning).toContain('OpenClaw runs one watcher (owner: "swang430-gmail-com")');
expect(warning).toContain("idles the duplicate");
expect(warning).toContain('accountId="swang430-gmail-com"');
expect(warning).toContain('"default"');
expect(warning).toContain('set "enabled": false');
});
it("includes dbPath in the warning when configured", async () => {
const warnings = await imessageDoctor.collectPreviewWarnings?.({
cfg: {
channels: {
imessage: {
accounts: {
primary: { cliPath: "imsg", dbPath: "/Users/me/chat.db" },
default: { cliPath: "imsg", dbPath: "/Users/me/chat.db" },
},
},
},
} as never,
doctorFixCommand: "openclaw doctor --fix",
});
expect(warnings).toHaveLength(1);
expect(warnings?.[0]).toMatch(/cliPath=imsg, dbPath=\/Users\/me\/chat\.db/);
});
it("stays quiet when each enabled account targets a distinct source", async () => {
const warnings = await imessageDoctor.collectPreviewWarnings?.({
cfg: {
channels: {
imessage: {
accounts: {
work: { cliPath: "/usr/local/bin/imsg-work" },
home: { cliPath: "/usr/local/bin/imsg-home" },
},
},
},
} as never,
doctorFixCommand: "openclaw doctor --fix",
});
expect(warnings).toEqual([]);
});
});