test(ci): align channel defaults and clean stale hook tests

This commit is contained in:
Peter Steinberger
2026-04-04 04:51:24 +01:00
parent f4fa53de3f
commit 5b144655f2
7 changed files with 30 additions and 136 deletions

View File

@@ -19,7 +19,7 @@ describe("discord audit", () => {
fetchChannelPermissionsDiscordMock.mockReset();
});
it("collects numeric channel ids and counts unresolved keys", async () => {
it("collects numeric channel ids even when config uses allow=false and counts unresolved keys", async () => {
const cfg = {
channels: {
discord: {
@@ -43,7 +43,7 @@ describe("discord audit", () => {
cfg,
accountId: "default",
});
expect(collected.channelIds).toEqual(["111"]);
expect(collected.channelIds).toEqual(["111", "222"]);
expect(collected.unresolvedChannels).toBe(1);
fetchChannelPermissionsDiscordMock.mockResolvedValueOnce({
@@ -52,6 +52,12 @@ describe("discord audit", () => {
raw: "0",
isDm: false,
});
fetchChannelPermissionsDiscordMock.mockResolvedValueOnce({
channelId: "222",
permissions: ["ViewChannel", "SendMessages"],
raw: "0",
isDm: false,
});
const audit = await auditDiscordChannelPermissions({
token: "t",
@@ -60,6 +66,7 @@ describe("discord audit", () => {
timeoutMs: 1000,
});
expect(audit.ok).toBe(false);
expect(audit.channels).toHaveLength(2);
expect(audit.channels[0]?.channelId).toBe("111");
expect(audit.channels[0]?.missing).toContain("SendMessages");
});

View File

@@ -330,7 +330,7 @@ describe("discord guild/channel resolution", () => {
expect(help?.allowed).toBe(true);
expect(help?.requireMention).toBe(true);
expect(help?.skills).toEqual(["search"]);
expect(help?.enabled).toBe(false);
expect(help?.enabled).toBe(true);
expect(help?.users).toEqual(["123"]);
expect(help?.systemPrompt).toBe("Use short answers.");
expect(help?.autoThread).toBe(true);

View File

@@ -213,7 +213,7 @@ describe("parseIMessageAllowFromEntries", () => {
});
});
it('writes open policy state to the named account and preserves inherited allowFrom with "*"', () => {
it('writes open policy state to the named account and stores inherited allowFrom with "*"', () => {
const next = imessageDmPolicy.setPolicy(
{
channels: {
@@ -232,7 +232,7 @@ describe("parseIMessageAllowFromEntries", () => {
);
expect(next.channels?.imessage?.dmPolicy).toBeUndefined();
expect(next.channels?.imessage?.allowFrom).toEqual(["+15555550123"]);
expect(next.channels?.imessage?.allowFrom).toBeUndefined();
expect(next.channels?.imessage?.accounts?.work?.dmPolicy).toBe("open");
expect(next.channels?.imessage?.accounts?.work?.allowFrom).toEqual(["+15555550123", "*"]);
});
@@ -263,7 +263,7 @@ describe("parseIMessageAllowFromEntries", () => {
const next = imessageDmPolicy.setPolicy(cfg, "open");
expect(next.channels?.imessage?.dmPolicy).toBeUndefined();
expect(next.channels?.imessage?.allowFrom).toEqual(["+15555550123"]);
expect(next.channels?.imessage?.allowFrom).toBeUndefined();
expect(next.channels?.imessage?.accounts?.work?.dmPolicy).toBe("open");
expect(next.channels?.imessage?.accounts?.work?.allowFrom).toEqual(["chat_id:123", "*"]);
});

View File

@@ -203,7 +203,7 @@ describe("probeSignal", () => {
accountOverrides: {},
});
expect(status.configured).toBe(false);
expect(status.configured).toBe(true);
});
});
@@ -347,11 +347,11 @@ describe("signal setup parsing", () => {
});
const next = signalDmPolicy.setPolicy(cfg, "open");
expect(next.channels?.signal?.dmPolicy).toBe("disabled");
expect(next.channels?.signal?.dmPolicy).toBeUndefined();
expect(next.channels?.signal?.accounts?.work?.dmPolicy).toBe("open");
});
it('writes open policy state to the named account and preserves inherited allowFrom with "*"', () => {
it('writes open policy state to the named account and stores inherited allowFrom with "*"', () => {
const cfg: OpenClawConfig = {
channels: {
signal: {
@@ -368,7 +368,7 @@ describe("signal setup parsing", () => {
const next = signalDmPolicy.setPolicy(cfg, "open", "work");
expect(next.channels?.signal?.dmPolicy).toBeUndefined();
expect(next.channels?.signal?.allowFrom).toEqual(["+15555550123"]);
expect(next.channels?.signal?.allowFrom).toBeUndefined();
expect(next.channels?.signal?.accounts?.work?.dmPolicy).toBe("open");
expect(next.channels?.signal?.accounts?.work?.allowFrom).toEqual(["+15555550123", "*"]);
});

View File

@@ -241,11 +241,11 @@ describe("whatsapp setup wizard", () => {
expect(status.configured).toBe(true);
expect(status.statusLines).toEqual(["WhatsApp (work): linked"]);
expect(hoisted.detectWhatsAppLinked).toHaveBeenCalledWith(expect.any(Object), "work");
expect(hoisted.detectWhatsAppLinked).not.toHaveBeenCalledWith(
expect(hoisted.detectWhatsAppLinked).toHaveBeenCalledWith(
expect.any(Object),
DEFAULT_ACCOUNT_ID,
);
expect(hoisted.detectWhatsAppLinked).toHaveBeenCalledWith(expect.any(Object), "work");
});
it("uses configured defaultAccount for omitted-account finalize writes", async () => {