Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
78849f3
WIP dialog recording
Juice10 Jun 10, 2024
c1d850f
chore: its important to run `yarn build:all` before running `yarn dev`
Juice10 Jun 10, 2024
b657233
feat: trigger showModal from rrdom and rrweb
Juice10 Jun 10, 2024
337b4c4
feat: Add support for replaying modal and non modal dialog elements
Juice10 Jun 11, 2024
29d4827
chore: Update dev script to remove CLEAR_DIST_DIR flag
Juice10 Jun 11, 2024
dcc867c
Get modal recording and replay working
Juice10 Jun 12, 2024
1144c9d
DRY up dialog test and dedupe snapshot images
Juice10 Jun 12, 2024
7507f4d
Fix eslint error
Juice10 Jun 12, 2024
b8679a0
feat: Refactor dialog test to use updated attribute name
Juice10 Jun 12, 2024
6ec4727
feat: Update dialog test to include rr_open attribute
Juice10 Jun 12, 2024
f7db71c
chore: Add npm dependency [email protected]
Juice10 Jun 12, 2024
b300674
Fix dialog test
Juice10 Jun 12, 2024
178ec1f
Add more test cases for dialog
Juice10 Jun 12, 2024
4229391
Add changesets
Juice10 Jun 12, 2024
b0065ce
Clean up naming
Juice10 Jun 12, 2024
25678f4
Apply formatting changes
Juice10 Jun 12, 2024
b71c8b7
Refactor dialog open code
Juice10 Jun 12, 2024
05d4cf0
Merge branch 'juice10/record-dialog' of https://github.com/rrweb-io/r…
Juice10 Jun 12, 2024
e731636
Revert changed code that doesn't do anything
Juice10 Jun 12, 2024
184e4fa
Add documentation for unimplemented type
Juice10 Jun 12, 2024
6a58edc
chore: Remove unnecessary comments in dialog.test.ts
Juice10 Jun 12, 2024
8c51129
Merge branch 'master' of https://github.com/rrweb-io/rrweb into juice…
Juice10 Jun 26, 2024
0df7994
rename rr_open to rr_openMode
Juice10 Jun 26, 2024
1ce8f70
Replace todo with a skipped test
Juice10 Jun 26, 2024
8aeb47f
Add better logging for CI
Juice10 Jun 26, 2024
985ac9f
Rename rr_openMode to rr_open_mode
Juice10 Jun 26, 2024
d693da9
Remove unused images
Juice10 Jun 26, 2024
760908f
Move after iframe append based on @YunFeng0817's comment
Juice10 Jul 9, 2024
2dfeb01
Remove redundant dialog handling from rrdom.
Juice10 Jul 9, 2024
63c0def
Merge branch 'master' into juice10/record-dialog
Juice10 Jul 9, 2024
21c4826
Rename variables for dialog handling in rrweb replay module
Juice10 Jul 9, 2024
424e4c8
Merge branch 'juice10/record-dialog' of https://github.com/rrweb-io/r…
Juice10 Jul 9, 2024
30c7780
Merge branch 'master' into juice10/record-dialog
eoghanmurray Jul 31, 2024
9f2a27c
Update packages/rrdom/src/document.ts
Juice10 Aug 2, 2024
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
Prev Previous commit
Next Next commit
DRY up dialog test and dedupe snapshot images
  • Loading branch information
Juice10 committed Jun 12, 2024
commit 1144c9d01f783d5ee5684b6719a54ab8dac77744
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
324 changes: 62 additions & 262 deletions packages/rrweb/test/replay/dialog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,255 +82,75 @@ describe('dialog', () => {
await hideMouseAnimation(page);
});

it('closed dialogs show nothing', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events);
`);
await waitForRAF(page);

const frameImage = await page!.screenshot();
expect(frameImage).toMatchImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: 'percent',
});
});

it('show show the dialog when open attribute gets added', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events);
window.replayer.pause(${showIncrementalAttributeTime});
`);
await waitForRAF(page);

const frameImage = await page!.screenshot();
expect(frameImage).toMatchImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: 'percent',
});
});

it('show show the dialog when open attribute gets added (non virtual)', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events, { useVirtualDom: false });
window.replayer.pause(${showIncrementalAttributeTime});
`);
await waitForRAF(page);

const frameImage = await page!.screenshot();
expect(frameImage).toMatchImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: 'percent',
});
});

it('should close dialog again when open attribute gets removed', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events);
window.replayer.pause(${closeIncrementalAttributeTime});
`);
await waitForRAF(page);

