Skip to content

Commit 0db5a1a

Browse files
committed
test(imessage): keep replay proof at durable owner
1 parent ed1c1e7 commit 0db5a1a

3 files changed

Lines changed: 5 additions & 53 deletions

File tree

‎extensions/imessage/src/approval-reactions.test.ts‎

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,49 +1077,6 @@ describe("iMessage approval reactions", () => {
10771077
).resolves.toBeNull();
10781078
});
10791079

1080-
it("propagates transient Gateway errors for durable ingress retry", async () => {
1081-
registerIMessageApprovalReactionTarget({
1082-
accountId: "default",
1083-
conversation: { handle: "+15551230000" },
1084-
messageId: "pending-approval",
1085-
approvalId: "exec-pending",
1086-
allowedDecisions: ["allow-once", "deny"],
1087-
});
1088-
const gatewayError = new Error("Gateway 503 Service Unavailable");
1089-
resolverMocks.resolveApprovalOverGateway.mockRejectedValueOnce(gatewayError);
1090-
resolverMocks.isApprovalNotFoundError.mockReturnValue(false);
1091-
1092-
// Transient errors must throw so the durable ingress drain releases the
1093-
// claim and replays the reaction; committing or dropping it here would
1094-
// lose the operator's click.
1095-
await expect(
1096-
maybeResolveIMessageApprovalReaction({
1097-
cfg: {
1098-
channels: { imessage: { allowFrom: ["+15551230000"] } },
1099-
},
1100-
accountId: "default",
1101-
message: buildTapbackReactionPayload({
1102-
sender: "+15551230000",
1103-
reaction_emoji: "👍",
1104-
reacted_to_guid: "pending-approval",
1105-
}),
1106-
bodyText: "",
1107-
}),
1108-
).rejects.toBe(gatewayError);
1109-
expect(resolverMocks.resolveApprovalOverGateway).toHaveBeenCalledWith(
1110-
expect.objectContaining({ approvalId: "exec-pending" }),
1111-
);
1112-
// The binding should NOT be cleared yet (not-found is the terminal case).
1113-
await expect(
1114-
resolveIMessageApprovalReactionTargetWithPersistence({
1115-
accountId: "default",
1116-
conversation: { handle: "+15551230000" },
1117-
messageId: "pending-approval",
1118-
reactionKey: "👍",
1119-
}),
1120-
).resolves.toBeTruthy();
1121-
});
1122-
11231080
it("clears a losing surface and reports the canonical first-answer outcome", async () => {
11241081
registerIMessageApprovalReactionTarget({
11251082
accountId: "default",

‎extensions/imessage/src/approval-reactions.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,8 @@ export async function handleIMessageApprovalReaction(params: {
593593
params.logVerboseMessage?.(
594594
`imessage: approval reaction failed id=${target.approvalId} sender=${event.actorHandle}: ${String(error)}`,
595595
);
596-
// A transient Gateway 5xx/network/auth error is not terminal: propagate it
597-
// so the durable ingress drain releases the claim and replays the reaction
598-
// under its retry policy, as the signal (#130134) and matrix (#129879)
599-
// owners do. Returning any result here would commit or drop the claim.
596+
// Non-terminal resolver errors must reach the durable ingress drain.
597+
// Returning here would commit the claim and lose the operator's reaction.
600598
throw error;
601599
}
602600
}

‎extensions/imessage/src/monitor.approval-reaction-replay.test.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44
// Everything here is real (SQLite queue, monitor, drain, approval-reaction
55
// resolution) except the one true external boundary: the Gateway
66
// approval-resolution call.
7-
import fs from "node:fs/promises";
8-
import os from "node:os";
9-
import path from "node:path";
107
import {
118
closeOpenClawStateDatabaseForTest,
129
createChannelIngressQueueForTests,
1310
} from "openclaw/plugin-sdk/plugin-state-test-runtime";
11+
import { useAutoCleanupTempDirTracker } from "openclaw/plugin-sdk/test-env";
1412
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
1513
import {
1614
clearIMessageApprovalReactionTargetsForTest,
@@ -58,10 +56,10 @@ afterEach(() => {
5856
closeOpenClawStateDatabaseForTest();
5957
vi.restoreAllMocks();
6058
});
59+
const tempDirs = useAutoCleanupTempDirTracker(afterEach);
6160

6261
async function withQueue<T>(fn: (queue: IMessageIngressQueue) => Promise<T>): Promise<T> {
63-
const created = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-imessage-ingress-replay-"));
64-
const stateDir = await fs.realpath(created);
62+
const stateDir = tempDirs.make("openclaw-imessage-ingress-replay-");
6563
const queue = createChannelIngressQueueForTests<IMessageIngressPayload>({
6664
channelId: "imessage",
6765
accountId: "default",
@@ -71,7 +69,6 @@ async function withQueue<T>(fn: (queue: IMessageIngressQueue) => Promise<T>): Pr
7169
return await fn(queue);
7270
} finally {
7371
closeOpenClawStateDatabaseForTest();
74-
await fs.rm(stateDir, { recursive: true, force: true });
7572
}
7673
}
7774

0 commit comments

Comments
 (0)