From 2014618e4aa8aa113965a7c804ad635562ee309f Mon Sep 17 00:00:00 2001 From: TaduJR Date: Sun, 11 Jan 2026 20:57:52 +0300 Subject: [PATCH] fix: resolve flaky CANCEL_PAYMENT tests due to NACHA cutoff timing --- tests/unit/ReportSecondaryActionUtilsTest.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/unit/ReportSecondaryActionUtilsTest.ts b/tests/unit/ReportSecondaryActionUtilsTest.ts index 0bc1dd2ba3efe..f85453cc694d8 100644 --- a/tests/unit/ReportSecondaryActionUtilsTest.ts +++ b/tests/unit/ReportSecondaryActionUtilsTest.ts @@ -897,6 +897,9 @@ describe('getSecondaryAction', () => { const TRANSACTION_ID = 'transaction_id'; await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, report); + // Use tomorrow's date to ensure we're always before the NACHA cutoff (23:45 UTC) + const tomorrow = new Date(); + tomorrow.setDate(tomorrow.getDate() + 1); const ACTION_ID = 'action_id'; const reportAction = { actionID: ACTION_ID, @@ -905,7 +908,7 @@ describe('getSecondaryAction', () => { IOUTransactionID: TRANSACTION_ID, type: CONST.IOU.REPORT_ACTION_TYPE.PAY, }, - created: new Date().toISOString(), + created: tomorrow.toISOString(), } as unknown as ReportAction; await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, {[ACTION_ID]: reportAction}); @@ -943,6 +946,9 @@ describe('getSecondaryAction', () => { const TRANSACTION_ID = 'transaction_id'; await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, report); + // Use tomorrow's date to ensure we're always before the NACHA cutoff (23:45 UTC) + const tomorrow = new Date(); + tomorrow.setDate(tomorrow.getDate() + 1); const ACTION_ID = 'action_id'; const reportAction = { actionID: ACTION_ID, @@ -952,7 +958,7 @@ describe('getSecondaryAction', () => { type: CONST.IOU.REPORT_ACTION_TYPE.PAY, paymentType: CONST.IOU.PAYMENT_TYPE.VBBA, }, - created: new Date().toISOString(), + created: tomorrow.toISOString(), } as unknown as ReportAction; await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, {[ACTION_ID]: reportAction}); @@ -990,6 +996,9 @@ describe('getSecondaryAction', () => { const TRANSACTION_ID = 'transaction_id'; await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, report); + // Use tomorrow's date to ensure we're always before the NACHA cutoff (23:45 UTC) + const tomorrow = new Date(); + tomorrow.setDate(tomorrow.getDate() + 1); const ACTION_ID = 'action_id'; const reportAction = { actionID: ACTION_ID, @@ -999,7 +1008,7 @@ describe('getSecondaryAction', () => { type: CONST.IOU.REPORT_ACTION_TYPE.PAY, paymentType: CONST.IOU.PAYMENT_TYPE.VBBA, }, - created: new Date().toISOString(), + created: tomorrow.toISOString(), } as unknown as ReportAction; await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, {[ACTION_ID]: reportAction}); @@ -1037,6 +1046,9 @@ describe('getSecondaryAction', () => { const TRANSACTION_ID = 'transaction_id'; await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, report); + // Use tomorrow's date to ensure we're always before the NACHA cutoff (23:45 UTC) + const tomorrow = new Date(); + tomorrow.setDate(tomorrow.getDate() + 1); const ACTION_ID = 'action_id'; const reportAction = { actionID: ACTION_ID, @@ -1046,7 +1058,7 @@ describe('getSecondaryAction', () => { type: CONST.IOU.REPORT_ACTION_TYPE.PAY, paymentType: CONST.IOU.PAYMENT_TYPE.VBBA, }, - created: new Date().toISOString(), + created: tomorrow.toISOString(), } as unknown as ReportAction; await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, {[ACTION_ID]: reportAction});