Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 9 additions & 39 deletions tests/unit/SidebarUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -907,29 +907,11 @@ describe('SidebarUtils', () => {
expect(result?.alternateText).toBe(`You invited 1 member`);
});
it('returns the last action message as an alternate text if the action is MOVED type', async () => {
// When a report has last action of MOVED type
const policy: Policy = {
...createRandomPolicy(1),
pendingAction: null,
};
const session = {
authToken: 'sensitive-auth-token',
encryptedAuthToken: 'sensitive-encrypted-token',
email: 'user@example.com',
accountID: 12345,
};
const report: Report = {
...createRandomReport(4),
chatType: 'policyRoom',
lastMessageHtml: '',
lastMessageText: '',
lastVisibleActionCreated: '2025-04-27 12:30:03.784',
participants: {
'12345': {
notificationPreference: 'daily',
},
},
policyID: '1',
chatType: 'policyExpenseChat',
pendingAction: null,
isOwnPolicyExpenseChat: true,
};
const lastAction: ReportAction = {
...createRandomReportAction(2),
Expand All @@ -938,31 +920,20 @@ describe('SidebarUtils', () => {
type: 'COMMENT',
html: "moved this report to the <a href='https://new.expensify.com/r/1325702002189143' target='_blank' rel='noreferrer noopener'>Three&#039;s Workspace</a> workspace",
text: "moved this report to the Three's Workspace workspace",
isEdited: false,
whisperedTo: [],
isDeletedParentAction: false,
deleted: '',
},
],
originalMessage: {
lastModified: '2025-04-27 12:32:10.416',
targetAccountIDs: [19268914],
whisperedTo: [],
},
actorAccountID: 12345,
actionName: CONST.REPORT.ACTIONS.TYPE.MOVED,
person: [
{
type: 'TEXT',
style: 'strong',
text: 'f50',
},
],
created: DateUtils.getDBTime(),
lastModified: DateUtils.getDBTime(),
shouldShow: true,
pendingAction: null,
};
const reportActions: ReportActions = {[lastAction.reportActionID]: lastAction};
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, report);
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, reportActions);
await Onyx.set(ONYXKEYS.SESSION, session);
await Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}1`, policy);
const result = SidebarUtils.getOptionData({
report,
reportAttributes: {},
Expand All @@ -976,8 +947,7 @@ describe('SidebarUtils', () => {
oneTransactionThreadReport: undefined,
});

// Then the alternate text should be equal to the message of the last action prepended with the last actor display name.
expect(result?.alternateText).toBe(`${lastAction.person?.[0].text}: ${getReportActionMessageText(lastAction)}`);
expect(result?.alternateText).toBe(`You: ${getReportActionMessageText(lastAction)}`);
});
});
});
Expand Down