From db4fbd51595be8c91907a153d77ea0c6f0ec788f Mon Sep 17 00:00:00 2001 From: Eoghan Murray Date: Fri, 14 May 2021 16:43:22 +0100 Subject: [PATCH] Add a test for the idea that emissions should be weakly ascending over the timestamp attribute --- packages/rrweb/test/utils.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/rrweb/test/utils.ts b/packages/rrweb/test/utils.ts index 6a2ac5811b..3c80da6861 100644 --- a/packages/rrweb/test/utils.ts +++ b/packages/rrweb/test/utils.ts @@ -46,6 +46,7 @@ export function matchSnapshot( * @param snapshots incrementalSnapshotEvent[] */ function stringifySnapshots(snapshots: eventWithTime[]): string { + let asc_time = 0; return JSON.stringify( snapshots .filter((s) => { @@ -110,6 +111,21 @@ function stringifySnapshots(snapshots: eventWithTime[]): string { coordinatesReg.lastIndex = 0; // wow, a real wart in ECMAScript }); } + if ( + s.type === EventType.IncrementalSnapshot && + (s.data.source === IncrementalSource.MouseMove + || s.data.source === IncrementalSource.TouchMove + || s.data.source === IncrementalSource.Drag) + ) { + s.data.positions.forEach((p) => { + let t = s.timestamp + p.timeOffset; + assert(asc_time <= t); + asc_time = t; + }); + } else { + assert(asc_time <= s.timestamp); + asc_time = s.timestamp; + } delete s.timestamp; return s; }),