const frameImage = await page!.screenshot();
expect(frameImage).toMatchImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: 'percent',
[
{
name: 'show the dialog when open attribute gets added',
time: showIncrementalAttributeTime,
},
{
name: 'should close dialog again when open attribute gets removed',
time: closeIncrementalAttributeTime,
},
{
name: 'should open dialog with showModal',
time: showModalIncrementalAttributeTime,
},
{
name: 'should switch between showModal and show',
time: switchBetweenShowModalAndShowIncrementalAttributeTime,
},
{
name: 'should switch between show and showModal',
time: switchBetweenShowAndShowModalIncrementalAttributeTime,
},
{
name: 'should open dialog with show in full snapshot',
time: showFullSnapshotTime,
},
{
name: 'should open dialog with showModal in full snapshot',
time: showModalFullSnapshotTime,
},
{
name: 'should add an opened dialog with showModal in incremental snapshot',
time: showModalIncrementalAddTime,
},
].forEach(({ name, time }) => {
[true, false].forEach((useVirtualDom) => {
it(`${name} (virtual dom: ${useVirtualDom})`, async () => {
await page.evaluate(
`let events = ${JSON.stringify(dialogPlaybackEvents)}`,
);
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events, { useVirtualDom: ${useVirtualDom} });
window.replayer.pause(${time});
`);
await waitForRAF(page);

const frameImage = await page!.screenshot({
fullPage: false,
});
const defaultImageFilePrefix =
'dialog-test-ts-test-replay-dialog-test-ts-dialog';
const kebabCaseName = name
.replace(/ /g, '-')
.replace(/showModal/g, 'show-modal');
const imageFileName = `${defaultImageFilePrefix}-${kebabCaseName}`;
expect(frameImage).toMatchImageSnapshot({
customSnapshotIdentifier: imageFileName,
failureThreshold: 0.05,
failureThresholdType: 'percent',
});
});
});
});

it('should close dialog again when open attribute gets removed (without virtual dom)', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events, { useVirtualDom: false });
window.replayer.pause(${closeIncrementalAttributeTime});
`);
await waitForRAF(page);

const frameImage = await page!.screenshot();
expect(frameImage).toMatchImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: 'percent',
});
});

it('should open dialog with showModal', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events);
window.replayer.pause(${showModalIncrementalAttributeTime});
`);
await waitForRAF(page);

const frameImage = await page!.screenshot();
expect(frameImage).toMatchImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: 'percent',
});
});

it('should open dialog with showModal (without virtual dom)', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events, { useVirtualDom: false });
window.replayer.pause(${showModalIncrementalAttributeTime});
`);
await waitForRAF(page);

const frameImage = await page!.screenshot();
expect(frameImage).toMatchImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: 'percent',
});
});

it('should switch between showModal and show', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events);
window.replayer.pause(${switchBetweenShowModalAndShowIncrementalAttributeTime});
`);
await waitForRAF(page);

const frameImage = await page!.screenshot();
expect(frameImage).toMatchImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: 'percent',
});
});

it('should switch between showModal and show (without virtual dom)', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events, { useVirtualDom: false });
window.replayer.pause(${switchBetweenShowModalAndShowIncrementalAttributeTime});
`);
await waitForRAF(page);

const frameImage = await page!.screenshot();
expect(frameImage).toMatchImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: 'percent',
});
});

it('should switch between show and showModal', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events);
window.replayer.pause(${switchBetweenShowAndShowModalIncrementalAttributeTime});
`);
await waitForRAF(page);

const frameImage = await page!.screenshot();
expect(frameImage).toMatchImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: 'percent',
});
});

it('should switch between show and showModal (without virtual dom)', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events, { useVirtualDom: false });
window.replayer.pause(${switchBetweenShowAndShowModalIncrementalAttributeTime});
`);
await waitForRAF(page);

const frameImage = await page!.screenshot();
expect(frameImage).toMatchImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: 'percent',
});
});

it('should open dialog with show in full snapshot', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events);
window.replayer.pause(${showFullSnapshotTime});
`);
await waitForRAF(page);

const frameImage = await page!.screenshot();
expect(frameImage).toMatchImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: 'percent',
});
});

it('should open dialog with show in full snapshot (without virtual dom)', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events, { useVirtualDom: false });
window.replayer.pause(${showFullSnapshotTime});
`);
await waitForRAF(page);

const frameImage = await page!.screenshot();
expect(frameImage).toMatchImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: 'percent',
});
});

it('should open dialog with showModal in full snapshot', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events);
window.replayer.pause(${showModalFullSnapshotTime});
`);
await waitForRAF(page);

const frameImage = await page!.screenshot();
expect(frameImage).toMatchImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: 'percent',
});
});

it('should open dialog with showModal in full snapshot (without virtual dom)', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
try {
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events, { useVirtualDom: false });
window.replayer.pause(${showModalFullSnapshotTime});
`);
} catch (e) {
console.log('error');
}
await waitForRAF(page);

const frameImage = await page!.screenshot();
expect(frameImage).toMatchImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: 'percent',
});
});

it('should add an opened dialog with showModal in incremental snapshot', async () => {
it('closed dialogs show nothing', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events);
window.replayer.pause(${showModalIncrementalAddTime});
`);
await waitForRAF(page);

Expand All @@ -340,24 +160,4 @@ describe('dialog', () => {
failureThresholdType: 'percent',
});
});

it('should add an opened dialog with showModal in incremental snapshot (without virtual dom)', async () => {
await page.evaluate(`let events = ${JSON.stringify(dialogPlaybackEvents)}`);
try {
await page.evaluate(`
const { Replayer } = rrweb;
window.replayer = new Replayer(events, { useVirtualDom: false });
window.replayer.pause(${showModalIncrementalAddTime});
`);
} catch (e) {
console.log('error');
}
await waitForRAF(page);

const frameImage = await page!.screenshot();
expect(frameImage).toMatchImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: 'percent',
});
});
});