Skip to content

Commit c5c223c

Browse files
authored
test(replay): Ensure that unicode characters are handled correctly (#7252)
1 parent e60cd02 commit c5c223c

14 files changed

+1108
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
window.Sentry = Sentry;
4+
window.Replay = new Sentry.Replay({
5+
flushMinDelay: 500,
6+
flushMaxDelay: 500,
7+
useCompression: true,
8+
maskAllText: false,
9+
});
10+
11+
Sentry.init({
12+
dsn: 'https://[email protected]/1337',
13+
sampleRate: 0,
14+
replaysSessionSampleRate: 1.0,
15+
replaysOnErrorSampleRate: 0.0,
16+
17+
integrations: [window.Replay],
18+
});
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
import {
5+
getFullRecordingSnapshots,
6+
normalize,
7+
shouldSkipReplayTest,
8+
waitForReplayRequest,
9+
} from '../../../../utils/replayHelpers';
10+
11+
sentryTest('replay should handle unicode characters', async ({ getLocalTestPath, page }) => {
12+
if (shouldSkipReplayTest()) {
13+
sentryTest.skip();
14+
}
15+
16+
const reqPromise0 = waitForReplayRequest(page, 0);
17+
18+
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
19+
return route.fulfill({
20+
status: 200,
21+
contentType: 'application/json',
22+
body: JSON.stringify({ id: 'test-id' }),
23+
});
24+
});
25+
26+
const url = await getLocalTestPath({ testDir: __dirname });
27+
28+
await page.goto(url);
29+
const snapshots = getFullRecordingSnapshots(await reqPromise0);
30+
31+
expect(snapshots.length).toEqual(1);
32+
expect(normalize(snapshots[0])).toMatchSnapshot('unicode-compressed.json');
33+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"node": {
3+
"type": 0,
4+
"childNodes": [
5+
{
6+
"type": 1,
7+
"name": "html",
8+
"publicId": "",
9+
"systemId": "",
10+
"id": 2
11+
},
12+
{
13+
"type": 2,
14+
"tagName": "html",
15+
"attributes": {},
16+
"childNodes": [
17+
{
18+
"type": 2,
19+
"tagName": "head",
20+
"attributes": {},
21+
"childNodes": [
22+
{
23+
"type": 2,
24+
"tagName": "meta",
25+
"attributes": {
26+
"charset": "utf-8"
27+
},
28+
"childNodes": [],
29+
"id": 5
30+
}
31+
],
32+
"id": 4
33+
},
34+
{
35+
"type": 3,
36+
"textContent": "\n ",
37+
"id": 6
38+
},
39+
{
40+
"type": 2,
41+
"tagName": "body",
42+
"attributes": {},
43+
"childNodes": [
44+
{
45+
"type": 3,
46+
"textContent": "\n ",
47+
"id": 8
48+
},
49+
{
50+
"type": 2,
51+
"tagName": "h1",
52+
"attributes": {},
53+
"childNodes": [
54+
{
55+
"type": 3,
56+
"textContent": "Hi 👋👋👋",
57+
"id": 10
58+
}
59+
],
60+
"id": 9
61+
},
62+
{
63+
"type": 3,
64+
"textContent": "\n ",
65+
"id": 11
66+
},
67+
{
68+
"type": 2,
69+
"tagName": "p",
70+
"attributes": {},
71+
"childNodes": [
72+
{
73+
"type": 3,
74+
"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 ",
75+
"id": 13
76+
}
77+
],
78+
"id": 12
79+
},
80+
{
81+
"type": 3,
82+
"textContent": "\n\n ",
83+
"id": 14
84+
},
85+
{
86+
"type": 2,
87+
"tagName": "button",
88+
"attributes": {
89+
"id": "go-background"
90+
},
91+
"childNodes": [
92+
{
93+
"type": 3,
94+
"textContent": "✅ Acknowledge",
95+
"id": 16
96+
}
97+
],
98+
"id": 15
99+
},
100+
{
101+
"type": 3,
102+
"textContent": "\n ",
103+
"id": 17
104+
},
105+
{
106+
"type": 3,
107+
"textContent": "\n\n",
108+
"id": 18
109+
}
110+
],
111+
"id": 7
112+
}
113+
],
114+
"id": 3
115+
}
116+
],
117+
"id": 1
118+
},
119+
"initialOffset": {
120+
"left": 0,
121+
"top": 0
122+
}
123+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"node": {
3+
"type": 0,
4+
"childNodes": [
5+
{
6+
"type": 1,
7+
"name": "html",
8+
"publicId": "",
9+
"systemId": "",
10+
"id": 2
11+
},
12+
{
13+
"type": 2,
14+
"tagName": "html",
15+
"attributes": {},
16+
"childNodes": [
17+
{
18+
"type": 2,
19+
"tagName": "head",
20+
"attributes": {},
21+
"childNodes": [
22+
{
23+
"type": 2,
24+
"tagName": "meta",
25+
"attributes": {
26+
"charset": "utf-8"
27+
},
28+
"childNodes": [],
29+
"id": 5
30+
}
31+
],
32+
"id": 4
33+
},
34+
{
35+
"type": 3,
36+
"textContent": "\n ",
37+
"id": 6
38+
},
39+
{
40+
"type": 2,
41+
"tagName": "body",
42+
"attributes": {},
43+
"childNodes": [
44+
{
45+
"type": 3,
46+
"textContent": "\n ",
47+
"id": 8
48+
},
49+
{
50+
"type": 2,
51+
"tagName": "h1",
52+
"attributes": {},
53+
"childNodes": [
54+
{
55+
"type": 3,
56+
"textContent": "Hi 👋👋👋",
57+
"id": 10
58+
}
59+
],
60+
"id": 9
61+
},
62+
{
63+
"type": 3,
64+
"textContent": "\n ",
65+
"id": 11
66+
},
67+
{
68+
"type": 2,
69+
"tagName": "p",
70+
"attributes": {},
71+
"childNodes": [
72+
{
73+
"type": 3,
74+
"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 ",
75+
"id": 13
76+
}
77+
],
78+
"id": 12
79+
},
80+
{
81+
"type": 3,
82+
"textContent": "\n\n ",
83+
"id": 14
84+
},
85+
{
86+
"type": 2,
87+
"tagName": "button",
88+
"attributes": {
89+
"id": "go-background"
90+
},
91+
"childNodes": [
92+
{
93+
"type": 3,
94+
"textContent": "✅ Acknowledge",
95+
"id": 16
96+
}
97+
],
98+
"id": 15
99+
},
100+
{
101+
"type": 3,
102+
"textContent": "\n ",
103+
"id": 17
104+
},
105+
{
106+
"type": 3,
107+
"textContent": "\n\n",
108+
"id": 18
109+
}
110+
],
111+
"id": 7
112+
}
113+
],
114+
"id": 3
115+
}
116+
],
117+
"id": 1
118+
},
119+
"initialOffset": {
120+
"left": 0,
121+
"top": 0
122+
}
123+
}

0 commit comments

Comments
 (0)