-
Notifications
You must be signed in to change notification settings - Fork 4k
86919: Message in IOU is not scrolled to when navigating via link, 'submitted' not shown #96428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
abbasifaizan70
wants to merge
11
commits into
Expensify:main
Choose a base branch
from
abbasifaizan70:fix-86919
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a02e7b6
86919: Message in IOU is not scrolled to when navigating via link, 's…
abbasifaizan70 01331a0
Merge branch 'Expensify:main' into fix-86919
abbasifaizan70 862e8c6
Fixed EsLint & test cases issues
abbasifaizan70 d28be07
Fixed Lint issues
abbasifaizan70 9d260f8
Fixed Lint issues
abbasifaizan70 7a8a51d
Fixed Lint issues
abbasifaizan70 332521b
Merge branch 'main' into fix-86919
abbasifaizan70 64267ad
fix: scroll to linked IOU message and show Submitted when opening via…
abbasifaizan70 896d69f
Merge branch 'main' into fix-86919
abbasifaizan70 d700dd3
fix: redirect linked action to parent expense report at open time ins…
abbasifaizan70 2701a5a
fixed test cases and typescript issues
abbasifaizan70 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| import Clipboard from '@libs/Clipboard'; | ||
| import type * as EnvironmentModule from '@libs/Environment/Environment'; | ||
| import {getDisplayedReportID} from '@libs/ReportUtils'; | ||
| // eslint-disable-next-line no-restricted-imports -- type-only namespace (erased at runtime) used solely for the requireActual generic; no restricted functions are actually imported | ||
| import type * as ReportUtilsModule from '@libs/ReportUtils'; | ||
|
|
||
| import ContextMenuActions from '@pages/inbox/report/ContextMenu/ContextMenuActions'; | ||
| import type {ContextMenuActionPayload} from '@pages/inbox/report/ContextMenu/ContextMenuActions'; | ||
|
|
||
| import CONST from '@src/CONST'; | ||
|
|
||
| import createRandomReportAction from '../utils/collections/reportActions'; | ||
|
|
||
| // Verifies the "Copy link" context menu action (change A for issue #86919): for one-transaction | ||
| // expense flows the copied link must use the DISPLAYED (parent expense) report ID rather than the | ||
| // transaction thread's `originalReportID`, so the link opens the combined view where the parent | ||
| // "Submitted" system message is present and the linked message can be scrolled to. | ||
|
|
||
| jest.mock( | ||
| 'expo-web-browser', | ||
| () => ({ | ||
| openAuthSessionAsync: jest.fn(), | ||
| }), | ||
| {virtual: true}, | ||
| ); | ||
|
|
||
| jest.mock('@components/Reactions/MiniQuickEmojiReactions', () => 'MiniQuickEmojiReactions'); | ||
| jest.mock('@components/Reactions/QuickEmojiReactions', () => 'QuickEmojiReactions'); | ||
|
|
||
| jest.mock('@libs/Clipboard', () => ({ | ||
| __esModule: true, | ||
| default: { | ||
| canSetHtml: jest.fn(), | ||
| setString: jest.fn(), | ||
| setHtml: jest.fn(), | ||
| }, | ||
| })); | ||
|
|
||
| jest.mock('@libs/Environment/Environment', () => ({ | ||
| __esModule: true, | ||
| ...jest.requireActual<typeof EnvironmentModule>('@libs/Environment/Environment'), | ||
| getEnvironmentURL: jest.fn(() => Promise.resolve('https://new.expensify.com')), | ||
| })); | ||
|
|
||
| jest.mock('@libs/ReportUtils', () => ({ | ||
| __esModule: true, | ||
| ...jest.requireActual<typeof ReportUtilsModule>('@libs/ReportUtils'), | ||
| getDisplayedReportID: jest.fn(), | ||
| })); | ||
|
|
||
| const mockClipboard = jest.mocked(Clipboard); | ||
| const mockGetDisplayedReportID = jest.mocked(getDisplayedReportID); | ||
|
|
||
| // ContextMenuAction is a union; sentryLabel/onPress only exist on the icon variant, so narrow with `in`. | ||
| const copyLinkAction = ContextMenuActions.find((action) => 'sentryLabel' in action && action.sentryLabel === CONST.SENTRY_LABEL.CONTEXT_MENU.COPY_LINK); | ||
|
|
||
| // Flush the microtasks queued by getEnvironmentURL().then(...) inside the onPress handler. | ||
| const flushPromises = () => | ||
| new Promise((resolve) => { | ||
| process.nextTick(resolve); | ||
| }); | ||
|
|
||
| function createPayload(overrides: Partial<ContextMenuActionPayload>): ContextMenuActionPayload { | ||
| // The copy-link handler only reads reportAction, originalReportID, and isOffline; the rest of the | ||
| // (large) payload type is irrelevant to this action, so we assert the minimal shape it needs. | ||
| const payload = { | ||
| reportAction: {...createRandomReportAction(1), reportActionID: 'action-1'}, | ||
| originalReportID: 'transaction-thread-1', | ||
| isOffline: false, | ||
| ...overrides, | ||
| }; | ||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- test payload only needs the fields the copy-link handler reads | ||
| return payload as ContextMenuActionPayload; | ||
| } | ||
|
|
||
| describe('ContextMenuActions copy link', () => { | ||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| it('copies a link using the displayed (parent) report ID for one-transaction expense flows', async () => { | ||
| mockGetDisplayedReportID.mockReturnValue('parent-expense-1'); | ||
|
|
||
| if (!copyLinkAction || !('onPress' in copyLinkAction)) { | ||
| throw new Error('Copy link context menu action was not found'); | ||
| } | ||
|
|
||
| copyLinkAction.onPress(true, createPayload({originalReportID: 'transaction-thread-1', isOffline: false})); | ||
| await flushPromises(); | ||
|
|
||
| // The displayed report ID is resolved from the original (transaction-thread) report ID and the offline flag. | ||
| expect(mockGetDisplayedReportID).toHaveBeenCalledWith('transaction-thread-1', false); | ||
| // The copied link points at the parent expense report, not the transaction thread. | ||
| expect(mockClipboard.setString).toHaveBeenCalledWith('https://new.expensify.com/r/parent-expense-1/action-1'); | ||
| }); | ||
|
|
||
| it('does not resolve a displayed report ID when there is no original report ID', async () => { | ||
| if (!copyLinkAction || !('onPress' in copyLinkAction)) { | ||
| throw new Error('Copy link context menu action was not found'); | ||
| } | ||
|
|
||
| copyLinkAction.onPress(true, createPayload({originalReportID: undefined})); | ||
| await flushPromises(); | ||
|
|
||
| expect(mockGetDisplayedReportID).not.toHaveBeenCalled(); | ||
| expect(mockClipboard.setString).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.