Skip to content

Commit 7734331

Browse files
committed
Some inconsequential tests to cover blocking scenarios
1 parent 4a751ee commit 7734331

4 files changed

+214
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[
2+
{
3+
"type": 3,
4+
"data": {
5+
"source": 0,
6+
"texts": [],
7+
"attributes": [],
8+
"removes": [],
9+
"adds": [
10+
{
11+
"parentId": 7,
12+
"nextId": null,
13+
"node": {
14+
"type": 2,
15+
"tagName": "div",
16+
"attributes": {},
17+
"childNodes": [],
18+
"id": 9
19+
}
20+
},
21+
{
22+
"parentId": 9,
23+
"nextId": null,
24+
"node": {
25+
"type": 2,
26+
"tagName": "div",
27+
"attributes": {
28+
"class": "rr-block",
29+
"rr_width": "1904px",
30+
"rr_height": "0px"
31+
},
32+
"childNodes": [],
33+
"id": 10
34+
}
35+
},
36+
{
37+
"parentId": 9,
38+
"nextId": 10,
39+
"node": {
40+
"type": 2,
41+
"tagName": "div",
42+
"attributes": {},
43+
"childNodes": [],
44+
"id": 11
45+
}
46+
}
47+
]
48+
}
49+
}
50+
]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[
2+
{
3+
"type": 3,
4+
"data": {
5+
"source": 0,
6+
"texts": [],
7+
"attributes": [],
8+
"removes": [],
9+
"adds": [
10+
{
11+
"parentId": 7,
12+
"nextId": null,
13+
"node": {
14+
"type": 2,
15+
"tagName": "div",
16+
"attributes": {},
17+
"childNodes": [],
18+
"id": 9
19+
}
20+
},
21+
{
22+
"parentId": 9,
23+
"nextId": null,
24+
"node": {
25+
"type": 2,
26+
"tagName": "div",
27+
"attributes": {},
28+
"childNodes": [],
29+
"id": 10
30+
}
31+
},
32+
{
33+
"parentId": 9,
34+
"nextId": 10,
35+
"node": {
36+
"type": 2,
37+
"tagName": "div",
38+
"attributes": {
39+
"class": "rr-block",
40+
"rr_width": "1904px",
41+
"rr_height": "0px"
42+
},
43+
"childNodes": [],
44+
"id": 11
45+
}
46+
}
47+
]
48+
}
49+
}
50+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
[
2+
{
3+
"type": 3,
4+
"data": {
5+
"source": 0,
6+
"texts": [],
7+
"attributes": [],
8+
"removes": [],
9+
"adds": [
10+
{
11+
"parentId": 7,
12+
"nextId": null,
13+
"node": {
14+
"type": 2,
15+
"tagName": "div",
16+
"attributes": {},
17+
"childNodes": [],
18+
"id": 9
19+
}
20+
},
21+
{
22+
"parentId": 9,
23+
"nextId": null,
24+
"node": {
25+
"type": 2,
26+
"tagName": "div",
27+
"attributes": {},
28+
"childNodes": [],
29+
"id": 10
30+
}
31+
},
32+
{
33+
"parentId": 9,
34+
"nextId": 10,
35+
"node": {
36+
"type": 2,
37+
"tagName": "div",
38+
"attributes": {
39+
"class": "rr-block",
40+
"rr_width": "1904px",
41+
"rr_height": "0px"
42+
},
43+
"childNodes": [],
44+
"id": 11
45+
}
46+
},
47+
{
48+
"parentId": 9,
49+
"nextId": 11,
50+
"node": {
51+
"type": 2,
52+
"tagName": "div",
53+
"attributes": {},
54+
"childNodes": [],
55+
"id": 12
56+
}
57+
}
58+
]
59+
}
60+
}
61+
]

packages/rrweb/test/record/mutation.test.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,57 @@ describe('mutation', () => {
209209
);
210210
await assertSnapshot(mutations, true);
211211
});
212+
213+
it('blocked firstchild element', async () => {
214+
await page.evaluate(() => {
215+
const d1 = document.createElement('div');
216+
document.body.append(d1);
217+
const b1 = document.createElement('div');
218+
b1.className = 'rr-block';
219+
b1.append(document.createElement('div')); // shouldn't show up
220+
b1.append(document.createElement('div')); // shouldn't show up
221+
const siblingDiv = document.createElement('div');
222+
d1.append(b1);
223+
d1.append(siblingDiv);
224+
});
225+
await waitForRAF(page);
226+
const mutations = events.filter((e)=>e.type === EventType.IncrementalSnapshot);
227+
await assertSnapshot(mutations, true);
228+
});
229+
230+
it('blocked middlechild element', async () => {
231+
await page.evaluate(() => {
232+
const d1 = document.createElement('div');
233+
document.body.append(d1);
234+
const b1 = document.createElement('div');
235+
b1.className = 'rr-block';
236+
b1.append(document.createElement('div')); // shouldn't show up
237+
b1.append(document.createElement('div')); // shouldn't show up
238+
const siblingDiv = document.createElement('div');
239+
const siblingDiv2 = document.createElement('div');
240+
d1.append(siblingDiv);
241+
d1.append(b1);
242+
d1.append(siblingDiv2);
243+
});
244+
await waitForRAF(page);
245+
const mutations = events.filter((e)=>e.type === EventType.IncrementalSnapshot);
246+
await assertSnapshot(mutations, true);
247+
});
248+
249+
it('blocked endchild element', async () => {
250+
await page.evaluate(() => {
251+
const d1 = document.createElement('div');
252+
document.body.append(d1);
253+
const b1 = document.createElement('div');
254+
b1.className = 'rr-block';
255+
b1.append(document.createElement('div')); // shouldn't show up
256+
b1.append(document.createElement('div')); // shouldn't show up
257+
const siblingDiv = document.createElement('div');
258+
d1.append(siblingDiv);
259+
d1.append(b1);
260+
});
261+
await waitForRAF(page);
262+
const mutations = events.filter((e)=>e.type === EventType.IncrementalSnapshot);
263+
await assertSnapshot(mutations, true);
264+
});
212265
});

0 commit comments

Comments
 (0)