


























@@ -156,9 +156,88 @@ describe("WhatsApp QA live runtime", () => {
156156expect(scenarios.map(({ id }) => id)).toEqual(["whatsapp-canary", "whatsapp-pairing-block"]);
157157});
158158159+it("reports standard WhatsApp live transport scenario coverage", () => {
160+expect(testing.WHATSAPP_QA_STANDARD_SCENARIO_IDS).toEqual([
161+"canary",
162+"allowlist-block",
163+"mention-gating",
164+]);
165+});
166+167+it("keeps native approval scenarios out of default WhatsApp selection", () => {
168+const expectedDefaultIds = [
169+"whatsapp-canary",
170+"whatsapp-pairing-block",
171+"whatsapp-mention-gating",
172+];
173+174+expect(testing.findScenarios().map(({ id }) => id)).toEqual(expectedDefaultIds);
175+expect(testing.findScenarios([]).map(({ id }) => id)).toEqual(expectedDefaultIds);
176+});
177+178+it("selects native approval scenarios by id without changing standard coverage", () => {
179+const scenarios = testing.findScenarios([
180+"whatsapp-approval-exec-native",
181+"whatsapp-approval-plugin-native",
182+]);
183+184+expect(scenarios.map(({ id }) => id)).toEqual([
185+"whatsapp-approval-exec-native",
186+"whatsapp-approval-plugin-native",
187+]);
188+expect(testing.WHATSAPP_QA_STANDARD_SCENARIO_IDS).not.toContain(
189+"whatsapp-approval-exec-native",
190+);
191+expect(scenarios.map((scenario) => scenario.buildRun().kind)).toEqual(["approval", "approval"]);
192+});
193+194+it("enables WhatsApp native exec and plugin approval delivery for approval scenarios", () => {
195+const cfg = testing.buildWhatsAppQaConfig(
196+{},
197+{
198+allowFrom: ["+15550000001"],
199+authDir: "/tmp/openclaw-whatsapp-qa-auth",
200+dmPolicy: "allowlist",
201+overrides: {
202+approvals: {
203+exec: true,
204+plugin: true,
205+},
206+},
207+sutAccountId: "sut",
208+},
209+);
210+211+expect(cfg.approvals?.exec).toEqual({ enabled: true, mode: "session" });
212+expect(cfg.approvals?.plugin).toEqual({ enabled: true, mode: "session" });
213+const account = cfg.channels?.whatsapp?.accounts?.sut;
214+expect(account?.allowFrom).toEqual(["+15550000001"]);
215+expect(account).not.toHaveProperty("execApprovals");
216+});
217+218+it("matches native approval resolved text emitted by the WhatsApp approval handler", () => {
219+expect(
220+testing.matchesWhatsAppApprovalResolvedText({
221+approvalId: "whatsapp-qa-exec-123",
222+approvalKind: "exec",
223+text: "✅ Exec approval allow-once. ID: whatsapp-qa-exec-123",
224+}),
225+).toBe(true);
226+expect(
227+testing.matchesWhatsAppApprovalResolvedText({
228+approvalId: "whatsapp-qa-plugin-123",
229+approvalKind: "plugin",
230+text: "✅ Plugin approval allowed once. ID: whatsapp-qa-plugin-123",
231+}),
232+).toBe(true);
233+});
234+159235it("uses automatic visible replies for WhatsApp group mention gating", () => {
160236const [scenario] = testing.findScenarios(["whatsapp-mention-gating"]);
161237const scenarioRun = scenario.buildRun();
238+if (scenarioRun.kind === "approval") {
239+throw new Error("whatsapp-mention-gating unexpectedly built an approval scenario run");
240+}
162241expect(scenarioRun.input).toContain("openclawqa reply with only this exact marker");
163242expect(scenarioRun.input).not.toContain("visible reply tool check");
164243此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。