Skip to content

Commit

Permalink
tests that pass
Browse files Browse the repository at this point in the history
  • Loading branch information
michellewzhang committed May 30, 2024
1 parent d9d3075 commit e1af343
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
6 changes: 6 additions & 0 deletions packages/rrweb/test/events/touch-all-pointer-id.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
EventType,
IncrementalSource,
MouseInteractions,
} from '@sentry-internal/rrweb-types';
Expand Down Expand Up @@ -170,6 +171,11 @@ const events: eventWithTime[] = [
},
timestamp: 155,
},
{
type: EventType.IncrementalSnapshot,
data: { source: IncrementalSource.Scroll, id: 1, x: 0, y: 250 },
timestamp: 220,
},
];

export default events;
6 changes: 6 additions & 0 deletions packages/rrweb/test/events/touch-some-pointer-id.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
EventType,
IncrementalSource,
MouseInteractions,
} from '@sentry-internal/rrweb-types';
Expand Down Expand Up @@ -167,6 +168,11 @@ const events: eventWithTime[] = [
},
timestamp: 155,
},
{
type: EventType.IncrementalSnapshot,
data: { source: IncrementalSource.Scroll, id: 1, x: 0, y: 250 },
timestamp: 220,
},
];

export default events;
19 changes: 11 additions & 8 deletions packages/rrweb/test/replayer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type IWindow = Window &
typeof globalThis & { rrweb: typeof import('../src'); events: typeof events };

describe('replayer', function () {
jest.setTimeout(300_000);
jest.setTimeout(10_000);

let code: ISuite['code'];
let browser: ISuite['browser'];
Expand Down Expand Up @@ -797,7 +797,7 @@ describe('replayer', function () {
// No active pointers should exist
await expect(
await page.evaluate(
() => document.querySelectorAll('.replayer-mouse')!.length,
() => document.querySelectorAll('.touch-active')!.length,
),
).toEqual(0);

Expand All @@ -808,7 +808,7 @@ describe('replayer', function () {
// 2 pointers should exist
await expect(
await page.evaluate(
() => document.querySelectorAll('.replayer-mouse')!.length,
() => document.querySelectorAll('.touch-active')!.length,
),
).toEqual(2);

Expand All @@ -817,6 +817,8 @@ describe('replayer', function () {
replayer.play();
`);

await page.waitForTimeout(160);

// Both pointers should be removed after the TouchEnd event
await expect(
await page.evaluate(
Expand All @@ -826,7 +828,7 @@ describe('replayer', function () {
});

// This should't happen, but we want to test/capture the behavior
it.only('has a pointer for touch interactions with some pointerIds', async () => {
it('has a pointer for touch interactions with some pointerIds', async () => {
await page.evaluate(`events = ${JSON.stringify(touchSomePointerEvents)}`);
await page.evaluate(`
const { Replayer } = rrweb;
Expand All @@ -837,27 +839,28 @@ describe('replayer', function () {
// No active pointers should exist
await expect(
await page.evaluate(
() => document.querySelectorAll('.replayer-mouse')!.length,
() => document.querySelectorAll('.touch-active')!.length,
),
).toEqual(0);

await page.evaluate(`
replayer.pause(101);
window.pointers = replayer.pointers;
`);

// 2 pointers should exist
await expect(
await page.evaluate(
() => document.querySelectorAll('.replayer-mouse')!.length,
() => document.querySelectorAll('.touch-active')!.length,
),
).toEqual(2);

await page.evaluate(`
replayer.pause(200);
replayer.pause(220);
replayer.play();
`);

await page.waitForTimeout(220);

// Both pointers should be removed after the TouchEnd event
await expect(
await page.evaluate(
Expand Down

0 comments on commit e1af343

Please sign in to comment.