Skip to content

Commit 7ae30ad

Browse files
yuwenmemonclaude
andcommitted
test: add coverage for getIntegrationSyncFailedMessage recurrenceCount
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ad8a897 commit 7ae30ad

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

tests/unit/ReportActionsUtilsTest.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {actionR14932 as mockIOUAction, originalMessageR14932 as mockOriginalMess
1111
import {chatReportR14932 as mockChatReport, iouReportR14932 as mockIOUReport} from '../../__mocks__/reportData/reports';
1212
import CONST from '../../src/CONST';
1313
import * as ReportActionsUtils from '../../src/libs/ReportActionsUtils';
14+
import {getIntegrationSyncFailedMessage} from '../../src/libs/ReportActionsUtils';
1415
import {
1516
findLastReportActions,
1617
getAddedCardFeedMessage,
@@ -5043,4 +5044,67 @@ describe('ReportActionsUtils', () => {
50435044
).toBe(false);
50445045
});
50455046
});
5047+
5048+
describe('getIntegrationSyncFailedMessage', () => {
5049+
const testPolicyID = 'test-policy-123';
5050+
5051+
it('should render message without recurrence text when recurrenceCount is absent', () => {
5052+
const action = {
5053+
actionName: CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED,
5054+
reportActionID: 'sync-fail-1',
5055+
actorAccountID: 1,
5056+
created: '2024-01-01',
5057+
message: [],
5058+
originalMessage: {
5059+
label: 'QuickBooks Online',
5060+
source: 'NEWEXPENSIFY',
5061+
errorMessage: 'Auth token expired',
5062+
},
5063+
} as ReportAction;
5064+
5065+
const result = getIntegrationSyncFailedMessage(translateLocal, action, testPolicyID);
5066+
expect(result).toContain('Auth token expired');
5067+
expect(result).not.toContain('Repeated');
5068+
});
5069+
5070+
it('should append recurrence text when recurrenceCount > 1', () => {
5071+
const action = {
5072+
actionName: CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED,
5073+
reportActionID: 'sync-fail-2',
5074+
actorAccountID: 1,
5075+
created: '2024-01-01',
5076+
message: [],
5077+
originalMessage: {
5078+
label: 'NetSuite',
5079+
source: 'AUTOSYNC',
5080+
errorMessage: 'Login Error',
5081+
recurrenceCount: 3,
5082+
},
5083+
} as ReportAction;
5084+
5085+
const result = getIntegrationSyncFailedMessage(translateLocal, action, testPolicyID);
5086+
expect(result).toContain('Login Error');
5087+
expect(result).toContain('Repeated 3 times');
5088+
});
5089+
5090+
it('should not append recurrence text when recurrenceCount is 1', () => {
5091+
const action = {
5092+
actionName: CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED,
5093+
reportActionID: 'sync-fail-3',
5094+
actorAccountID: 1,
5095+
created: '2024-01-01',
5096+
message: [],
5097+
originalMessage: {
5098+
label: 'Xero',
5099+
source: 'NEWEXPENSIFY',
5100+
errorMessage: 'Rate limit',
5101+
recurrenceCount: 1,
5102+
},
5103+
} as ReportAction;
5104+
5105+
const result = getIntegrationSyncFailedMessage(translateLocal, action, testPolicyID);
5106+
expect(result).toContain('Rate limit');
5107+
expect(result).not.toContain('Repeated');
5108+
});
5109+
});
50465110
});

0 commit comments

Comments
 (0)