refactor clearCreateChatError, clearTaskErrors and navigateToAndOpenReportWithAccountIDs to use isSelfTourViewed from useOnyx#87231
Conversation
…eportWithAccountIDs to use isSelfTourViewed from useOnyx
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
@DylanDylann Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
| TestHelper.expectAPICommandToHaveBeenCalled(WRITE_COMMANDS.OPEN_REPORT, 1); | ||
| }); | ||
|
|
||
| it('clearCreateChatError should pass isSelfTourViewed=true through navigateToConciergeChatAndDeleteReport when deleting optimistic report', async () => { |
There was a problem hiding this comment.
I confused with these tests. We should simulate scenario where isSelfTourViewed is true or false, then verify the output
Reviewer Checklist
Screenshots/VideosScreen.Recording.2026-04-08.at.17.19.05.mov |
| TestHelper.expectAPICommandToHaveBeenCalled(WRITE_COMMANDS.OPEN_REPORT, 1); | ||
| }); | ||
|
|
||
| it('clearCreateChatError should delete optimistic report and navigate to concierge when isSelfTourViewed is true', async () => { |
There was a problem hiding this comment.
The description looks incorrect, could you check again?
| expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(EXISTING_REPORT_ID)); | ||
| }); | ||
|
|
||
| it('should create new chat and call openReport when isSelfTourViewed is true and no existing chat is found', async () => { |
There was a problem hiding this comment.
same above
should create new chat
|
@DylanDylann can you please check again? |
| TestHelper.expectAPICommandToHaveBeenCalled(WRITE_COMMANDS.OPEN_REPORT, 1); | ||
| }); | ||
|
|
||
| it('clearCreateChatError should call openReport when isSelfTourViewed is true', async () => { |
There was a problem hiding this comment.
@dukenv0307 I think the test should focus on behavior driven by isSelfTourViewed. In this case, verifying the openReport call doesn’t seem related to isSelfTourViewed. So it looks confused....
| it('clearCreateChatError should call openReport when deleting optimistic report', async () => { | ||
| const TEST_USER_ACCOUNT_ID = 1; | ||
| const TEST_USER_LOGIN = 'test@user.com'; | ||
| const REPORT: OnyxTypes.Report = {...createRandomReport(1, undefined), errorFields: {createChat: {error: 'error'}}}; | ||
| const INTRO_SELECTED: OnyxTypes.IntroSelected = {choice: CONST.ONBOARDING_CHOICES.MANAGE_TEAM}; | ||
|
|
||
| await TestHelper.signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN); | ||
| await TestHelper.setPersonalDetails(TEST_USER_LOGIN, TEST_USER_ACCOUNT_ID); | ||
| await Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, { | ||
| [CONST.ACCOUNT_ID.CONCIERGE]: { | ||
| accountID: CONST.ACCOUNT_ID.CONCIERGE, | ||
| login: CONST.EMAIL.CONCIERGE, | ||
| displayName: 'Concierge', | ||
| }, | ||
| }); |
There was a problem hiding this comment.
Looks like this test is the same as the above one.
|
@MelvinBot Could you please review the unit test change in this PR and suggest an effective way to avoid duplicated test cases? |
|
I reviewed the unit test changes. Here are the duplicated tests and how to consolidate them: 1.
|
| Area | Issue | Action |
|---|---|---|
navigateToAndOpenReportWithAccountIDs |
3rd test is exact duplicate of 1st | Delete 3rd test; optionally merge 1st+2nd with it.each |
clearCreateChatError |
New test duplicates existing one above | Delete or merge with it.each |
getGuidedSetupDataForOpenReport |
Not duplicated, but heavy boilerplate | Collapse with it.each for readability |
|
@MelvinBot Please review again |
|
I've re-reviewed the PR after the latest changes. Here's my assessment: Production code changes ✅The Test changes — mostly good, one minor concernWell addressed from prior feedback:
Minor concern (non-blocking): The All CI checks passing ✅ |
|
@DylanDylann all yours |
|
🚧 @mjasikowski has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mjasikowski in version: 9.3.60-0 🚀
Bundle Size Analysis (Sentry): |
|
No help site changes are required for this PR. This is a purely internal code refactoring that threads the |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.3.60-22 🚀
|
Explanation of Change
Fixed Issues
$ #66424
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-04-07.at.15.49.42.mov