Skip to content

Commit

Permalink
refactor: remove sentry error reporter test for now
Browse files Browse the repository at this point in the history
  • Loading branch information
cngonzalez committed Aug 19, 2024
1 parent 9a22558 commit 626a67e
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ SANITY_E2E_BASE_URL=http://localhost:3339
# Whether or not to run the end to end tests in headless mode. Defaults to true, but sometimes
# you might want to see the browser in action, in which case you can set this to `false`.
HEADLESS=true
SANITY_E2E_HEADLESS=true
# In CI, we have to provide some signal of how we've build the studio. Set this to `true` if you're testing an auto-updating build.
SANITY_E2E_IS_AUTO_UPDATING=false
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
# Delete `SANITY_E2E_SESSION_TOKEN_NEW` from github
SANITY_E2E_SESSION_TOKEN: ${{ secrets.SANITY_E2E_SESSION_TOKEN_NEW }}
SANITY_E2E_PROJECT_ID: ${{ secrets.SANITY_E2E_PROJECT_ID }}
SANITY_E2E_DATASET: pr-${{ matrix.project }}-${{ github.event.number }}
SANITY_E2E_DATASET: pr-${{ matrix.project }}-${{ github.event.number }}${{ matrix.config == 'auto-updating' && '-auto-updating' || '' }}
SANITY_E2E_IS_AUTO_UPDATING: ${{ matrix.config == 'auto-updating' && 'true' || '' }}
run: |
if [ "${{ matrix.config }}" == "auto-updating" ]; then
Expand Down Expand Up @@ -227,7 +227,7 @@ jobs:
# Delete `SANITY_E2E_SESSION_TOKEN_NEW` from github
SANITY_E2E_SESSION_TOKEN: ${{ secrets.SANITY_E2E_SESSION_TOKEN_NEW }}
SANITY_E2E_PROJECT_ID: ${{ secrets.SANITY_E2E_PROJECT_ID }}
SANITY_E2E_DATASET: pr-${{ matrix.project }}-${{ github.event.number }}
SANITY_E2E_DATASET: pr-${{ matrix.project }}-${{ github.event.number }}${{ matrix.config == 'auto-updating' && '-auto-updating' || '' }}
SANITY_E2E_IS_AUTO_UPDATING: ${{ matrix.config == 'auto-updating' && 'true' || '' }}
run: pnpm test:e2e --project ${{ matrix.project }} --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}

Expand Down
28 changes: 28 additions & 0 deletions dev/test-studio/schema/debug/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Button } from '@sanity/ui'
import { defineField, defineType } from 'sanity'

export default defineType({
name: 'error',
type: 'document',
title: 'Error',
fields: [
defineField({
name: 'title',
title: 'Title',
type: 'string',
components: {
input: () => {
const errorFunc = () => {
throw new Error('This is not a real error: we are just testing')
}
return (
<Button
onClick={errorFunc}
text='Throw error'
/>
)
}
}
}),
]
})
2 changes: 2 additions & 0 deletions dev/test-studio/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
} from './debug/deprecatedFields'
import documentActions from './debug/documentActions'
import empty from './debug/empty'
import error from './debug/error'
import experiment from './debug/experiment'
import {fieldActionsTest} from './debug/fieldActionsTest'
import fieldComponentsTest from './debug/fieldComponentsTest'
Expand Down Expand Up @@ -196,6 +197,7 @@ export const schemaTypes = [
deprecatedFields,
documentActions,
empty,
error,
experiment,
fieldActionsTest,
fieldComponentsTest,
Expand Down
1 change: 1 addition & 0 deletions dev/test-studio/structure/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const DEBUG_INPUT_TYPES = [
'documentActionsTest',
'documentWithHoistedPt',
'empty',
'error',
'fieldActionsTest',
'fieldComponentsTest',
'fieldsetsTest',
Expand Down
1 change: 1 addition & 0 deletions packages/sanity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"@dnd-kit/sortable": "^7.0.1",
"@dnd-kit/utilities": "^3.2.0",
"@juggle/resize-observer": "^3.3.1",
"@portabletext/editor": "^1.0.13",
"@portabletext/react": "^3.0.0",
"@rexxars/react-json-inspector": "^8.0.1",
"@sanity/asset-utils": "^1.2.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const hasSanityPackageInImportMap = () => {
if (typeof document === 'undefined' || !('querySelectorAll' in document)) {
return false
}
return true
const importMapEntries = document.querySelectorAll('script[type="importmap"]')
return Array.from(importMapEntries).some((entry) => {
if (!entry.textContent) return false
Expand Down
43 changes: 43 additions & 0 deletions test/e2e/tests/error-reporting/errorReporter.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {expect} from '@playwright/test'
import {test} from '@sanity/test'

import {SANITY_E2E_IS_AUTO_UPDATING} from '../../env'

const TELEMETRY_URL = 'https://**/intake/telemetry-status**'
const SENTRY_URL = 'https://sanity.sentry.io/**'

test('Error reporter should initialize if in an updating studio and telemetry is granted', async ({
page,
createDraftDocument,
}) => {
let apiCalled = false

await createDraftDocument('test/content/input-debug;error')
//force telemetry to be enabled
await page.route(TELEMETRY_URL, (route) => {
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
status: 'enabled',
}),
})
})

await page.getByText('Throw error').click()

await page.route(SENTRY_URL, (route) => {
apiCalled = true
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({}),
})
})

if (SANITY_E2E_IS_AUTO_UPDATING) {
expect(apiCalled).toBe(true)
} else {
expect(apiCalled).toBe(false)
}
})
33 changes: 0 additions & 33 deletions test/e2e/tests/error-reporting/sentryErrorReporter.test.ts

This file was deleted.

0 comments on commit 626a67e

Please sign in to comment.