Skip to content

Commit

Permalink
[test] Fix Firefox browser version in karma profile config and resolv…
Browse files Browse the repository at this point in the history
…e user-event test TODOs (#353)
  • Loading branch information
ZeeshanTamboli authored May 1, 2024
1 parent 95ccd92 commit 5e53fd2
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 54 deletions.
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

0 comments on commit 5e53fd2

Please sign in to comment.