-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Support top-layer <dialog> recording & replay #1503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
78849f3
WIP dialog recording
Juice10 c1d850f
chore: its important to run `yarn build:all` before running `yarn dev`
Juice10 b657233
feat: trigger showModal from rrdom and rrweb
Juice10 337b4c4
feat: Add support for replaying modal and non modal dialog elements
Juice10 29d4827
chore: Update dev script to remove CLEAR_DIST_DIR flag
Juice10 dcc867c
Get modal recording and replay working
Juice10 1144c9d
DRY up dialog test and dedupe snapshot images
Juice10 7507f4d
Fix eslint error
Juice10 b8679a0
feat: Refactor dialog test to use updated attribute name
Juice10 6ec4727
feat: Update dialog test to include rr_open attribute
Juice10 f7db71c
chore: Add npm dependency [email protected]
Juice10 b300674
Fix dialog test
Juice10 178ec1f
Add more test cases for dialog
Juice10 4229391
Add changesets
Juice10 b0065ce
Clean up naming
Juice10 25678f4
Apply formatting changes
Juice10 b71c8b7
Refactor dialog open code
Juice10 05d4cf0
Merge branch 'juice10/record-dialog' of https://github.com/rrweb-io/r…
Juice10 e731636
Revert changed code that doesn't do anything
Juice10 184e4fa
Add documentation for unimplemented type
Juice10 6a58edc
chore: Remove unnecessary comments in dialog.test.ts
Juice10 8c51129
Merge branch 'master' of https://github.com/rrweb-io/rrweb into juice…
Juice10 0df7994
rename rr_open to rr_openMode
Juice10 1ce8f70
Replace todo with a skipped test
Juice10 8aeb47f
Add better logging for CI
Juice10 985ac9f
Rename rr_openMode to rr_open_mode
Juice10 d693da9
Remove unused images
Juice10 760908f
Move after iframe append based on @YunFeng0817's comment
Juice10 2dfeb01
Remove redundant dialog handling from rrdom.
Juice10 63c0def
Merge branch 'master' into juice10/record-dialog
Juice10 21c4826
Rename variables for dialog handling in rrweb replay module
Juice10 424e4c8
Merge branch 'juice10/record-dialog' of https://github.com/rrweb-io/r…
Juice10 30c7780
Merge branch 'master' into juice10/record-dialog
eoghanmurray 9f2a27c
Update packages/rrdom/src/document.ts
Juice10 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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-snapshot": minor | ||
--- | ||
|
||
Record dialog's modal status for replay in rrweb. (Currently triggering `dialog.showModal()` is not supported in rrweb-snapshot's rebuild) |
This file contains hidden or 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,7 @@ | ||
--- | ||
"rrdom": minor | ||
"rrweb": minor | ||
"@rrweb/types": minor | ||
--- | ||
|
||
Support top-layer <dialog> components. Fixes #1381. |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,112 @@ | ||
/** | ||
* @vitest-environment happy-dom | ||
*/ | ||
import { vi, MockInstance } from 'vitest'; | ||
import { | ||
NodeType as RRNodeType, | ||
createMirror, | ||
Mirror as NodeMirror, | ||
serializedNodeWithId, | ||
} from 'rrweb-snapshot'; | ||
import { RRDocument } from '../../src'; | ||
import { diff, ReplayerHandler } from '../../src/diff'; | ||
|
||
describe('diff algorithm for rrdom', () => { | ||
let mirror: NodeMirror; | ||
let replayer: ReplayerHandler; | ||
let warn: MockInstance; | ||
let elementSn: serializedNodeWithId; | ||
let elementSn2: serializedNodeWithId; | ||
|
||
beforeEach(() => { | ||
mirror = createMirror(); | ||
replayer = { | ||
mirror, | ||
applyCanvas: () => {}, | ||
applyInput: () => {}, | ||
applyScroll: () => {}, | ||
applyStyleSheetMutation: () => {}, | ||
afterAppend: () => {}, | ||
}; | ||
document.write('<!DOCTYPE html><html><head></head><body></body></html>'); | ||
// Mock the original console.warn function to make the test fail once console.warn is called. | ||
warn = vi.spyOn(console, 'warn'); | ||
|
||
elementSn = { | ||
type: RRNodeType.Element, | ||
tagName: 'DIALOG', | ||
attributes: {}, | ||
childNodes: [], | ||
id: 1, | ||
}; | ||
|
||
elementSn2 = { | ||
...elementSn, | ||
attributes: {}, | ||
}; | ||
}); | ||
|
||
afterEach(() => { | ||
// Check that warn was not called (fail on warning) | ||
expect(warn).not.toBeCalled(); | ||
vi.resetAllMocks(); | ||
}); | ||
describe('diff dialog elements', () => { | ||
vi.setConfig({ testTimeout: 60_000 }); | ||
|
||
it('should trigger `showModal` on rr_open_mode:modal attributes', () => { | ||
const tagName = 'DIALOG'; | ||
const node = document.createElement(tagName) as HTMLDialogElement; | ||
vi.spyOn(node, 'matches').mockReturnValue(false); // matches is used to check if the dialog was opened with showModal | ||
const showModalFn = vi.spyOn(node, 'showModal'); | ||
|
||
const rrDocument = new RRDocument(); | ||
const rrNode = rrDocument.createElement(tagName); | ||
rrNode.attributes = { rr_open_mode: 'modal', open: '' }; | ||
|
||
mirror.add(node, elementSn); | ||
rrDocument.mirror.add(rrNode, elementSn); | ||
diff(node, rrNode, replayer); | ||
|
||
expect(showModalFn).toBeCalled(); | ||
}); | ||
|
||
it('should trigger `close` on rr_open_mode removed', () => { | ||
const tagName = 'DIALOG'; | ||
const node = document.createElement(tagName) as HTMLDialogElement; | ||
node.showModal(); | ||
vi.spyOn(node, 'matches').mockReturnValue(true); // matches is used to check if the dialog was opened with showModal | ||
const closeFn = vi.spyOn(node, 'close'); | ||
|
||
const rrDocument = new RRDocument(); | ||
const rrNode = rrDocument.createElement(tagName); | ||
rrNode.attributes = {}; | ||
|
||
mirror.add(node, elementSn); | ||
rrDocument.mirror.add(rrNode, elementSn); | ||
diff(node, rrNode, replayer); | ||
|
||
expect(closeFn).toBeCalled(); | ||
}); | ||
|
||
it('should not trigger `close` on rr_open_mode is kept', () => { | ||
const tagName = 'DIALOG'; | ||
const node = document.createElement(tagName) as HTMLDialogElement; | ||
vi.spyOn(node, 'matches').mockReturnValue(true); // matches is used to check if the dialog was opened with showModal | ||
node.setAttribute('rr_open_mode', 'modal'); | ||
node.setAttribute('open', ''); | ||
const closeFn = vi.spyOn(node, 'close'); | ||
|
||
const rrDocument = new RRDocument(); | ||
const rrNode = rrDocument.createElement(tagName); | ||
rrNode.attributes = { rr_open_mode: 'modal', open: '' }; | ||
|
||
mirror.add(node, elementSn); | ||
rrDocument.mirror.add(rrNode, elementSn); | ||
diff(node, rrNode, replayer); | ||
|
||
expect(closeFn).not.toBeCalled(); | ||
expect(node.open).toBe(true); | ||
}); | ||
}); | ||
}); |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.