Skip to content

Commit

Permalink
fix/tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ishpaul777 committed Aug 18, 2024
1 parent 4c41990 commit 8504a1d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ function isSystemChat(report: OnyxEntry<Report>): boolean {
return getChatType(report) === CONST.REPORT.CHAT_TYPE.SYSTEM;
}

function getDefaultNotificationPreferenceForReport(report: OnyxEntry<Report>) {
function getDefaultNotificationPreferenceForReport(report: OnyxEntry<Report>): ValueOf<typeof CONST.REPORT.NOTIFICATION_PREFERENCE> {
if (isAnnounceRoom(report)) {
return CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS;
}
Expand All @@ -1172,7 +1172,7 @@ function getDefaultNotificationPreferenceForReport(report: OnyxEntry<Report>) {
/**
* Get the notification preference given a report
*/
function getReportNotificationPreference(report: OnyxEntry<Report>) {
function getReportNotificationPreference(report: OnyxEntry<Report>): ValueOf<typeof CONST.REPORT.NOTIFICATION_PREFERENCE> {
return report?.participants?.[currentUserAccountID ?? -1]?.notificationPreference ?? getDefaultNotificationPreferenceForReport(report);
}

Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3009,8 +3009,8 @@ function clearAddRoomMemberError(reportID: string, invitedAccountID: string) {

function updateGroupChatMemberRoles(reportID: string, accountIDList: number[], role: ValueOf<typeof CONST.REPORT.ROLE>) {
const memberRoles: Record<number, string> = {};
const optimisticParticipants: Record<number, Partial<Participant>> = {};
const successParticipants: Record<number, Partial<Participant>> = {};
const optimisticParticipants: Record<number, Partial<ReportParticipant>> = {};
const successParticipants: Record<number, Partial<ReportParticipant>> = {};

accountIDList.forEach((accountID) => {
memberRoles[accountID] = role;
Expand Down
20 changes: 10 additions & 10 deletions tests/actions/IOUTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ describe('actions/IOU', () => {
transactionThread = transactionThreadReport;

expect(iouReport?.participants).toBe({
[RORY_ACCOUNT_ID]: {notification: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN},
[CARLOS_ACCOUNT_ID]: {notification: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN},
[RORY_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN},
[CARLOS_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN},
});

// They should be linked together
Expand Down Expand Up @@ -297,8 +297,8 @@ describe('actions/IOU', () => {
iouReportID = iouReport?.reportID;

expect(iouReport?.participants).toBe({
[RORY_ACCOUNT_ID]: {notification: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN},
[CARLOS_ACCOUNT_ID]: {notification: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN},
[RORY_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN},
[CARLOS_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN},
});

// They should be linked together
Expand Down Expand Up @@ -644,10 +644,10 @@ describe('actions/IOU', () => {
const iouReport = iouReports[0];
iouReportID = iouReport?.reportID;

expect(chatReport?.participants).toEqual({[RORY_ACCOUNT_ID]: RORY_PARTICIPANT, [CARLOS_ACCOUNT_ID]: CARLOS_PARTICIPANT});
expect(chatReport?.participants).toStrictEqual({[RORY_ACCOUNT_ID]: RORY_PARTICIPANT, [CARLOS_ACCOUNT_ID]: CARLOS_PARTICIPANT});

// They should be linked together
expect(chatReport?.participants).toEqual({[RORY_ACCOUNT_ID]: RORY_PARTICIPANT, [CARLOS_ACCOUNT_ID]: CARLOS_PARTICIPANT});
expect(chatReport?.participants).toStrictEqual({[RORY_ACCOUNT_ID]: RORY_PARTICIPANT, [CARLOS_ACCOUNT_ID]: CARLOS_PARTICIPANT});
expect(chatReport?.iouReportID).toBe(iouReport?.reportID);

resolve();
Expand Down Expand Up @@ -1165,7 +1165,7 @@ describe('actions/IOU', () => {
// The 1:1 chat reports and the IOU reports should be linked together
expect(carlosChatReport?.iouReportID).toBe(carlosIOUReport?.reportID);
expect(carlosIOUReport?.chatReportID).toBe(carlosChatReport?.reportID);
expect(carlosIOUReport?.participants).toBe({[CARLOS_ACCOUNT_ID]: CARLOS_PARTICIPANT});
expect(carlosIOUReport?.participants).toStrictEqual({[CARLOS_ACCOUNT_ID]: CARLOS_PARTICIPANT});

expect(julesChatReport?.iouReportID).toBe(julesIOUReport?.reportID);
expect(julesIOUReport?.chatReportID).toBe(julesChatReport?.reportID);
Expand Down Expand Up @@ -2442,7 +2442,7 @@ describe('actions/IOU', () => {
// Given a transaction thread
thread = ReportUtils.buildTransactionThread(createIOUAction, iouReport);

expect(thread.participants).toBe({[RORY_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN, role: CONST.REPORT.ROLE.ADMIN}});
expect(thread.participants).toStrictEqual({[RORY_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN, role: CONST.REPORT.ROLE.ADMIN}});

Onyx.connect({
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${thread.reportID}`,
Expand Down Expand Up @@ -2719,7 +2719,7 @@ describe('actions/IOU', () => {
jest.advanceTimersByTime(10);
thread = ReportUtils.buildTransactionThread(createIOUAction, iouReport);

expect(thread.participants).toBe({[RORY_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN, role: CONST.REPORT.ROLE.ADMIN}});
expect(thread.participants).toStrictEqual({[RORY_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN, role: CONST.REPORT.ROLE.ADMIN}});

Onyx.connect({
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${thread.reportID}`,
Expand Down Expand Up @@ -2959,7 +2959,7 @@ describe('actions/IOU', () => {
jest.advanceTimersByTime(10);
thread = ReportUtils.buildTransactionThread(createIOUAction, iouReport);

expect(thread.participants).toBe(CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN);
expect(thread.participants).toStrictEqual({[RORY_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN, role: CONST.REPORT.ROLE.ADMIN}});

Onyx.connect({
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${thread.reportID}`,
Expand Down

0 comments on commit 8504a1d

Please sign in to comment.