-
-
Notifications
You must be signed in to change notification settings - Fork 357
test: e2e replay test using Maestro (js) #4277
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a954733
test: move e2e test assertions to maestro runScript
vaind e650070
replay tests
vaind 5a8d40b
fix tests
vaind 8fb5c3a
update maestro jsengine everywhere
vaind 6f5e263
Merge branch 'main' into test/e2e-replay-maestro-js
vaind 00eaec7
kill app between test cases
vaind 425b974
replay tests only on iOS
vaind 8038867
review suggestions
vaind de8ac54
quote style
vaind bd6dc14
only capture replay in replay test
vaind d572629
Merge branch 'main' into test/e2e-replay-maestro-js
krystofwoldrich 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| appId: ${APP_ID} | ||
| jsEngine: graaljs | ||
| --- | ||
| - runFlow: utils/launchTestAppClear.yml | ||
| - tapOn: "Capture Exception" | ||
|
|
||
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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| appId: ${APP_ID} | ||
| jsEngine: graaljs | ||
| --- | ||
| - runFlow: utils/launchTestAppClear.yml | ||
| - tapOn: "Capture Message" | ||
|
|
||
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,13 @@ | ||
| appId: ${APP_ID} | ||
| jsEngine: graaljs | ||
| --- | ||
| - runFlow: | ||
| file: utils/launchTestAppClear.yml | ||
| env: | ||
| replaysOnErrorSampleRate: 1.0 | ||
| - tapOn: "Capture Exception" | ||
| - runFlow: utils/assertEventIdVisible.yml | ||
| - runFlow: | ||
| file: utils/assertReplay.yml | ||
| when: | ||
| platform: iOS |
1 change: 1 addition & 0 deletions
1
dev-packages/e2e-tests/maestro/captureUnhandledPromiseRejection.yml
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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| appId: ${APP_ID} | ||
| jsEngine: graaljs | ||
| --- | ||
| - runFlow: utils/launchTestAppClear.yml | ||
| - tapOn: "Close" | ||
|
|
||
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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| appId: ${APP_ID} | ||
| jsEngine: graaljs | ||
| --- | ||
| - runFlow: utils/launchTestAppClear.yml | ||
| - tapOn: "Crash" | ||
|
|
||
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,23 @@ | ||
| appId: ${APP_ID} | ||
| jsEngine: graaljs | ||
| --- | ||
| - extendedWaitUntil: | ||
| visible: | ||
| id: "eventId" | ||
| timeout: 60_000 # 60 seconds | ||
|
|
||
| - copyTextFrom: | ||
| id: "eventId" | ||
| - assertTrue: ${maestro.copiedText} | ||
|
|
||
| - runScript: | ||
| file: sentryApi.js | ||
| env: | ||
| fetch: replay | ||
| eventId: ${maestro.copiedText} | ||
| sentryAuthToken: ${SENTRY_AUTH_TOKEN} | ||
|
|
||
| - assertTrue: ${output.replayId} | ||
| - assertTrue: ${output.replayDuration} | ||
| - assertTrue: ${output.replaySegments} | ||
| - assertTrue: ${output.replayCodec == "ftypmp42"} |
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,80 @@ | ||
| const baseUrl = 'https://sentry.io/api/0/projects/sentry-sdks/sentry-react-native'; | ||
|
|
||
| const RETRY_COUNT = 600; | ||
| const RETRY_INTERVAL = 1000; | ||
| const requestHeaders = { 'Authorization': `Bearer ${sentryAuthToken}` } | ||
|
|
||
| function sleep(ms) { | ||
| // TODO reach out to Maestro & GrallJS via GitHub issues. | ||
| // return new Promise(resolve => setTimeout(resolve, ms)); | ||
| // Instead, we need to do a busy wait. | ||
| const until = Date.now() + ms; | ||
| while (Date.now() < until) { | ||
| // console.log(`Sleeping for ${until - Date.now()} ms`); | ||
| try { | ||
| http.get('http://127.0.0.1:1'); | ||
| } catch (e) { | ||
| // Ignore | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function fetchFromSentry(url) { | ||
| console.log(`Fetching ${url}`); | ||
| let retries = 0; | ||
| const shouldRetry = (response) => { | ||
| switch (response.status) { | ||
| case 200: | ||
| return false; | ||
| case 403: | ||
| throw new Error(`Could not fetch ${url}: ${response.status} | ${response.body}`); | ||
| default: | ||
| if (retries++ < RETRY_COUNT) { | ||
| console.log(`Request failed (HTTP ${response.status}), retrying: ${retries}/${RETRY_COUNT}`); | ||
| return true; | ||
| } | ||
| throw new Error(`Could not fetch ${url} within retry limit: ${response.status} | ${response.body}`); | ||
| } | ||
| } | ||
|
|
||
| while (true) { | ||
| const response = http.get(url, { headers: requestHeaders }) | ||
| if (!shouldRetry(response)) { | ||
| console.log(`Received HTTP ${response.status}: body length ${response.body.length}`); | ||
| return response.body; | ||
| } | ||
| sleep(RETRY_INTERVAL); | ||
| } | ||
| }; | ||
|
|
||
| function setOutput(data) { | ||
| for (const [key, value] of Object.entries(data)) { | ||
| console.log(`Setting output.${key} = '${value}'`); | ||
| output[key] = value; | ||
| } | ||
| } | ||
|
|
||
| // Note: "fetch", "id", "eventId", etc. are script inputs, see for example assertEventIdIVisible.yml | ||
| switch (fetch) { | ||
| case 'event': { | ||
| const data = json(fetchFromSentry(`${baseUrl}/events/${id}/json/`)); | ||
| setOutput({ eventId: data.event_id }); | ||
| break; | ||
| } | ||
| case 'replay': { | ||
| const event = json(fetchFromSentry(`${baseUrl}/events/${eventId}/json/`)); | ||
| const replayId = event._dsc.replay_id.replace(/\-/g, ''); | ||
| const replay = json(fetchFromSentry(`${baseUrl}/replays/${replayId}/`)); | ||
| const segment = fetchFromSentry(`${baseUrl}/replays/${replayId}/videos/0/`); | ||
|
|
||
| setOutput({ | ||
| replayId: replay.data.id, | ||
| replayDuration: replay.data.duration, | ||
| replaySegments: replay.data.count_segments, | ||
| replayCodec: segment.slice(4, 12) | ||
| }); | ||
| break; | ||
| } | ||
| default: | ||
| throw new Error(`Unknown "fetch" value: '${fetch}'`); | ||
| } | ||
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 was deleted.
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.