Skip to content

test(replay): Ensure that unicode characters are handled correctly #7252

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 3 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as Sentry from '@sentry/browser';

window.Sentry = Sentry;
window.Replay = new Sentry.Replay({
flushMinDelay: 500,
flushMaxDelay: 500,
useCompression: true,
maskAllText: false,
});

Sentry.init({
dsn: 'https://[email protected]/1337',
sampleRate: 0,
replaysSessionSampleRate: 1.0,
replaysOnErrorSampleRate: 0.0,

integrations: [window.Replay],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import {
getFullRecordingSnapshots,
normalize,
shouldSkipReplayTest,
waitForReplayRequest,
} from '../../../../utils/replayHelpers';

sentryTest('replay should handle unicode characters', 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);
expect(normalize(snapshots[0])).toMatchSnapshot('unicode-compressed.json');
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"node": {
"type": 0,
"childNodes": [
{
"type": 1,
"name": "html",
"publicId": "",
"systemId": "",
"id": 2
},
{
"type": 2,
"tagName": "html",
"attributes": {},
"childNodes": [
{
"type": 2,
"tagName": "head",
"attributes": {},
"childNodes": [
{
"type": 2,
"tagName": "meta",
"attributes": {
"charset": "utf-8"
},
"childNodes": [],
"id": 5
}
],
"id": 4
},
{
"type": 3,
"textContent": "\n ",
"id": 6
},
{
"type": 2,
"tagName": "body",
"attributes": {},
"childNodes": [
{
"type": 3,
"textContent": "\n ",
"id": 8
},
{
"type": 2,
"tagName": "h1",
"attributes": {},
"childNodes": [
{
"type": 3,
"textContent": "Hi 👋👋👋",
"id": 10
}
],
"id": 9
},
{
"type": 3,
"textContent": "\n ",
"id": 11
},
{
"type": 2,
"tagName": "p",
"attributes": {},
"childNodes": [
{
"type": 3,
"textContent": "\n Adding some unicode characters to the page to make sure they are properly handled. At sentry, we like 🚢🚢🚢. We\n also like 🍕, 🍺 and 🐕. (Some people might actually prefer 🐈‍⬛ but the test author is a dog person, so 🤷‍♂️).\n ",
"id": 13
}
],
"id": 12
},
{
"type": 3,
"textContent": "\n\n ",
"id": 14
},
{
"type": 2,
"tagName": "button",
"attributes": {
"id": "go-background"
},
"childNodes": [
{
"type": 3,
"textContent": "✅ Acknowledge",
"id": 16
}
],
"id": 15
},
{
"type": 3,
"textContent": "\n ",
"id": 17
},
{
"type": 3,
"textContent": "\n\n",
"id": 18
}
],
"id": 7
}
],
"id": 3
}
],
"id": 1
},
"initialOffset": {
"left": 0,
"top": 0
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"node": {
"type": 0,
"childNodes": [
{
"type": 1,
"name": "html",
"publicId": "",
"systemId": "",
"id": 2
},
{
"type": 2,
"tagName": "html",
"attributes": {},
"childNodes": [
{
"type": 2,
"tagName": "head",
"attributes": {},
"childNodes": [
{
"type": 2,
"tagName": "meta",
"attributes": {
"charset": "utf-8"
},
"childNodes": [],
"id": 5
}
],
"id": 4
},
{
"type": 3,
"textContent": "\n ",
"id": 6
},
{
"type": 2,
"tagName": "body",
"attributes": {},
"childNodes": [
{
"type": 3,
"textContent": "\n ",
"id": 8
},
{
"type": 2,
"tagName": "h1",
"attributes": {},
"childNodes": [
{
"type": 3,
"textContent": "Hi 👋👋👋",
"id": 10
}
],
"id": 9
},
{
"type": 3,
"textContent": "\n ",
"id": 11
},
{
"type": 2,
"tagName": "p",
"attributes": {},
"childNodes": [
{
"type": 3,
"textContent": "\n Adding some unicode characters to the page to make sure they are properly handled. At sentry, we like 🚢🚢🚢. We\n also like 🍕, 🍺 and 🐕. (Some people might actually prefer 🐈‍⬛ but the test author is a dog person, so 🤷‍♂️).\n ",
"id": 13
}
],
"id": 12
},
{
"type": 3,
"textContent": "\n\n ",
"id": 14
},
{
"type": 2,
"tagName": "button",
"attributes": {
"id": "go-background"
},
"childNodes": [
{
"type": 3,
"textContent": "✅ Acknowledge",
"id": 16
}
],
"id": 15
},
{
"type": 3,
"textContent": "\n ",
"id": 17
},
{
"type": 3,
"textContent": "\n\n",
"id": 18
}
],
"id": 7
}
],
"id": 3
}
],
"id": 1
},
"initialOffset": {
"left": 0,
"top": 0
}
}
Loading