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

Nux: Improve act() usage in DotTip tests #46231

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ exports[`DotTip should render correctly 1`] = `
aria-label="Editor tips"
class="components-popover nux-dot-tip"
role="dialog"
style="position: absolute; opacity: 0; transform: translateX(-2em) scale(0) translateZ(0); transform-origin: 0% 50% 0; left: 0px; top: 0px;"
style="position: absolute; opacity: 0.9994144868675858; transform: translateX(-0.00117em) scale(0.9994144868675858) translateZ(0); transform-origin: 0% 50% 0; left: 0px; top: 0px;"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsnajdr's comment (opacity value) applies here too and we should have the same handling.

tabindex="-1"
>
<div
18 changes: 11 additions & 7 deletions packages/nux/src/components/dot-tip/test/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { act, render, screen } from '@testing-library/react';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

/**
@@ -19,8 +19,6 @@ describe( 'DotTip', () => {
</DotTip>
);

await act( () => Promise.resolve() );

expect( screen.queryByRole( 'dialog' ) ).not.toBeInTheDocument();
} );

@@ -31,9 +29,11 @@ describe( 'DotTip', () => {
</DotTip>
);

await act( () => Promise.resolve() );
const dialog = screen.getByRole( 'dialog' );

await waitFor( () => expect( dialog ).toBePositionedPopover() );

expect( screen.getByRole( 'dialog' ) ).toMatchSnapshot();
expect( dialog ).toMatchSnapshot();
} );

it( 'should call onDismiss when the dismiss button is clicked', async () => {
@@ -48,7 +48,9 @@ describe( 'DotTip', () => {
</DotTip>
);

await act( () => Promise.resolve() );
const dialog = screen.getByRole( 'dialog' );

await waitFor( () => expect( dialog ).toBePositionedPopover() );

await user.click( screen.getByRole( 'button', { name: 'Got it' } ) );

@@ -67,7 +69,9 @@ describe( 'DotTip', () => {
</DotTip>
);

await act( () => Promise.resolve() );
const dialog = screen.getByRole( 'dialog' );

await waitFor( () => expect( dialog ).toBePositionedPopover() );

await user.click(
screen.getByRole( 'button', { name: 'Disable tips' } )