-
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
BorderBoxControl: migrate tests to TypeScript, remove act()
call
#47755
Conversation
Size Change: 0 B Total Size: 1.31 MB ℹ️ View Unchanged
|
Flaky tests detected in c1b1d9b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4105491572
|
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.
Thanks for finishing off the conversion of the BorderBoxControl to TypeScript @ciampo 👍
The changes look good.
✅ No typing errors
✅ Unit tests are passing locally.
✅ Updates look good. No runtime changes.
Regarding the remaining timeout error in the failed e2e, that looks related to a different test than the one commented on in this PR. I couldn't, however, replicate the problem locally. 🤔
|
||
render( <BorderBoxControl { ...props } enableStyle={ false } /> ); | ||
it.each( colorButtonIndexes )( |
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.
I've noticed that this test times out on CI (not locally though) so in bde3e09 I've split it to separate tests that target each button separately. This should distribute the effort and make tests run within the 5s limit.
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.
That fixed it, thank you!
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.
I've added a commit to fix the test timeout and left some thoughts, but this looks great IMHO 👍 🚀 Nice work
|
||
function assertStyleOptionsMissing() { | ||
const styleLabel = screen.queryByText( 'Style' ); | ||
const solidButton = screen.queryByRole( 'button', { |
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.
We could be able to shorten this to a single query, where:
const solidButton = screen.queryByRole( 'button', {
name: 'Solid',
} );
const dashedButton = screen.queryByRole( 'button', {
name: 'Dashed',
} );
const dottedButton = screen.queryByRole( 'button', {
name: 'Dotted',
} );
expect( solidButton ).not.toBeInTheDocument();
expect( dashedButton ).not.toBeInTheDocument();
expect( dottedButton ).not.toBeInTheDocument();
to:
const styleButton = screen.queryByRole( 'button', {
name: /(Solid)|(Dashed)|(Dotted)/,
} );
expect( styleButton ).not.toBeInTheDocument();
This is totally optional since it's a suggestion on pre-existing code.
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.
Clever! Applied in d7b188b
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.
Nice. You might also want to do it for the other should omit style options when requested
test that has the same assertions.
07a6e71
to
fdbd422
Compare
fdbd422
to
c1b1d9b
Compare
What?
Part of #35744
Refactor
BorderBoxControl
's tests to TypeScript (the rest of the component is already typed)Remove unnecessary
act()
call in the processWhy?
Part of the TypeScript migration that we're doing in the
@wordpress/components
package, see #35744 for more infoHow?
Testing Instructions
No runtime changes. Make sure that the project compiles, and that tests make sense