@@ -7,7 +7,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
77import { matrixApprovalNativeRuntime } from "./approval-handler.runtime.js" ;
88import {
99 clearMatrixApprovalReactionTargetsForTest ,
10- resolveMatrixApprovalReactionTarget ,
10+ resolveMatrixApprovalReactionTargetWithPersistence ,
1111} from "./approval-reactions.js" ;
1212
1313type MatrixDeliverPendingParams = Parameters <
@@ -72,6 +72,11 @@ function buildMatrixApprovalRoomTarget(
7272 } ;
7373}
7474
75+ // Pending approvals expire in the future; the reaction target store TTLs its
76+ // memory layer from `view.expiresAtMs - now`, so epoch-past fixtures would
77+ // evict the mapping before assertions run.
78+ const TEST_APPROVAL_EXPIRES_AT_MS = Date . now ( ) + 5 * 60_000 ;
79+
7580function buildExecApprovalView (
7681 overrides : Partial < MatrixPendingExecApprovalView > = { } ,
7782) : MatrixPendingExecApprovalView {
@@ -102,7 +107,7 @@ function buildExecApprovalView(
102107 command : "/approve req-1 deny" ,
103108 } ,
104109 ] ,
105- expiresAtMs : 1_000 ,
110+ expiresAtMs : TEST_APPROVAL_EXPIRES_AT_MS ,
106111 ...overrides ,
107112 } ;
108113}
@@ -129,7 +134,7 @@ function buildPluginApprovalView(
129134 command : "/approve plugin:req-1 allow-once" ,
130135 } ,
131136 ] ,
132- expiresAtMs : 1_000 ,
137+ expiresAtMs : TEST_APPROVAL_EXPIRES_AT_MS ,
133138 ...overrides ,
134139 } ;
135140}
@@ -273,7 +278,7 @@ describe("matrixApprovalNativeRuntime", () => {
273278 kind : "plugin" ,
274279 title : "Plugin Approval Required" ,
275280 description : "Approve the tool call." ,
276- expiresAtMs : 1_000 ,
281+ expiresAtMs : TEST_APPROVAL_EXPIRES_AT_MS ,
277282 metadata : [ ] ,
278283 allowedDecisions : [ "allow-once" ] ,
279284 actions : [
@@ -304,7 +309,7 @@ describe("matrixApprovalNativeRuntime", () => {
304309 } ) ;
305310 const reactMessage = vi . fn ( ) . mockImplementation ( async ( ) => {
306311 expect (
307- resolveMatrixApprovalReactionTarget ( {
312+ await resolveMatrixApprovalReactionTargetWithPersistence ( {
308313 roomId : "!room:example.org" ,
309314 eventId : "$approval" ,
310315 reactionKey : "✅" ,
@@ -510,7 +515,7 @@ describe("matrixApprovalNativeRuntime", () => {
510515 eventId : "$primary" ,
511516 } ) ;
512517 expect (
513- resolveMatrixApprovalReactionTarget ( {
518+ await resolveMatrixApprovalReactionTargetWithPersistence ( {
514519 roomId : "!room:example.org" ,
515520 eventId : "$primary" ,
516521 reactionKey : "✅" ,
@@ -520,7 +525,7 @@ describe("matrixApprovalNativeRuntime", () => {
520525 decision : "allow-once" ,
521526 } ) ;
522527 expect (
523- resolveMatrixApprovalReactionTarget ( {
528+ await resolveMatrixApprovalReactionTargetWithPersistence ( {
524529 roomId : "!room:example.org" ,
525530 eventId : "$last" ,
526531 reactionKey : "✅" ,
0 commit comments