Improve automated regression testing for paste bugs for inline rich text #36392
Labels
[Type] Automated Testing
Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.
[Type] Enhancement
A suggestion for improvement.
In #36356 we found a bug whereby internally pasted links were prefixed with a
<meta charset>
tag. When trying to add an integration test to cover this I discovered we're missing test coverage for any internally pasted content that comes from a rich text instance.More info below:
I was looking at adding an integration test to cover this. Initially it seemed like we already have one but upon closer testing it doesn't assert on the same problem.
According to the
usePasteHandler
code, if the content is identified as being "internal"...gutenberg/packages/block-editor/src/components/rich-text/use-paste-handler.js
Line 126 in 7a41d02
...then all the filters in
pasteHandler
are skipped.gutenberg/packages/block-editor/src/components/rich-text/use-paste-handler.js
Lines 128 to 131 in 7a41d02
These filters are those within
pasteHandler
- one of which strips meta (such as is fixed by this PR).Therefore the integration test which exclusively uses
pasteHandler
and includes a test for<meta charset>
will pass, but this bug where meta is added to internal pasted content will continue to manifest itself in the Editor.It looks like we can't pass inline pasted content through
pasteHandler
as it will strip things that are considered safe within an inline context. However, perhaps we need to modifypasteHandler
with aninline-rich
mode to allow us to apply selective filters to rich inline content.If we don't do something it's going to be very difficult to assert on the handling of pasting rich inline content. For example, I tired adding an e2e tests to cover the
<meta charset
scenario but the "bug" will not manifest in Puppeteer.Do you have any thoughts on the best way forward here?
Originally posted by @getdave in #36356 (comment)
The text was updated successfully, but these errors were encountered: