Skip to content
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

Improve automated regression testing for paste bugs for inline rich text #36392

Open
getdave opened this issue Nov 11, 2021 · 0 comments
Open
Assignees
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.

Comments

@getdave
Copy link
Contributor

getdave commented Nov 11, 2021

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"...

const isInternal = clipboardData.getData( 'rich-text' ) === 'true';

...then all the filters in pasteHandler are skipped.

// If the data comes from a rich text instance, we can directly use it
// without filtering the data. The filters are only meant for externally
// pasted content and remove inline styles.
if ( isInternal ) {

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 modify pasteHandler with an inline-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)

@getdave getdave added the [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. label Nov 11, 2021
@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

3 participants