-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
test(replay): Test that blocking elements works as expected #7201
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
4 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 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 @@ | ||
test-results | ||
20 changes: 20 additions & 0 deletions
20
packages/integration-tests/suites/replay/privacyBlock/init.js
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,20 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
import { Replay } from '@sentry/replay'; | ||
|
||
window.Sentry = Sentry; | ||
window.Replay = new Replay({ | ||
flushMinDelay: 200, | ||
flushMaxDelay: 200, | ||
useCompression: false, | ||
blockAllMedia: false, | ||
block: ['link[rel="icon"]', 'video', '.nested-hide'], | ||
}); | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
sampleRate: 0, | ||
replaysSessionSampleRate: 1.0, | ||
replaysOnErrorSampleRate: 0.0, | ||
|
||
integrations: [window.Replay], | ||
}); |
22 changes: 22 additions & 0 deletions
22
packages/integration-tests/suites/replay/privacyBlock/template.html
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,22 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" type="image/png" href="file://assets/icon/favicon.png"/> | ||
</head> | ||
<body> | ||
<button aria-label="Click me" onclick="console.log('Test log')">Click me</button> | ||
<div>This should be masked by default</div> | ||
<div data-sentry-unmask>This should be unmasked due to data attribute</div> | ||
<input placeholder="Placeholder should be masked" /> | ||
<div title="Title should be masked">Title should be masked</div> | ||
<svg style="width:200px;height:200px" viewBox="0 0 80 80"><path d=""/><area /><rect /></svg> | ||
<svg style="width:200px;height:200px" viewBox="0 0 80 80" data-sentry-unblock><path d=""/><area /><rect /></svg> | ||
<img style="width:100px;height:100px" src="file:///none.png" /> | ||
<img data-sentry-unblock style="width:100px;height:100px" src="file:///none.png" /> | ||
<video style="width:30px;height:30px"><source src="file://foo.mp4" /></video> | ||
<div class="nested-hide"> | ||
<div>This should be hidden.</div> | ||
</div> | ||
</body> | ||
</html> |
35 changes: 35 additions & 0 deletions
35
packages/integration-tests/suites/replay/privacyBlock/test.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { | ||
getFullRecordingSnapshots, | ||
normalize, | ||
shouldSkipReplayTest, | ||
waitForReplayRequest, | ||
} from '../../../utils/replayHelpers'; | ||
|
||
sentryTest('should allow to manually block elements', async ({ getLocalTestPath, page }) => { | ||
if (shouldSkipReplayTest()) { | ||
sentryTest.skip(); | ||
} | ||
|
||
const reqPromise0 = waitForReplayRequest(page, 0); | ||
|
||
await page.route('https://dsn.ingest.sentry.io/**/*', route => { | ||
return route.fulfill({ | ||
status: 200, | ||
contentType: 'application/json', | ||
body: JSON.stringify({ id: 'test-id' }), | ||
}); | ||
}); | ||
|
||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
await page.goto(url); | ||
const snapshots = getFullRecordingSnapshots(await reqPromise0); | ||
expect(snapshots.length).toEqual(1); | ||
|
||
const stringifiedSnapshot = normalize(snapshots[0], { normalizeNumberAttributes: ['rr_width', 'rr_height'] }); | ||
|
||
expect(stringifiedSnapshot).toMatchSnapshot('privacy.json'); | ||
}); |
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.
Add a .gitginore to ensure this is not accidentally checked in.
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.
Good idea, also saw this folder floating around recently