-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix clipboard read/write on regular elements in e2e tests #55030
base: trunk
Are you sure you want to change the base?
Changes from all commits
4db3f88
0987f26
7474ce6
8941952
14ab6d6
5b98d2c
c519666
cb0992f
fb2836b
04d4571
24c472d
55c091d
745f8da
152583b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -450,7 +450,7 @@ test.describe( 'Copy/cut/paste', () => { | |
// back to default browser behaviour, allowing the browser to insert | ||
// unfiltered HTML. When we swap out the post title in the post editor | ||
// with the proper block, this test can be removed. | ||
pageUtils.setClipboardData( { | ||
await pageUtils.setClipboardData( { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm seeing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is possibly due to outdated build. Try running |
||
html: '<span style="border: 1px solid black">Hello World</span>', | ||
} ); | ||
await pageUtils.pressKeys( 'primary+v' ); | ||
|
@@ -469,7 +469,7 @@ test.describe( 'Copy/cut/paste', () => { | |
} ) => { | ||
await page.keyboard.type( 'ab' ); | ||
await page.keyboard.press( 'ArrowLeft' ); | ||
pageUtils.setClipboardData( { | ||
await pageUtils.setClipboardData( { | ||
html: '<span style="border: 1px solid black">x</span>', | ||
} ); | ||
await pageUtils.pressKeys( 'primary+v' ); | ||
|
@@ -487,7 +487,7 @@ test.describe( 'Copy/cut/paste', () => { | |
pageUtils, | ||
editor, | ||
} ) => { | ||
pageUtils.setClipboardData( { | ||
await pageUtils.setClipboardData( { | ||
html: '<pre>x</pre>', | ||
} ); | ||
await editor.insertBlock( { name: 'core/list' } ); | ||
|
@@ -503,7 +503,7 @@ test.describe( 'Copy/cut/paste', () => { | |
attributes: { content: 'a' }, | ||
} ); | ||
await pageUtils.pressKeys( 'primary+a' ); | ||
pageUtils.setClipboardData( { | ||
await pageUtils.setClipboardData( { | ||
plainText: 'https://wordpress.org/gutenberg', | ||
html: '<a href="https://wordpress.org/gutenberg">https://wordpress.org/gutenberg</a>', | ||
} ); | ||
|
@@ -523,7 +523,7 @@ test.describe( 'Copy/cut/paste', () => { | |
name: 'core/paragraph', | ||
attributes: { content: 'a' }, | ||
} ); | ||
pageUtils.setClipboardData( { | ||
await pageUtils.setClipboardData( { | ||
plainText: 'https://wordpress.org/gutenberg', | ||
html: 'https://wordpress.org/gutenberg', | ||
} ); | ||
|
@@ -541,7 +541,7 @@ test.describe( 'Copy/cut/paste', () => { | |
|
||
test( 'should embed on paste', async ( { pageUtils, editor } ) => { | ||
await editor.insertBlock( { name: 'core/paragraph' } ); | ||
pageUtils.setClipboardData( { | ||
await pageUtils.setClipboardData( { | ||
plainText: 'https://www.youtube.com/watch?v=FcTLMTyD2DU', | ||
html: 'https://www.youtube.com/watch?v=FcTLMTyD2DU', | ||
} ); | ||
|
@@ -562,7 +562,7 @@ test.describe( 'Copy/cut/paste', () => { | |
}, | ||
} ); | ||
await pageUtils.pressKeys( 'primary+a' ); | ||
pageUtils.setClipboardData( { | ||
await pageUtils.setClipboardData( { | ||
plainText: 'movie: b', | ||
html: 'movie: b', | ||
} ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a safeguard to resolve the
Promise
if the method isn't able to add an event listener, primarily due toactiveElement
being unavailable. Is my logic/understanding here correct?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is here in case the event never fires. This could happen for
paste
events when the element doesn't attach an event listener and it needs to fallback to native "real" event. We need a flag here that basically meanshasEventHandled
, and it that'sfalse
we'll fire a real key press.I know this is all very confusing and I've been thinking about better ways to document this 😅. Maybe I should make a comparison table or something like that...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any additional documentation would be helpful here.