From 558cc44e74e75bb4923f3085d59ce80918878273 Mon Sep 17 00:00:00 2001 From: Shakker Date: Fri, 8 May 2026 21:07:53 +0100 Subject: [PATCH] test: tighten channel readonly assertion --- .../audit-channel-readonly-resolution.test.ts | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/security/audit-channel-readonly-resolution.test.ts b/src/security/audit-channel-readonly-resolution.test.ts index a53ab13a546..872eda225d9 100644 --- a/src/security/audit-channel-readonly-resolution.test.ts +++ b/src/security/audit-channel-readonly-resolution.test.ts @@ -31,6 +31,19 @@ function stubChannelPlugin(params: { }; } +function requireReadOnlyResolutionFinding( + findings: Awaited>, +) { + const finding = findings.find( + (entry) => entry.checkId === "channels.zalouser.account.read_only_resolution", + ); + expect(finding).toBeDefined(); + if (!finding) { + throw new Error("Expected Zalo read-only resolution warning"); + } + return finding; +} + describe("security audit channel read-only resolution", () => { it("adds a read-only resolution warning when channel account resolveAccount throws", async () => { const plugin = stubChannelPlugin({ @@ -54,12 +67,10 @@ describe("security audit channel read-only resolution", () => { plugins: [plugin], }); - const finding = findings.find( - (entry) => entry.checkId === "channels.zalouser.account.read_only_resolution", - ); - expect(finding?.severity).toBe("warn"); - expect(finding?.title).toContain("could not be fully resolved"); - expect(finding?.detail).toContain("zalouser:default: failed to resolve account"); - expect(finding?.detail).toContain("missing SecretRef"); + const finding = requireReadOnlyResolutionFinding(findings); + expect(finding.severity).toBe("warn"); + expect(finding.title).toContain("could not be fully resolved"); + expect(finding.detail).toContain("zalouser:default: failed to resolve account"); + expect(finding.detail).toContain("missing SecretRef"); }); });