test: tighten messaging plugin array assertions

This commit is contained in:
Shakker
2026-05-09 05:00:31 +01:00
parent c83a40e474
commit c4d05b0dfc
27 changed files with 44 additions and 44 deletions

View File

@@ -88,7 +88,7 @@ describe("device-pair notify persistence", () => {
const persisted = JSON.parse(
await fs.readFile(path.join(stateDir, "device-pair-notify.json"), "utf8"),
) as { subscribers: unknown[] };
expect(persisted.subscribers).toEqual([]);
expect(persisted.subscribers).toStrictEqual([]);
});
it("does not remove a different persisted subscriber when notify fields contain pipes", async () => {

View File

@@ -25,8 +25,8 @@ describe("parsePostContent", () => {
expect(result.textContent).toBe(
"Daily \\*Plan\\*\n\n**Bold** *Italic* <u>Underline</u> ~~Strike~~ `Code`",
);
expect(result.imageKeys).toEqual([]);
expect(result.mentionedOpenIds).toEqual([]);
expect(result.imageKeys).toStrictEqual([]);
expect(result.mentionedOpenIds).toStrictEqual([]);
});
it("renders links and mentions", () => {
@@ -70,7 +70,7 @@ describe("parsePostContent", () => {
expect(result.textContent).toBe("Before ![image] after\n![image]");
expect(result.imageKeys).toEqual(["img_1", "img_2"]);
expect(result.mentionedOpenIds).toEqual([]);
expect(result.mentionedOpenIds).toStrictEqual([]);
});
it("supports locale wrappers", () => {

View File

@@ -85,7 +85,7 @@ describe("createSequentialQueue", () => {
).rejects.toThrow("boom");
await new Promise((resolve) => setTimeout(resolve, 0));
expect(unhandled).toEqual([]);
expect(unhandled).toStrictEqual([]);
await expect(
enqueue("feishu:default:chat-1", async () => {
@@ -156,7 +156,7 @@ describe("createSequentialQueue", () => {
// Wait long enough that a timeout would have fired if it were active.
await vi.advanceTimersByTimeAsync(30);
expect(order).toEqual(["first:start"]);
expect(timeouts).toEqual([]);
expect(timeouts).toStrictEqual([]);
gate.resolve();
await Promise.all([first, second]);

View File

@@ -55,6 +55,6 @@ describe("googlechat secret contract", () => {
const workAccount = resolvedConfig.channels?.googlechat?.accounts?.work;
expect(workAccount?.serviceAccount).toBe('{"client_email":"bot@example.com"}');
expect(context.warnings).toEqual([]);
expect(context.warnings).toStrictEqual([]);
});
});

View File

@@ -180,7 +180,7 @@ describe("listInworldVoices", () => {
queueGuardedResponse(new Response(JSON.stringify({}), { status: 200 }));
const voices = await listInworldVoices({ apiKey: "test-key" });
expect(voices).toEqual([]);
expect(voices).toStrictEqual([]);
});
it("passes language filter as query parameter", async () => {

View File

@@ -20,7 +20,7 @@ describe("linePlugin status.collectStatusIssues", () => {
tokenSource: "env",
},
]),
).toEqual([]);
).toStrictEqual([]);
});
it("reports missing access token when the snapshot is unconfigured and tokenSource is none", () => {

View File

@@ -382,8 +382,8 @@ describe("linePlugin status.probeAccount", () => {
describe("line runtime api", () => {
it("keeps the LINE runtime barrel self-contained", () => {
const runtimeApiPath = path.join(process.cwd(), "extensions", "line", "runtime-api.ts");
expect(collectRuntimeApiPreExports(runtimeApiPath)).toEqual([]);
expect(collectRuntimeApiPreExports(runtimeApiPath)).toEqual([]);
expect(collectRuntimeApiPreExports(runtimeApiPath)).toStrictEqual([]);
expect(collectRuntimeApiPreExports(runtimeApiPath)).toStrictEqual([]);
});
});

View File

@@ -145,7 +145,7 @@ const unresolvedSecretRefPrivateKeyCases = [
{
name: "listNostrAccountIds",
assert: (cfg: ReturnType<typeof createUnresolvedNostrPrivateKeyCfg>) => {
expect(listNostrAccountIds(cfg)).toEqual([]);
expect(listNostrAccountIds(cfg)).toStrictEqual([]);
},
},
{
@@ -192,7 +192,7 @@ describe("nostrPlugin", () => {
it("listAccountIds returns empty array for unconfigured", () => {
const cfg = { channels: {} };
const ids = nostrTestPlugin.config.listAccountIds(cfg);
expect(ids).toEqual([]);
expect(ids).toStrictEqual([]);
});
it("listAccountIds returns default for configured", () => {
@@ -370,12 +370,12 @@ describe("nostr account helpers", () => {
describe("listNostrAccountIds", () => {
it("returns empty array when not configured", () => {
const cfg = { channels: {} };
expect(listNostrAccountIds(cfg)).toEqual([]);
expect(listNostrAccountIds(cfg)).toStrictEqual([]);
});
it("returns empty array when nostr section exists but no privateKey", () => {
const cfg = { channels: { nostr: { enabled: true } } };
expect(listNostrAccountIds(cfg)).toEqual([]);
expect(listNostrAccountIds(cfg)).toStrictEqual([]);
});
it("returns default when privateKey is configured", () => {

View File

@@ -133,7 +133,7 @@ describe("createProfileEvent", () => {
expect(event.kind).toBe(0);
expect(event.pubkey).toBe(TEST_PUBKEY);
expect(event.tags).toEqual([]);
expect(event.tags).toStrictEqual([]);
expect(event.id).toMatch(/^[0-9a-f]{64}$/);
expect(event.sig).toMatch(/^[0-9a-f]{128}$/);
});

View File

@@ -126,7 +126,7 @@ describe("phone-control plugin", () => {
expect(writeConfigFile).toHaveBeenCalledTimes(1);
expect(nodes.allowCommands).toEqual([...WRITE_COMMANDS]);
expect(nodes.denyCommands).toEqual([]);
expect(nodes.denyCommands).toStrictEqual([]);
expect(text).toContain("sms.send");
});
});

View File

@@ -32,8 +32,8 @@ describe("normalizeQQBotAllowFrom", () => {
});
it("returns empty array for undefined/null", () => {
expect(normalizeQQBotAllowFrom(undefined)).toEqual([]);
expect(normalizeQQBotAllowFrom(null)).toEqual([]);
expect(normalizeQQBotAllowFrom(undefined)).toStrictEqual([]);
expect(normalizeQQBotAllowFrom(null)).toStrictEqual([]);
});
});

View File

@@ -162,7 +162,7 @@ describe("engine/config/group", () => {
describe("resolveMentionPatterns", () => {
it("returns [] when nothing configured", () => {
expect(resolveMentionPatterns({})).toEqual([]);
expect(resolveMentionPatterns({})).toStrictEqual([]);
});
it("reads global patterns", () => {

View File

@@ -8,7 +8,7 @@ import {
describe("engine/config/resolve", () => {
it("returns empty list when no accounts configured", () => {
expect(listAccountIds({})).toEqual([]);
expect(listAccountIds({})).toStrictEqual([]);
});
it("returns default when top-level appId is set", () => {

View File

@@ -68,6 +68,6 @@ describe("engine import boundary", () => {
}
}
expect(offenders).toEqual([]);
expect(offenders).toStrictEqual([]);
});
});

View File

@@ -157,7 +157,7 @@ describe("engine/group/history", () => {
entry: entry("A", "hi"),
limit: 0,
});
expect(entries).toEqual([]);
expect(entries).toStrictEqual([]);
expect(map.size).toBe(0);
});
@@ -301,7 +301,7 @@ describe("engine/group/history", () => {
limit: 5,
});
clearPendingHistory({ historyMap: map, historyKey: "G", limit: 5 });
expect(map.get("G")).toEqual([]);
expect(map.get("G")).toStrictEqual([]);
});
it("no-ops when disabled", () => {

View File

@@ -30,7 +30,7 @@ async function resolveQqbotSecretAssignments(
);
applyResolvedAssignments({ assignments: context.assignments, resolved });
expect(context.warnings).toEqual([]);
expect(context.warnings).toStrictEqual([]);
return resolvedConfig;
}

View File

@@ -381,8 +381,8 @@ describe("createSynologyChatPlugin", () => {
const plugin = createSynologyChatPlugin();
const params = { cfg: {}, runtime: {} as never };
expect(await plugin.directory.self?.(params)).toBeNull();
expect(await plugin.directory.listPeers?.(params)).toEqual([]);
expect(await plugin.directory.listGroups?.(params)).toEqual([]);
expect(await plugin.directory.listPeers?.(params)).toStrictEqual([]);
expect(await plugin.directory.listGroups?.(params)).toStrictEqual([]);
});
});

View File

@@ -145,8 +145,8 @@ describe("synology-chat core", () => {
describe("synology-chat account resolution", () => {
it("lists no accounts when the channel is missing", () => {
expect(listAccountIds({})).toEqual([]);
expect(listAccountIds({ channels: {} })).toEqual([]);
expect(listAccountIds({})).toStrictEqual([]);
expect(listAccountIds({ channels: {} })).toStrictEqual([]);
});
it("lists the default account when base config has a token", () => {

View File

@@ -62,7 +62,7 @@ describe("tlon core", () => {
cfg: {} as OpenClawConfig,
accountId: "default",
}),
).toEqual([]);
).toStrictEqual([]);
});
it("resolves dm allowlist from the default account", () => {

View File

@@ -74,8 +74,8 @@ describe("applyTlonSettingsOverrides", () => {
},
});
expect(result.effectiveDmAllowlist).toEqual([]);
expect(result.effectiveGroupInviteAllowlist).toEqual([]);
expect(result.effectiveDmAllowlist).toStrictEqual([]);
expect(result.effectiveGroupInviteAllowlist).toStrictEqual([]);
});
it("falls back to file config when settings fields are removed", () => {
@@ -108,6 +108,6 @@ describe("applyTlonSettingsOverrides", () => {
expect(result.effectiveAutoAcceptGroupInvites).toBe(false);
expect(result.effectiveShowModelSig).toBe(true);
expect(result.effectiveOwnerShip).toBe("~nec");
expect(result.pendingApprovals).toEqual([]);
expect(result.pendingApprovals).toStrictEqual([]);
});
});

View File

@@ -137,7 +137,7 @@ describe("createTaskFlowWebhookRequestHandler", () => {
expect(res.statusCode).toBe(401);
expect(res.body).toBe("unauthorized");
expect(target.taskFlow.list()).toEqual([]);
expect(target.taskFlow.list()).toStrictEqual([]);
expect(hoisted.resolveConfiguredSecretInputStringMock).not.toHaveBeenCalled();
});

View File

@@ -43,7 +43,7 @@ describe("zalo directory", () => {
limit: undefined,
runtime: runtimeEnv,
}),
).resolves.toEqual([]);
).resolves.toStrictEqual([]);
}
it("lists peers from allowFrom", async () => {

View File

@@ -101,7 +101,7 @@ describe("zalo send", () => {
ok: false,
error: "No Zalo bot token configured",
});
expect(missingToken.receipt.platformMessageIds).toEqual([]);
expect(missingToken.receipt.platformMessageIds).toStrictEqual([]);
const blankPhoto = await sendPhotoZalo("dm-chat-4", " ", {
token: "zalo-token",
@@ -110,7 +110,7 @@ describe("zalo send", () => {
ok: false,
error: "No photo URL provided",
});
expect(blankPhoto.receipt.platformMessageIds).toEqual([]);
expect(blankPhoto.receipt.platformMessageIds).toStrictEqual([]);
expect(sendMessageMock).not.toHaveBeenCalled();
expect(sendPhotoMock).not.toHaveBeenCalled();

View File

@@ -890,6 +890,6 @@ describe("zalouser monitor group mention gating", () => {
});
expect(dispatchReplyWithBufferedBlockDispatcher).toHaveBeenCalledTimes(2);
const secondDispatch = dispatchReplyWithBufferedBlockDispatcher.mock.calls[1]?.[0];
expect(secondDispatch?.ctx?.InboundHistory).toEqual([]);
expect(secondDispatch?.ctx?.InboundHistory).toStrictEqual([]);
});
});

View File

@@ -178,7 +178,7 @@ describe("zalouser send helpers", () => {
mockSendText.mock.calls
.map((call, index) => ({ index, length: call[1].length }))
.filter((call) => call.length > 2000),
).toEqual([]);
).toStrictEqual([]);
expect(result).toMatchObject({ ok: true, messageId: "mid-2c-2" });
});
@@ -388,7 +388,7 @@ describe("zalouser send helpers", () => {
remove: undefined,
});
expect(result).toMatchObject({ ok: true, error: undefined });
expect(result.receipt.platformMessageIds).toEqual([]);
expect(result.receipt.platformMessageIds).toStrictEqual([]);
});
it("delegates delivered+seen helpers to JS transport", async () => {

View File

@@ -142,7 +142,7 @@ describe("zalouser setup wizard", () => {
});
expectEnabledDefaultSetup(result, "allowlist");
expect(result.cfg.channels?.zalouser?.allowFrom).toEqual([]);
expect(result.cfg.channels?.zalouser?.allowFrom).toStrictEqual([]);
expect(
note.mock.calls.some(([message]) => message.includes("No DM allowlist entries added yet.")),
).toBe(true);
@@ -214,7 +214,7 @@ describe("zalouser setup wizard", () => {
const result = await runSetup({ prompter, forceAllowFrom: true });
expect(result.cfg.channels?.zalouser?.dmPolicy).toBe("allowlist");
expect(result.cfg.channels?.zalouser?.allowFrom).toEqual([]);
expect(result.cfg.channels?.zalouser?.allowFrom).toStrictEqual([]);
expect(seen).not.toContain("Zalo Personal DM policy");
expect(seen).toContain("Zalouser allowFrom (name or user id)");
expect(

View File

@@ -311,7 +311,7 @@ describe("zalouser credential persistence", () => {
try {
await withEnvAsync({ OPENCLAW_STATE_DIR: stateDir }, async () => {
await expect(listZaloFriends(profile)).resolves.toEqual([]);
await expect(listZaloFriends(profile)).resolves.toStrictEqual([]);
const firstRaw = await readFile(filePath, "utf8");
const stableMtime = new Date("2026-04-01T00:00:10.000Z");
await utimes(filePath, stableMtime, stableMtime);
@@ -319,7 +319,7 @@ describe("zalouser credential persistence", () => {
currentCookie = cookieB;
await expect(listZaloFriends(profile)).resolves.toEqual([]);
await expect(listZaloFriends(profile)).resolves.toStrictEqual([]);
expect(await readFile(filePath, "utf8")).toBe(firstRaw);
expect((await stat(filePath)).mtimeMs).toBe(firstMtimeMs);
});