Editor: Refactor 'PostPublishButton' into function component#78737
Conversation
|
Size Change: -174 B (0%) Total Size: 8.21 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Flaky tests detected in d97fb17. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/26517728136
|
| export class PostPublishButton extends Component { | ||
| constructor( props ) { | ||
| super( props ); | ||
| export default function PostPublishButton( { |
There was a problem hiding this comment.
Just verifying that you intended to remove the named export and go just with the default export?
There was a problem hiding this comment.
Reverted this to the original. We don't really need two exports, but this allows us to keep the autogenerated docs the same.
|
|
||
| // The label component runs its own selectors. Stub it so each test can | ||
| // assert on a stable button name without coupling to the label's logic. | ||
| jest.mock( '../label', () => () => 'Submit for Review' ); |
There was a problem hiding this comment.
I think humans or agents could be confused by this hardcoded label in tests. Should we instead use a test id or something similar generic that avoids this potential confusion?
There was a problem hiding this comment.
Changed to just use a role-based selector; the component only renders a single element, so we should be good.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
d97fb17 to
6897972
Compare
What?
Supersedes #73992.
Decided to clean this up while working on #78659.
PR refacators 'PostPublishButton' into a function component, replacing HoC with appropriate hooks.
The
entitiesSavedStatescallback bookkeeping (previously held in component state) is gone; each click now builds its own closure that's handed to the parent, so no state or ref is needed.Testing Instructions
Testing Instructions for Keyboard
Same.
Use of AI Tools
Assisted by Claude.