mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 04:30:42 +00:00
test(ci): align channel defaults and clean stale hook tests
This commit is contained in:
@@ -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");
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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", "*"]);
|
||||
});
|
||||
|
||||
@@ -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", "*"]);
|
||||
});
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user