-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for sentry session start in AUS
- Loading branch information
1 parent
7967653
commit 9cf808e
Showing
3 changed files
with
46 additions
and
4 deletions.
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
34 changes: 34 additions & 0 deletions
34
test/e2e/tests/error-reporting/sentryErrorReporter.test.ts
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,34 @@ | ||
import {expect} from '@playwright/test' | ||
import {test} from '@sanity/test' | ||
|
||
import {SANITY_E2E_IS_AUTO_UPDATING} from '../../env' | ||
|
||
const SENTRY_URL = 'https://sentry.sanity.io/**' | ||
|
||
test('Sentry session should begin if in an updating studio', async ({page, baseURL}) => { | ||
let apiCalled = false | ||
|
||
// Create a promise that resolves when the route is called | ||
const apiCalledPromise = new Promise<void>((resolve) => { | ||
page.route(SENTRY_URL, (route) => { | ||
apiCalled = true | ||
route.continue() | ||
resolve() | ||
}) | ||
}) | ||
|
||
await page.goto(baseURL ?? '') | ||
|
||
await Promise.race([ | ||
apiCalledPromise, | ||
new Promise((_, reject) => | ||
setTimeout(() => reject(new Error('Sentry API was not called')), 10000), | ||
), | ||
]) | ||
|
||
if (SANITY_E2E_IS_AUTO_UPDATING) { | ||
expect(apiCalled).toBe(true) | ||
} else { | ||
expect(apiCalled).toBe(false) | ||
} | ||
}) |