forked from rrweb-io/rrweb
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Trigger mouse movement & hover with mouse up/down in sync mode (r…
…rweb-io#1191) * Trigger mouse movement & hover with mouse up/down in sync mode * Trigger touchActive and mouseDown on flush
- Loading branch information
Showing
6 changed files
with
220 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'rrweb': patch | ||
--- | ||
|
||
Only apply touch-active styling on flush |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'rrweb': patch | ||
--- | ||
|
||
Trigger mouse movement and hover with mouse up and mouse down events when replayer.pause(...) is called. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import { IncrementalSource, MouseInteractions } from '@rrweb/types'; | ||
import type { eventWithTime } from '../../../types/src'; | ||
|
||
const events: eventWithTime[] = [ | ||
{ | ||
type: 4, | ||
data: { | ||
href: '', | ||
width: 1600, | ||
height: 900, | ||
}, | ||
timestamp: 0, | ||
}, | ||
{ | ||
type: 2, | ||
data: { | ||
node: { | ||
type: 0, | ||
childNodes: [ | ||
{ type: 1, name: 'html', publicId: '', systemId: '', id: 2 }, | ||
{ | ||
type: 2, | ||
tagName: 'html', | ||
attributes: { lang: 'en' }, | ||
childNodes: [ | ||
{ | ||
type: 2, | ||
tagName: 'head', | ||
attributes: {}, | ||
childNodes: [ | ||
{ | ||
id: 101, | ||
type: 2, | ||
tagName: 'style', | ||
attributes: {}, | ||
childNodes: [ | ||
{ | ||
id: 102, | ||
type: 3, | ||
isStyle: true, | ||
textContent: 'div:hover { background-color: gold; }', | ||
}, | ||
], | ||
}, | ||
], | ||
id: 4, | ||
}, | ||
{ type: 3, textContent: '\n ', id: 13 }, | ||
{ | ||
type: 2, | ||
tagName: 'body', | ||
attributes: {}, | ||
childNodes: [ | ||
{ type: 3, textContent: '\n ', id: 15 }, | ||
{ | ||
type: 2, | ||
tagName: 'div', | ||
attributes: { | ||
style: | ||
'border: 1px solid #000000; width: 100px; height: 100px;', | ||
}, | ||
childNodes: [{ type: 3, textContent: '\n ', id: 17 }], | ||
id: 16, | ||
}, | ||
], | ||
id: 14, | ||
}, | ||
], | ||
id: 3, | ||
}, | ||
], | ||
id: 1, | ||
}, | ||
initialOffset: { left: 0, top: 0 }, | ||
}, | ||
timestamp: 10, | ||
}, | ||
{ | ||
type: 3, | ||
data: { | ||
source: IncrementalSource.MouseInteraction, | ||
type: MouseInteractions.MouseDown, | ||
id: 16, | ||
x: 30, | ||
y: 30, | ||
}, | ||
timestamp: 100, | ||
}, | ||
{ | ||
type: 3, | ||
data: { | ||
source: IncrementalSource.MouseInteraction, | ||
type: MouseInteractions.MouseUp, | ||
id: 16, | ||
x: 30, | ||
y: 30, | ||
}, | ||
timestamp: 150, | ||
}, | ||
{ | ||
type: 3, | ||
data: { | ||
source: IncrementalSource.MouseInteraction, | ||
type: MouseInteractions.Click, | ||
id: 16, | ||
x: 30, | ||
y: 30, | ||
}, | ||
timestamp: 155, | ||
}, | ||
]; | ||
|
||
export default events; |
Binary file added
BIN
+11.5 KB
...ts__/hover-test-ts-replayer-hover-should-trigger-hover-on-mouse-down-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import { launchPuppeteer, waitForRAF } from '../utils'; | ||
import { toMatchImageSnapshot } from 'jest-image-snapshot'; | ||
import type * as puppeteer from 'puppeteer'; | ||
import events from '../events/hover'; | ||
|
||
interface ISuite { | ||
code: string; | ||
styles: string; | ||
browser: puppeteer.Browser; | ||
page: puppeteer.Page; | ||
} | ||
|
||
expect.extend({ toMatchImageSnapshot }); | ||
|
||
describe('replayer', function () { | ||
jest.setTimeout(10_000); | ||
|
||
let code: ISuite['code']; | ||
let styles: ISuite['styles']; | ||
let browser: ISuite['browser']; | ||
let page: ISuite['page']; | ||
|
||
beforeAll(async () => { | ||
browser = await launchPuppeteer({ devtools: true }); | ||
|
||
const bundlePath = path.resolve(__dirname, '../../dist/rrweb.js'); | ||
const stylePath = path.resolve( | ||
__dirname, | ||
'../../src/replay/styles/style.css', | ||
); | ||
code = fs.readFileSync(bundlePath, 'utf8'); | ||
styles = fs.readFileSync(stylePath, 'utf8'); | ||
}); | ||
|
||
beforeEach(async () => { | ||
page = await browser.newPage(); | ||
await page.goto('about:blank'); | ||
await page.addStyleTag({ | ||
content: styles, | ||
}); | ||
await page.evaluate(code); | ||
await page.evaluate(`let events = ${JSON.stringify(events)}`); | ||
|
||
page.on('console', (msg) => console.log('PAGE LOG:', msg.text())); | ||
}); | ||
|
||
afterEach(async () => { | ||
await page.close(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await browser.close(); | ||
}); | ||
|
||
describe('hover', () => { | ||
it('should trigger hover on mouseDown', async () => { | ||
await page.evaluate(` | ||
const { Replayer } = rrweb; | ||
const replayer = new Replayer(events); | ||
replayer.pause(110); // mouseDown event is at 100 | ||
`); | ||
|
||
await waitForRAF(page); | ||
|
||
const image = await page.screenshot(); | ||
expect(image).toMatchImageSnapshot(); | ||
}); | ||
}); | ||
}); |