-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix: comment linking e2e test #43986
Merged
mountiny
merged 2 commits into
Expensify:main
from
margelo:fix/e2e-comment-linking-test
Jun 19, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import {DeviceEventEmitter} from 'react-native'; | ||
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 getPromiseWithResolve from '@libs/E2E/utils/getPromiseWithResolve'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import Performance from '@libs/Performance'; | ||
import CONST from '@src/CONST'; | ||
|
@@ -23,6 +24,29 @@ const test = (config: NativeConfig) => { | |
return waitForAppLoaded().then(() => E2EClient.submitTestDone()); | ||
} | ||
|
||
const [appearMessagePromise, appearMessageResolve] = getPromiseWithResolve(); | ||
const [switchReportPromise, switchReportResolve] = getPromiseWithResolve(); | ||
|
||
Promise.all([appearMessagePromise, switchReportPromise]) | ||
.then(() => { | ||
console.debug('[E2E] Test completed successfully, exiting…'); | ||
E2EClient.submitTestDone(); | ||
}) | ||
.catch((err) => { | ||
console.debug('[E2E] Error while submitting test results:', err); | ||
}); | ||
|
||
const subscription = DeviceEventEmitter.addListener('onViewableItemsChanged', (res) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it fire when we open the first chat? It looks like it would, so we can skip it or change the log '[E2E] Message verification failed,' as it may look like an error, but it would be expected behavior since we only want to check it for entry.name === SWITCH_REPORT |
||
console.debug('[E2E] Viewable items retrieved, verifying correct message…', res); | ||
|
||
if (!!res && res[0]?.item?.reportActionID === linkedReportActionID) { | ||
appearMessageResolve(); | ||
subscription.remove(); | ||
} else { | ||
console.debug(`[E2E] Provided message id '${res?.[0]?.item?.reportActionID}' doesn't match to an expected '${linkedReportActionID}'. Waiting for a next one…`); | ||
} | ||
}); | ||
|
||
Performance.subscribeToMeasurements((entry) => { | ||
if (entry.name === CONST.TIMING.SIDEBAR_LOADED) { | ||
console.debug('[E2E] Sidebar loaded, navigating to a report…'); | ||
|
@@ -41,27 +65,14 @@ const test = (config: NativeConfig) => { | |
|
||
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); | ||
E2EClient.submitTestResults({ | ||
branch: Config.E2E_BRANCH, | ||
name: 'Comment linking', | ||
duration: entry.duration, | ||
}); | ||
|
||
switchReportResolve(); | ||
} | ||
}); | ||
}); | ||
|
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.
DeviceEventEmitter is deprecated, but we can use NativeEventEmitter instead
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, currently we don't use
NativeEventEmitter
anywhere in the codebase, so I think now it's better to keepDeviceEventEmitter
and later (when needed) we can re-work all code pieces at once.