mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 15:20:45 +00:00
test: tighten zalo setup assertions
This commit is contained in:
@@ -60,9 +60,14 @@ describe("zalo setup wizard", () => {
|
||||
});
|
||||
|
||||
expect(result.accountId).toBe("default");
|
||||
expect(result.cfg.channels?.zalo?.enabled).toBe(true);
|
||||
expect(result.cfg.channels?.zalo?.botToken).toBe("12345689:abc-xyz");
|
||||
expect(result.cfg.channels?.zalo?.webhookUrl).toBeUndefined();
|
||||
const zaloConfig = result.cfg.channels?.zalo;
|
||||
expect(zaloConfig).toBeDefined();
|
||||
if (!zaloConfig) {
|
||||
throw new Error("expected Zalo config");
|
||||
}
|
||||
expect(zaloConfig.enabled).toBe(true);
|
||||
expect(zaloConfig.botToken).toBe("12345689:abc-xyz");
|
||||
expect(zaloConfig.webhookUrl).toBeUndefined();
|
||||
});
|
||||
|
||||
it("reads the named-account DM policy instead of the channel root", () => {
|
||||
@@ -117,11 +122,20 @@ describe("zalo setup wizard", () => {
|
||||
});
|
||||
|
||||
const next = zaloDmPolicy.setPolicy(cfg, "open");
|
||||
expect(next.channels?.zalo?.dmPolicy).toBe("disabled");
|
||||
const zaloConfig = next.channels?.zalo;
|
||||
expect(zaloConfig).toBeDefined();
|
||||
if (!zaloConfig) {
|
||||
throw new Error("expected Zalo config");
|
||||
}
|
||||
expect(zaloConfig.dmPolicy).toBe("disabled");
|
||||
const workAccount = next.channels?.zalo?.accounts?.work as
|
||||
| { dmPolicy?: string; allowFrom?: Array<string | number> }
|
||||
| undefined;
|
||||
expect(workAccount?.dmPolicy).toBe("open");
|
||||
expect(workAccount).toBeDefined();
|
||||
if (!workAccount) {
|
||||
throw new Error("expected Zalo work account");
|
||||
}
|
||||
expect(workAccount.dmPolicy).toBe("open");
|
||||
});
|
||||
|
||||
it('writes open policy state to the named account and preserves inherited allowFrom with "*"', () => {
|
||||
@@ -142,12 +156,21 @@ describe("zalo setup wizard", () => {
|
||||
"work",
|
||||
);
|
||||
|
||||
expect(next.channels?.zalo?.dmPolicy).toBeUndefined();
|
||||
const zaloConfig = next.channels?.zalo;
|
||||
expect(zaloConfig).toBeDefined();
|
||||
if (!zaloConfig) {
|
||||
throw new Error("expected Zalo config");
|
||||
}
|
||||
expect(zaloConfig.dmPolicy).toBeUndefined();
|
||||
const workAccount = next.channels?.zalo?.accounts?.work as
|
||||
| { dmPolicy?: string; allowFrom?: Array<string | number> }
|
||||
| undefined;
|
||||
expect(workAccount?.dmPolicy).toBe("open");
|
||||
expect(workAccount?.allowFrom).toEqual(["123456789", "*"]);
|
||||
expect(workAccount).toBeDefined();
|
||||
if (!workAccount) {
|
||||
throw new Error("expected Zalo work account");
|
||||
}
|
||||
expect(workAccount.dmPolicy).toBe("open");
|
||||
expect(workAccount.allowFrom).toEqual(["123456789", "*"]);
|
||||
});
|
||||
|
||||
it("uses configured defaultAccount for omitted setup configured state", async () => {
|
||||
|
||||
Reference in New Issue
Block a user