-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
chore(sourcemaps): Make sourcemaps e2e test more generic #19678
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
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
79 changes: 55 additions & 24 deletions
79
dev-packages/e2e-tests/test-applications/nextjs-sourcemaps/assert-build.ts
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,43 +1,74 @@ | ||
| import * as assert from 'assert/strict'; | ||
| import { | ||
| loadSourcemapUploadRecords, | ||
| assertSourcemapUploadRequests, | ||
| getArtifactBundleManifests, | ||
| assertDebugIdPairs, | ||
| assertSourcemapMappings, | ||
| assertSourcemapSources, | ||
| assertArtifactBundleAssembly, | ||
| getSourcemapUploadSummary, | ||
| loadMockServerResults, | ||
| getArtifactBundles, | ||
| getDebugIdPairs, | ||
| getSourcemaps, | ||
| getChunkUploadPosts, | ||
| getAssembleRequests, | ||
| } from '@sentry-internal/test-utils'; | ||
|
|
||
| const requests = loadSourcemapUploadRecords(); | ||
| const requests = loadMockServerResults(); | ||
|
|
||
| console.log(`Captured ${requests.length} requests to mock Sentry server:\n`); | ||
| for (const req of requests) { | ||
| console.log(` ${req.method} ${req.url} (${req.bodySize} bytes)`); | ||
| } | ||
| console.log(''); | ||
|
|
||
| assertSourcemapUploadRequests(requests, 'fake-auth-token'); | ||
| // Auth token is present | ||
| const authenticated = requests.filter(r => r.authorization.includes('fake-auth-token')); | ||
| assert.ok(authenticated.length > 0, 'Expected requests with the configured auth token'); | ||
|
|
||
| const manifests = getArtifactBundleManifests(requests); | ||
| console.log(`Found ${manifests.length} artifact bundle manifest(s):\n`); | ||
| // Chunk uploads happened | ||
| const chunkPosts = getChunkUploadPosts(requests); | ||
| assert.ok(chunkPosts.length > 0, 'Expected at least one chunk upload POST'); | ||
| assert.ok( | ||
| chunkPosts.some(r => r.bodySize > 0), | ||
| 'Expected at least one chunk upload with a non-empty body', | ||
| ); | ||
|
|
||
| const debugIdPairs = assertDebugIdPairs(manifests); | ||
| console.log(`Found ${debugIdPairs.length} JS/sourcemap pairs with debug IDs:`); | ||
| // Release endpoint was called | ||
| assert.ok( | ||
| requests.some(r => r.url?.includes('/releases/')), | ||
| 'Expected at least one request to releases endpoint', | ||
| ); | ||
|
|
||
| // Artifact bundles have manifests | ||
| const bundles = getArtifactBundles(requests); | ||
| assert.ok(bundles.length > 0, 'Expected at least one artifact bundle with a manifest'); | ||
| console.log(`Found ${bundles.length} artifact bundle(s)\n`); | ||
|
|
||
| // Debug ID pairs exist and are valid UUIDs | ||
| const debugIdPairs = getDebugIdPairs(bundles); | ||
| assert.ok(debugIdPairs.length > 0, 'Expected at least one JS/sourcemap pair with matching debug IDs'); | ||
|
|
||
| const uuidRegex = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i; | ||
| for (const pair of debugIdPairs) { | ||
| assert.match(pair.debugId, uuidRegex, `Invalid debug ID: ${pair.debugId}`); | ||
| console.log(` ${pair.debugId} ${pair.jsUrl}`); | ||
| } | ||
| console.log(''); | ||
|
|
||
| assertSourcemapMappings(manifests); | ||
| assertSourcemapSources(manifests, /client-page|page\.tsx/); | ||
| assertArtifactBundleAssembly(requests, 'test-project'); | ||
| // Sourcemaps have real content | ||
| const sourcemaps = getSourcemaps(bundles); | ||
| assert.ok( | ||
| sourcemaps.some(s => s.sourcemap.mappings && s.sourcemap.mappings.length > 0), | ||
| 'Expected at least one sourcemap with non-empty mappings', | ||
| ); | ||
|
|
||
| const summary = getSourcemapUploadSummary(requests, manifests, debugIdPairs); | ||
| // At least one sourcemap references app source files | ||
| assert.ok( | ||
| sourcemaps.some(s => s.sourcemap.sources?.some(src => /client-page|page\.tsx/.test(src))), | ||
| 'Expected at least one sourcemap referencing app source files', | ||
| ); | ||
|
|
||
| // Assemble requests reference the correct project | ||
| const assembleReqs = getAssembleRequests(requests); | ||
| assert.ok(assembleReqs.length > 0, 'Expected at least one assemble request'); | ||
| for (const req of assembleReqs) { | ||
| assert.ok(req.assembleBody?.projects?.includes('test-project'), 'Expected assemble request to include test-project'); | ||
| assert.ok((req.assembleBody?.chunks?.length ?? 0) > 0, 'Expected assemble request to have chunk checksums'); | ||
| } | ||
|
|
||
| console.log('\nAll sourcemap upload assertions passed!'); | ||
| console.log(` - ${summary.totalRequests} total requests captured`); | ||
| console.log(` - ${summary.chunkUploadPosts} chunk upload POST requests`); | ||
| console.log(` - ${summary.artifactBundles} artifact bundles with manifests`); | ||
| console.log(` - ${summary.debugIdPairs} JS/sourcemap pairs with debug IDs`); | ||
| console.log(` - ${summary.assembleRequests} artifact bundle assemble requests`); | ||
| console.log('All sourcemap upload assertions passed!'); | ||
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
278 changes: 0 additions & 278 deletions
278
dev-packages/test-utils/src/sourcemap-upload-assertions.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.