DB-6671: Preview Button Regression in WordPress 6.3 #58
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.
In WordPress 6.3 dispatching an autosave event in the block editor via JS now triggers additional actions by WordPress that expect the default preview button to exist. This was causing React to throw an exception in the block editor.
In order to resolve this, we're now hiding the standard preview button with CSS rather than removing it from the dom via JS.
I also took a long look at adding test coverage for this. Since this functionality depends on client side JS our existing suite of PHP unit tests won't help. From what I can tell, WordPress does not have a core solution for functional or browser tests. The only JS testing is JQuery unit testing, which I also don't think can cover this use case. wp-browser (https://wpbrowser.wptestkit.dev/) seems like it would meet our needs, but the implementation would be outside the scope of this ticket. wp-browser uses codeception rather than phpunit, and assumes that a live WordPress environment already exists.
We have an upcoming need for End to End testing, so I think that would be the most efficient way to address this.
Long term: