Skip to content

Commit 791fe80

Browse files
committed
fix UTs
1 parent 76fc90d commit 791fe80

5 files changed

Lines changed: 50 additions & 51 deletions

File tree

src/libs/DateUtils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import Onyx from 'react-native-onyx';
3636
import type {ValueOf} from 'type-fest';
3737
import type {LocaleContextProps} from '@components/LocaleContextProvider';
3838
import CONST from '@src/CONST';
39-
import IntlStore from '@src/languages/IntlStore';
4039
import ONYXKEYS from '@src/ONYXKEYS';
4140
import {timezoneBackwardToNewMap, timezoneNewToBackwardMap} from '@src/TIMEZONES';
4241
import type Locale from '@src/types/onyx/Locale';

tests/actions/IOUTest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3731,7 +3731,7 @@ describe('actions/IOU', () => {
37313731
jest.advanceTimersByTime(10);
37323732

37333733
// When a comment is added
3734-
addComment(thread.reportID, 'Testing a comment');
3734+
addComment(thread.reportID, 'Testing a comment', CONST.DEFAULT_TIME_ZONE);
37353735
await waitForBatchedUpdates();
37363736

37373737
// Then comment details should match the expected report action
@@ -3829,7 +3829,7 @@ describe('actions/IOU', () => {
38293829

38303830
jest.advanceTimersByTime(10);
38313831

3832-
addComment(thread.reportID, 'Testing a comment');
3832+
addComment(thread.reportID, 'Testing a comment', CONST.DEFAULT_TIME_ZONE);
38333833
await waitForBatchedUpdates();
38343834

38353835
// Fetch the updated IOU Action from Onyx due to addition of comment to transaction thread.
@@ -3878,7 +3878,7 @@ describe('actions/IOU', () => {
38783878
jest.advanceTimersByTime(10);
38793879

38803880
if (IOU_REPORT_ID) {
3881-
addComment(IOU_REPORT_ID, 'Testing a comment');
3881+
addComment(IOU_REPORT_ID, 'Testing a comment', CONST.DEFAULT_TIME_ZONE);
38823882
}
38833883
await waitForBatchedUpdates();
38843884

tests/actions/ReportTest.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ describe('actions/Report', () => {
140140
.then(() => {
141141
// This is a fire and forget response, but once it completes we should be able to verify that we
142142
// have an "optimistic" report action in Onyx.
143-
Report.addComment(REPORT_ID, 'Testing a comment');
143+
Report.addComment(REPORT_ID, 'Testing a comment', CONST.DEFAULT_TIME_ZONE);
144144
return waitForBatchedUpdates();
145145
})
146146
.then(() => {
@@ -270,7 +270,7 @@ describe('actions/Report', () => {
270270
}
271271

272272
// And leave a comment on a report
273-
Report.addComment(REPORT_ID, 'Testing a comment');
273+
Report.addComment(REPORT_ID, 'Testing a comment', CONST.DEFAULT_TIME_ZONE);
274274

275275
// Then we should expect that there is on persisted request
276276
expect(PersistedRequests.getAll().length).toBe(1);
@@ -391,7 +391,7 @@ describe('actions/Report', () => {
391391
// When a new comment is added by the current user
392392

393393
currentTime = DateUtils.getDBTime();
394-
Report.addComment(REPORT_ID, 'Current User Comment 1');
394+
Report.addComment(REPORT_ID, 'Current User Comment 1', CONST.DEFAULT_TIME_ZONE);
395395
return waitForBatchedUpdates();
396396
})
397397
.then(() => {
@@ -403,7 +403,7 @@ describe('actions/Report', () => {
403403

404404
// When another comment is added by the current user
405405
currentTime = DateUtils.getDBTime();
406-
Report.addComment(REPORT_ID, 'Current User Comment 2');
406+
Report.addComment(REPORT_ID, 'Current User Comment 2', CONST.DEFAULT_TIME_ZONE);
407407
return waitForBatchedUpdates();
408408
})
409409
.then(() => {
@@ -414,7 +414,7 @@ describe('actions/Report', () => {
414414

415415
// When another comment is added by the current user
416416
currentTime = DateUtils.getDBTime();
417-
Report.addComment(REPORT_ID, 'Current User Comment 3');
417+
Report.addComment(REPORT_ID, 'Current User Comment 3', CONST.DEFAULT_TIME_ZONE);
418418
return waitForBatchedUpdates();
419419
})
420420
.then(() => {
@@ -679,7 +679,7 @@ describe('actions/Report', () => {
679679
.then(() => {
680680
// This is a fire and forget response, but once it completes we should be able to verify that we
681681
// have an "optimistic" report action in Onyx.
682-
Report.addComment(REPORT_ID, 'Testing a comment');
682+
Report.addComment(REPORT_ID, 'Testing a comment', CONST.DEFAULT_TIME_ZONE);
683683
return waitForBatchedUpdates();
684684
})
685685
.then(() => {
@@ -807,7 +807,7 @@ describe('actions/Report', () => {
807807
.then(() => {
808808
// This is a fire and forget response, but once it completes we should be able to verify that we
809809
// have an "optimistic" report action in Onyx.
810-
Report.addComment(REPORT_ID, 'Testing a comment');
810+
Report.addComment(REPORT_ID, 'Testing a comment', CONST.DEFAULT_TIME_ZONE);
811811
return waitForBatchedUpdates();
812812
})
813813
.then(() => {
@@ -897,7 +897,7 @@ describe('actions/Report', () => {
897897

898898
Onyx.set(ONYXKEYS.NETWORK, {isOffline: true});
899899

900-
Report.addComment(REPORT_ID, 'Testing a comment');
900+
Report.addComment(REPORT_ID, 'Testing a comment', CONST.DEFAULT_TIME_ZONE);
901901
// Need the reportActionID to delete the comments
902902
const newComment = PersistedRequests.getAll().at(0);
903903
const reportActionID = newComment?.data?.reportActionID as string | undefined;
@@ -969,7 +969,7 @@ describe('actions/Report', () => {
969969

970970
await Onyx.set(ONYXKEYS.NETWORK, {isOffline: false});
971971

972-
Report.addComment(REPORT_ID, 'Testing a comment');
972+
Report.addComment(REPORT_ID, 'Testing a comment', CONST.DEFAULT_TIME_ZONE);
973973

974974
// Need the reportActionID to delete the comments
975975
const newComment = PersistedRequests.getAll().at(1);
@@ -1020,7 +1020,7 @@ describe('actions/Report', () => {
10201020
const TEN_MINUTES_AGO = subMinutes(new Date(), 10);
10211021
const created = format(addSeconds(TEN_MINUTES_AGO, 10), CONST.DATE.FNS_DB_FORMAT_STRING);
10221022

1023-
Report.addComment(REPORT_ID, 'Testing a comment');
1023+
Report.addComment(REPORT_ID, 'Testing a comment', CONST.DEFAULT_TIME_ZONE);
10241024
await waitForNetworkPromises();
10251025

10261026
expect(PersistedRequests.getAll().length).toBe(1);
@@ -1069,7 +1069,7 @@ describe('actions/Report', () => {
10691069
await Onyx.set(ONYXKEYS.NETWORK, {isOffline: true});
10701070

10711071
const file = new File([''], 'test.txt', {type: 'text/plain'});
1072-
Report.addAttachment(REPORT_ID, file);
1072+
Report.addAttachment(REPORT_ID, file, CONST.DEFAULT_TIME_ZONE);
10731073

10741074
// Need the reportActionID to delete the comments
10751075
const newComment = PersistedRequests.getAll().at(0);
@@ -1211,7 +1211,7 @@ describe('actions/Report', () => {
12111211
await Onyx.set(ONYXKEYS.NETWORK, {isOffline: true});
12121212
await Promise.resolve();
12131213

1214-
Report.addComment(REPORT_ID, 'reactions with comment');
1214+
Report.addComment(REPORT_ID, 'reactions with comment', CONST.DEFAULT_TIME_ZONE);
12151215
// Need the reportActionID to delete the comments
12161216
const newComment = PersistedRequests.getAll().at(0);
12171217
const reportActionID = newComment?.data?.reportActionID as string | undefined;
@@ -1307,7 +1307,7 @@ describe('actions/Report', () => {
13071307
const TEN_MINUTES_AGO = subMinutes(new Date(), 10);
13081308
const created = format(addSeconds(TEN_MINUTES_AGO, 10), CONST.DATE.FNS_DB_FORMAT_STRING);
13091309

1310-
Report.addComment(REPORT_ID, 'Attachment with comment');
1310+
Report.addComment(REPORT_ID, 'Attachment with comment', CONST.DEFAULT_TIME_ZONE);
13111311

13121312
// Need the reportActionID to delete the comments
13131313
const newComment = PersistedRequests.getAll().at(0);
@@ -1379,7 +1379,7 @@ describe('actions/Report', () => {
13791379
await Onyx.set(ONYXKEYS.NETWORK, {isOffline: true});
13801380
await waitForBatchedUpdates();
13811381

1382-
Report.addComment(REPORT_ID, 'Testing a comment');
1382+
Report.addComment(REPORT_ID, 'Testing a comment', CONST.DEFAULT_TIME_ZONE);
13831383

13841384
const newComment = PersistedRequests.getAll().at(0);
13851385
const reportActionID = newComment?.data?.reportActionID as string | undefined;
@@ -1437,7 +1437,7 @@ describe('actions/Report', () => {
14371437

14381438
Onyx.set(ONYXKEYS.NETWORK, {isOffline: true});
14391439

1440-
Report.addComment(REPORT_ID, 'Testing a comment');
1440+
Report.addComment(REPORT_ID, 'Testing a comment', CONST.DEFAULT_TIME_ZONE);
14411441
// Need the reportActionID to delete the comments
14421442
const newComment = PersistedRequests.getAll().at(0);
14431443
const reportActionID = newComment?.data?.reportActionID as string | undefined;

tests/ui/UnreadIndicatorsTest.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ describe.skip('Unread Indicators', () => {
450450
expect(unreadIndicator).toHaveLength(1);
451451

452452
// Leave a comment as the current user and verify the indicator is removed
453-
addComment(REPORT_ID, 'Current User Comment 1');
453+
addComment(REPORT_ID, 'Current User Comment 1', CONST.DEFAULT_TIME_ZONE);
454454
return waitForBatchedUpdates();
455455
})
456456
.then(() => {
@@ -513,7 +513,7 @@ describe.skip('Unread Indicators', () => {
513513
.then(() => navigateToSidebarOption(0))
514514
.then(() => {
515515
// Leave a comment as the current user
516-
addComment(REPORT_ID, 'Current User Comment 1');
516+
addComment(REPORT_ID, 'Current User Comment 1', CONST.DEFAULT_TIME_ZONE);
517517
return waitForBatchedUpdates();
518518
})
519519
.then(() => {
@@ -558,7 +558,7 @@ describe.skip('Unread Indicators', () => {
558558
await signInAndGetAppWithUnreadChat();
559559
await navigateToSidebarOption(0);
560560

561-
addComment(REPORT_ID, 'Comment 1');
561+
addComment(REPORT_ID, 'Comment 1', CONST.DEFAULT_TIME_ZONE);
562562

563563
await waitForBatchedUpdates();
564564

@@ -569,7 +569,7 @@ describe.skip('Unread Indicators', () => {
569569

570570
await waitForBatchedUpdates();
571571

572-
addComment(REPORT_ID, 'Comment 2');
572+
addComment(REPORT_ID, 'Comment 2', CONST.DEFAULT_TIME_ZONE);
573573

574574
await waitForBatchedUpdates();
575575

tests/unit/SidebarOrderTest.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ describe('Sidebar', () => {
118118
const report3 = LHNTestUtils.getFakeReport([1, 4], 1);
119119

120120
// Each report has at least one ADD_COMMENT action so should be rendered in the LNH
121-
addComment(report1.reportID, 'Hi, this is a comment');
122-
addComment(report2.reportID, 'Hi, this is a comment');
123-
addComment(report3.reportID, 'Hi, this is a comment');
121+
addComment(report1.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
122+
addComment(report2.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
123+
addComment(report3.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
124124

125125
const reportCollectionDataSet: ReportCollectionDataSet = {
126126
[`${ONYXKEYS.COLLECTION.REPORT}${report1.reportID}`]: report1,
@@ -166,9 +166,9 @@ describe('Sidebar', () => {
166166
const report3 = LHNTestUtils.getFakeReport([1, 4], 1);
167167

168168
// Each report has at least one ADD_COMMENT action so should be rendered in the LNH
169-
addComment(report1.reportID, 'Hi, this is a comment');
170-
addComment(report2.reportID, 'Hi, this is a comment');
171-
addComment(report3.reportID, 'Hi, this is a comment');
169+
addComment(report1.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
170+
addComment(report2.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
171+
addComment(report3.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
172172

173173
const currentReportId = report1.reportID;
174174
const reportCollectionDataSet: ReportCollectionDataSet = {
@@ -215,9 +215,9 @@ describe('Sidebar', () => {
215215
const report3 = LHNTestUtils.getFakeReport([1, 4], 1);
216216

217217
// Each report has at least one ADD_COMMENT action so should be rendered in the LNH
218-
addComment(report1.reportID, 'Hi, this is a comment');
219-
addComment(report2.reportID, 'Hi, this is a comment');
220-
addComment(report3.reportID, 'Hi, this is a comment');
218+
addComment(report1.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
219+
addComment(report2.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
220+
addComment(report3.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
221221

222222
const reportCollectionDataSet: ReportCollectionDataSet = {
223223
[`${ONYXKEYS.COLLECTION.REPORT}${report1.reportID}`]: report1,
@@ -276,9 +276,9 @@ describe('Sidebar', () => {
276276
};
277277

278278
// Each report has at least one ADD_COMMENT action so should be rendered in the LNH
279-
addComment(report1.reportID, 'Hi, this is a comment');
280-
addComment(report2.reportID, 'Hi, this is a comment');
281-
addComment(report3.reportID, 'Hi, this is a comment');
279+
addComment(report1.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
280+
addComment(report2.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
281+
addComment(report3.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
282282

283283
const reportCollectionDataSet: ReportCollectionDataSet = {
284284
[`${ONYXKEYS.COLLECTION.REPORT}${report1.reportID}`]: report1,
@@ -350,9 +350,9 @@ describe('Sidebar', () => {
350350
report3.iouReportID = iouReport.reportID;
351351

352352
// Each report has at least one ADD_COMMENT action so should be rendered in the LNH
353-
addComment(report1.reportID, 'Hi, this is a comment');
354-
addComment(report3.reportID, 'Hi, this is a comment');
355-
addComment(report2.reportID, 'Hi, this is a comment');
353+
addComment(report1.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
354+
addComment(report3.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
355+
addComment(report2.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
356356

357357
const reportCollectionDataSet: ReportCollectionDataSet = {
358358
[`${ONYXKEYS.COLLECTION.REPORT}${report1.reportID}`]: report1,
@@ -429,9 +429,9 @@ describe('Sidebar', () => {
429429
report3.iouReportID = expenseReport.reportID;
430430

431431
// Each report has at least one ADD_COMMENT action so should be rendered in the LNH
432-
addComment(report1.reportID, 'Hi, this is a comment');
433-
addComment(report3.reportID, 'Hi, this is a comment');
434-
addComment(report2.reportID, 'Hi, this is a comment');
432+
addComment(report1.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
433+
addComment(report3.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
434+
addComment(report2.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
435435

436436
const reportCollectionDataSet: ReportCollectionDataSet = {
437437
[`${ONYXKEYS.COLLECTION.REPORT}${report1.reportID}`]: report1,
@@ -479,9 +479,9 @@ describe('Sidebar', () => {
479479
const report3 = LHNTestUtils.getFakeReport([1, 4], 1);
480480

481481
// Each report has at least one ADD_COMMENT action so should be rendered in the LNH
482-
addComment(report1.reportID, 'Hi, this is a comment');
483-
addComment(report2.reportID, 'Hi, this is a comment');
484-
addComment(report3.reportID, 'Hi, this is a comment');
482+
addComment(report1.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
483+
addComment(report2.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
484+
addComment(report3.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
485485

486486
const currentReportId = report2.reportID;
487487

@@ -628,7 +628,7 @@ describe('Sidebar', () => {
628628
iouReportID: undefined,
629629
};
630630
const report4 = LHNTestUtils.getFakeReport([1, 5], 1);
631-
addComment(report4.reportID, 'Hi, this is a comment');
631+
addComment(report4.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
632632

633633
const iouReport: OnyxTypes.Report = {
634634
...LHNTestUtils.getFakeReport([1, 4]),
@@ -848,9 +848,9 @@ describe('Sidebar', () => {
848848
const report3 = LHNTestUtils.getFakeReport([1, 4]);
849849

850850
// Each report has at least one ADD_COMMENT action so should be rendered in the LNH
851-
addComment(report1.reportID, 'Hi, this is a comment');
852-
addComment(report2.reportID, 'Hi, this is a comment');
853-
addComment(report3.reportID, 'Hi, this is a comment');
851+
addComment(report1.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
852+
addComment(report2.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
853+
addComment(report3.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
854854

855855
// Given the user is in all betas
856856
const betas = [CONST.BETAS.DEFAULT_ROOMS];
@@ -902,9 +902,9 @@ describe('Sidebar', () => {
902902
const report3: OnyxTypes.Report = LHNTestUtils.getFakeReport([1, 4]);
903903

904904
// Each report has at least one ADD_COMMENT action so should be rendered in the LNH
905-
addComment(report1.reportID, 'Hi, this is a comment');
906-
addComment(report2.reportID, 'Hi, this is a comment');
907-
addComment(report3.reportID, 'Hi, this is a comment');
905+
addComment(report1.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
906+
addComment(report2.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
907+
addComment(report3.reportID, 'Hi, this is a comment', CONST.DEFAULT_TIME_ZONE);
908908

909909
const reportCollectionDataSet: ReportCollectionDataSet = {
910910
[`${ONYXKEYS.COLLECTION.REPORT}${report1.reportID}`]: report1,

0 commit comments

Comments
 (0)