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

[test] Fix Firefox browser version in karma profile config and resolve user-event test TODOs #353

Merged
12 changes: 6 additions & 6 deletions packages/mui-base/src/MenuButton/MenuButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import {
} from '@base_ui/react/useDropdown';
import { describeConformanceUnstyled } from '../../test/describeConformanceUnstyled';

// TODO v6: initialize @testing-library/user-event using userEvent.setup() instead of directly calling methods e.g. userEvent.click() for all related tests in this file
// currently the setup() method uses the ClipboardEvent constructor which is incompatible with our lowest supported version of iOS Safari (12.2) https://github.com/mui/material-ui/blob/master/.browserslistrc#L44
// userEvent.setup() requires Safari 14 or up to work

const testContext: DropdownContextValue = {
dispatch: () => {},
popupId: 'menu-popup',
Expand Down Expand Up @@ -146,6 +142,8 @@ describe('<MenuButton />', () => {
dispatch: dispatchSpy,
};

const user = userEvent.setup();

const { getByRole } = render(
<DropdownContext.Provider value={context}>{buttonComponent}</DropdownContext.Provider>,
);
Expand All @@ -155,7 +153,7 @@ describe('<MenuButton />', () => {
button.focus();
});

await userEvent.keyboard(`{${key}}`);
await user.keyboard(`{${key}}`);

expect(dispatchSpy.calledOnce).to.equal(true);
expect(dispatchSpy.args[0][0]).to.contain({ type: DropdownActionTypes.open });
Expand All @@ -171,6 +169,8 @@ describe('<MenuButton />', () => {
dispatch: dispatchSpy,
};

const user = userEvent.setup();

const { getByRole } = render(
<DropdownContext.Provider value={context}>{buttonComponent}</DropdownContext.Provider>,
);
Expand All @@ -180,7 +180,7 @@ describe('<MenuButton />', () => {
button.focus();
});

await userEvent.keyboard(`{${key}}`);
await user.keyboard(`{${key}}`);

expect(dispatchSpy.calledOnce).to.equal(true);
expect(dispatchSpy.args[0][0]).to.contain({ type: DropdownActionTypes.toggle });
Expand Down
Loading