-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Comment linking e2e #36791
Merged
Merged
Comment linking e2e #36791
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
810184f
Merge branch 'feat/##23229-linking' of https://github.com/margelo/exp…
perunt 3ad7459
Merge branch 'feat/##23229-linking' of https://github.com/margelo/exp…
perunt d537da2
Merge branch 'feat/##23229-linking' of https://github.com/margelo/exp…
perunt af70579
Merge branch 'feat/##23229-linking' of https://github.com/margelo/exp…
perunt 55fceb1
update config
perunt 82a1aaa
add onViewableItemsChanged
perunt 4e263ec
linking test
perunt 72c4d87
fix typings
perunt b365f7d
Merge branch 'main' of https://github.com/Expensify/App into feat/232…
perunt cae01f1
Merge branch 'main' of https://github.com/Expensify/App into feat/232…
perunt 5b3a3b7
Merge branch 'main' of https://github.com/Expensify/App into feat/232…
perunt 9f42bc1
fix lint
perunt 1c29ef0
fix type
perunt 884e6e2
use NativeConfig type
perunt 625a59f
use one get route method
perunt 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 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 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
54 changes: 54 additions & 0 deletions
54
src/components/InvertedFlatList/BaseInvertedFlatList/index.e2e.tsx
This file contains 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,54 @@ | ||
import React, {forwardRef, useMemo} from 'react'; | ||
import type {FlatListProps, ScrollViewProps, ViewToken} from 'react-native'; | ||
import {FlatList} from 'react-native'; | ||
import type {ReportAction} from '@src/types/onyx'; | ||
|
||
type BaseInvertedFlatListProps = FlatListProps<ReportAction> & { | ||
shouldEnableAutoScrollToTopThreshold?: boolean; | ||
}; | ||
|
||
const AUTOSCROLL_TO_TOP_THRESHOLD = 128; | ||
|
||
let localViewableItems: ViewToken[]; | ||
const getViewableItems = () => localViewableItems; | ||
|
||
function BaseInvertedFlatListE2e(props: BaseInvertedFlatListProps, ref: React.ForwardedRef<FlatList<ReportAction>>) { | ||
const {shouldEnableAutoScrollToTopThreshold, ...rest} = props; | ||
|
||
const handleViewableItemsChanged = useMemo( | ||
() => | ||
({viewableItems}: {viewableItems: ViewToken[]}) => { | ||
localViewableItems = viewableItems; | ||
}, | ||
[], | ||
); | ||
|
||
const maintainVisibleContentPosition = useMemo(() => { | ||
const config: ScrollViewProps['maintainVisibleContentPosition'] = { | ||
// This needs to be 1 to avoid using loading views as anchors. | ||
minIndexForVisible: 1, | ||
}; | ||
|
||
if (shouldEnableAutoScrollToTopThreshold) { | ||
config.autoscrollToTopThreshold = AUTOSCROLL_TO_TOP_THRESHOLD; | ||
} | ||
|
||
return config; | ||
}, [shouldEnableAutoScrollToTopThreshold]); | ||
|
||
return ( | ||
<FlatList<ReportAction> | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...rest} | ||
ref={ref} | ||
maintainVisibleContentPosition={maintainVisibleContentPosition} | ||
inverted | ||
onViewableItemsChanged={handleViewableItemsChanged} | ||
/> | ||
); | ||
} | ||
|
||
BaseInvertedFlatListE2e.displayName = 'BaseInvertedFlatListE2e'; | ||
|
||
export default forwardRef(BaseInvertedFlatListE2e); | ||
export {getViewableItems}; |
This file contains 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 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 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,70 @@ | ||
import type {NativeConfig} from 'react-native-config'; | ||
import Config from 'react-native-config'; | ||
import {getViewableItems} from '@components/InvertedFlatList/BaseInvertedFlatList/index.e2e'; | ||
import Timing from '@libs/actions/Timing'; | ||
import E2ELogin from '@libs/E2E/actions/e2eLogin'; | ||
import waitForAppLoaded from '@libs/E2E/actions/waitForAppLoaded'; | ||
import E2EClient from '@libs/E2E/client'; | ||
import getConfigValueOrThrow from '@libs/E2E/utils/getConfigValueOrThrow'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import Performance from '@libs/Performance'; | ||
import CONST from '@src/CONST'; | ||
import ROUTES from '@src/ROUTES'; | ||
|
||
const test = (config: NativeConfig) => { | ||
console.debug('[E2E] Logging in for comment linking'); | ||
|
||
const reportID = getConfigValueOrThrow('reportID', config); | ||
const linkedReportID = getConfigValueOrThrow('linkedReportID', config); | ||
const linkedReportActionID = getConfigValueOrThrow('linkedReportActionID', config); | ||
|
||
E2ELogin().then((neededLogin) => { | ||
if (neededLogin) { | ||
return waitForAppLoaded().then(() => E2EClient.submitTestDone()); | ||
} | ||
|
||
Performance.subscribeToMeasurements((entry) => { | ||
if (entry.name === CONST.TIMING.SIDEBAR_LOADED) { | ||
console.debug('[E2E] Sidebar loaded, navigating to a report…'); | ||
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID)); | ||
return; | ||
} | ||
|
||
if (entry.name === CONST.TIMING.REPORT_INITIAL_RENDER) { | ||
console.debug('[E2E] Navigating to linked report action…'); | ||
Timing.start(CONST.TIMING.SWITCH_REPORT); | ||
Performance.markStart(CONST.TIMING.SWITCH_REPORT); | ||
|
||
Navigation.navigate(ROUTES.REPORT_WITH_ID_AND_ACTION_ID.getRoute(linkedReportID, linkedReportActionID)); | ||
return; | ||
} | ||
|
||
if (entry.name === CONST.TIMING.SWITCH_REPORT) { | ||
console.debug('[E2E] Linking: 1'); | ||
setTimeout(() => { | ||
const res = getViewableItems(); | ||
console.debug('[E2E] Viewable items retrieved, verifying correct message…'); | ||
|
||
if (!!res && res[0]?.item?.reportActionID === linkedReportActionID) { | ||
E2EClient.submitTestResults({ | ||
branch: Config.E2E_BRANCH, | ||
name: 'Comment linking', | ||
duration: entry.duration, | ||
}) | ||
.then(() => { | ||
console.debug('[E2E] Test completed successfully, exiting…'); | ||
E2EClient.submitTestDone(); | ||
}) | ||
.catch((err) => { | ||
console.debug('[E2E] Error while submitting test results:', err); | ||
}); | ||
} else { | ||
console.debug('[E2E] Message verification failed'); | ||
} | ||
}, 3000); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
export default test; |
This file contains 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a separate route for this? Can we include it in
REPORT_WITH_ID
, which already has something for:reportActionID
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it makes sense to combine it, I'll do it in a moment