test: add cross-provider approval availability coverage (#59776) (thanks @joelnishanth)

This commit is contained in:
Peter Steinberger 2026-04-02 18:09:08 +01:00
parent d5865bbcc2
commit 2ea0ca08f6
3 changed files with 85 additions and 0 deletions

View File

@ -95,6 +95,7 @@ Docs: https://docs.openclaw.ai
- Telegram/exec approvals: fall back to the origin session key for async approval followups and keep resume-failure status delivery sanitized so Telegram followups still land without leaking raw exec metadata. (#59351) Thanks @seonang.
- Node-host/exec approvals: bind `pnpm dlx` invocations through the approval planner's mutable-script path so the effective runtime command is resolved for approval instead of being left unbound. (#58374)
- Exec/node hosts: stop forwarding the gateway workspace cwd to remote node exec when no workdir was explicitly requested, so cross-platform node approvals fall back to the node default cwd instead of failing with `SYSTEM_RUN_DENIED`. (#58977) Thanks @Starhappysh.
- Exec approvals/channels: decouple initiating-surface approval availability from native delivery enablement so Telegram, Slack, and Discord still expose approvals when approvers exist and native target routing is configured separately. (#59776) Thanks @joelnishanth.
## 2026.4.2

View File

@ -21,6 +21,47 @@ function writeStore(store: Record<string, unknown>) {
}
describe("createDiscordNativeApprovalAdapter", () => {
it("keeps approval availability enabled when approvers exist but native delivery is off", () => {
const adapter = createDiscordNativeApprovalAdapter({
enabled: false,
approvers: ["555555555"],
target: "channel",
} as never);
expect(
adapter.auth?.getActionAvailabilityState?.({
cfg: NATIVE_APPROVAL_CFG as never,
accountId: "main",
action: "approve",
}),
).toEqual({ kind: "enabled" });
expect(
adapter.native?.describeDeliveryCapabilities({
cfg: NATIVE_APPROVAL_CFG as never,
accountId: "main",
approvalKind: "exec",
request: {
id: "approval-1",
request: {
command: "pwd",
turnSourceChannel: "discord",
turnSourceTo: "channel:123456789",
turnSourceAccountId: "main",
sessionKey: "agent:main:discord:channel:123456789",
},
createdAtMs: 1,
expiresAtMs: 2,
},
}),
).toEqual({
enabled: false,
preferredSurface: "origin",
supportsOriginSurface: true,
supportsApproverDmSurface: true,
notifyOriginWhenDmOnly: true,
});
});
it("honors ownerAllowFrom fallback when gating approval requests", () => {
expect(
shouldHandleDiscordApprovalRequest({

View File

@ -33,6 +33,49 @@ function writeStore(store: Record<string, unknown>) {
}
describe("slack native approval adapter", () => {
it("keeps approval availability enabled when approvers exist but native delivery is off", () => {
const cfg = buildConfig({
execApprovals: {
enabled: false,
approvers: ["U123APPROVER"],
target: "channel",
},
});
expect(
slackNativeApprovalAdapter.auth?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",
}),
).toEqual({ kind: "enabled" });
expect(
slackNativeApprovalAdapter.native?.describeDeliveryCapabilities({
cfg,
accountId: "default",
approvalKind: "exec",
request: {
id: "req-disabled-1",
request: {
command: "echo hi",
turnSourceChannel: "slack",
turnSourceTo: "channel:C123",
turnSourceAccountId: "default",
sessionKey: "agent:main:slack:channel:c123",
},
createdAtMs: 0,
expiresAtMs: 1000,
},
}),
).toEqual({
enabled: false,
preferredSurface: "origin",
supportsOriginSurface: true,
supportsApproverDmSurface: true,
notifyOriginWhenDmOnly: true,
});
});
it("describes native slack approval delivery capabilities", () => {
const capabilities = slackNativeApprovalAdapter.native?.describeDeliveryCapabilities({
cfg: buildConfig(),