From 5d97d79eaa80b3285bceda989a356377e6daf103 Mon Sep 17 00:00:00 2001 From: Matheus Wichman Date: Fri, 5 Mar 2021 21:15:28 -0300 Subject: [PATCH 01/11] [SpeedDial] Reset tooltip state when the speed dial is closed --- .../src/SpeedDial/SpeedDial.test.js | 99 +++++++++++++++++-- .../src/SpeedDialAction/SpeedDialAction.js | 4 + 2 files changed, 93 insertions(+), 10 deletions(-) diff --git a/packages/material-ui/src/SpeedDial/SpeedDial.test.js b/packages/material-ui/src/SpeedDial/SpeedDial.test.js index 85d787e4344ce7..cc90170a202c08 100644 --- a/packages/material-ui/src/SpeedDial/SpeedDial.test.js +++ b/packages/material-ui/src/SpeedDial/SpeedDial.test.js @@ -14,6 +14,16 @@ import SpeedDial, { speedDialClasses as classes } from '@material-ui/core/SpeedD import SpeedDialAction from '@material-ui/core/SpeedDialAction'; describe('', () => { + let clock; + + beforeEach(() => { + clock = useFakeTimers(); + }); + + afterEach(() => { + clock.restore(); + }); + // StrictModeViolation: not using act(), prefer test/utils/createClientRender const mount = createMount({ strict: false }); const render = createClientRender({ strict: false }); @@ -85,6 +95,43 @@ describe('', () => { expect(actions.map((element) => element.className)).not.to.contain('is-closed'); }); + it('should reset the state of the tooltip when the speed dial is closed while it is open', () => { + const { queryByRole, getByRole, getAllByRole } = render( + + + + , + ); + const fab = getByRole('button'); + const menu = getByRole('menu'); + const actions = getAllByRole('menuitem'); + + fireEvent.mouseEnter(fab); + act(() => { + clock.runAll(); + }); + expect(menu).to.not.have.class(classes.actionsClosed); + + fireEvent.mouseOver(actions[0]); + act(() => { + clock.runAll(); + }); + expect(queryByRole('tooltip')).not.to.equal(null); + + fireEvent.mouseLeave(actions[0]); + act(() => { + clock.runAll(); + }); + expect(menu).to.have.class(classes.actionsClosed); + + fireEvent.mouseEnter(fab); + act(() => { + clock.runAll(); + }); + expect(queryByRole('tooltip')).to.equal(null); + expect(menu).to.not.have.class(classes.actionsClosed); + }); + describe('prop: onKeyDown', () => { it('should be called when a key is pressed', () => { const handleKeyDown = spy(); @@ -124,16 +171,6 @@ describe('', () => { }); describe('keyboard', () => { - let clock; - - beforeEach(() => { - clock = useFakeTimers(); - }); - - afterEach(() => { - clock.restore(); - }); - it('should open the speed dial and move to the first action without closing', () => { const handleOpen = spy(); const { getByRole, getAllByRole } = render( @@ -154,6 +191,48 @@ describe('', () => { expect(document.activeElement).to.equal(actions[0]); expect(fab).to.have.attribute('aria-expanded', 'true'); }); + + it('should reset the state of the tooltip when the speed dial is closed while it is open', () => { + const handleOpen = spy(); + const { queryByRole, getByRole, getAllByRole } = render( + + + + , + ); + const fab = getByRole('button'); + const menu = getByRole('menu'); + const actions = getAllByRole('menuitem'); + + fab.focus(); + act(() => { + clock.runAll(); + }); + expect(menu).to.not.have.class(classes.actionsClosed); + + fireEvent.keyDown(fab, { key: 'ArrowUp' }); + act(() => { + clock.runAll(); + }); + expect(queryByRole('tooltip')).not.to.equal(null); + + const escapeEvent = new window.Event('KeyboardEvent'); + escapeEvent.initEvent('keydown', true); + escapeEvent.key = 'Escape'; + actions[0].dispatchEvent(escapeEvent); + act(() => { + clock.runAll(); + }); + expect(queryByRole('tooltip')).to.equal(null); + expect(menu).to.have.class(classes.actionsClosed); + + fab.focus(); + act(() => { + clock.runAll(); + }); + expect(queryByRole('tooltip')).to.equal(null); + expect(menu).to.not.have.class(classes.actionsClosed); + }); }); describe('dial focus', () => { diff --git a/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js b/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js index 8557d632cee06c..2e9502ed68344c 100644 --- a/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js +++ b/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js @@ -201,6 +201,10 @@ const SpeedDialAction = React.forwardRef(function SpeedDialAction(inProps, ref) ); } + if (!open && tooltipOpen) { + setTooltipOpen(false); + } + return ( Date: Sun, 7 Mar 2021 21:31:43 -0300 Subject: [PATCH 02/11] Fix tooltip placement when the direction is horizontal --- .../material-ui/src/SpeedDial/SpeedDial.js | 9 +++++++- .../src/SpeedDial/SpeedDial.test.js | 23 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/material-ui/src/SpeedDial/SpeedDial.js b/packages/material-ui/src/SpeedDial/SpeedDial.js index 3daec5a6535b2b..be9818feb62b20 100644 --- a/packages/material-ui/src/SpeedDial/SpeedDial.js +++ b/packages/material-ui/src/SpeedDial/SpeedDial.js @@ -360,7 +360,13 @@ const SpeedDial = React.forwardRef(function SpeedDial(inProps, ref) { }); const children = allItems.map((child, index) => { - const { FabProps: { ref: origButtonRef, ...ChildFabProps } = {} } = child.props; + const { + FabProps: { ref: origButtonRef, ...ChildFabProps } = {}, + tooltipPlacement: tooltipPlacementProp, + } = child.props; + + const tooltipPlacement = + tooltipPlacementProp || getOrientation(direction) === 'vertical' ? 'left' : 'top'; return React.cloneElement(child, { FabProps: { @@ -369,6 +375,7 @@ const SpeedDial = React.forwardRef(function SpeedDial(inProps, ref) { }, delay: 30 * (open ? index : allItems.length - index), open, + tooltipPlacement, id: `${id}-action-${index}`, }); }); diff --git a/packages/material-ui/src/SpeedDial/SpeedDial.test.js b/packages/material-ui/src/SpeedDial/SpeedDial.test.js index cc90170a202c08..0f1c3fa1de8b0c 100644 --- a/packages/material-ui/src/SpeedDial/SpeedDial.test.js +++ b/packages/material-ui/src/SpeedDial/SpeedDial.test.js @@ -12,6 +12,7 @@ import { import Icon from '@material-ui/core/Icon'; import SpeedDial, { speedDialClasses as classes } from '@material-ui/core/SpeedDial'; import SpeedDialAction from '@material-ui/core/SpeedDialAction'; +import { tooltipClasses } from '@material-ui/core/Tooltip'; describe('', () => { let clock; @@ -168,6 +169,28 @@ describe('', () => { expect(getByRole('presentation')).to.have.class(classes[className]); }); }); + + [ + ['up', 'tooltipPlacementLeft'], + ['down', 'tooltipPlacementLeft'], + ['left', 'tooltipPlacementTop'], + ['right', 'tooltipPlacementTop'], + ].forEach(([direction, className]) => { + it(`should place the tooltip in the correct position when direction=${direction}`, () => { + const { getByRole, getAllByRole } = render( + + + + , + ); + const actions = getAllByRole('menuitem'); + fireEvent.mouseOver(actions[0]); + act(() => { + clock.runAll(); + }); + expect(getByRole('tooltip').firstChild).to.have.class(tooltipClasses[className]); + }); + }); }); describe('keyboard', () => { From 6fb86426b66606c91cf4226f1db7ebc0caf9674e Mon Sep 17 00:00:00 2001 From: Matheus Wichman Date: Sun, 7 Mar 2021 22:53:01 -0300 Subject: [PATCH 03/11] Wrap in parentheses --- packages/material-ui/src/SpeedDial/SpeedDial.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/material-ui/src/SpeedDial/SpeedDial.js b/packages/material-ui/src/SpeedDial/SpeedDial.js index be9818feb62b20..c0a1186c28dd85 100644 --- a/packages/material-ui/src/SpeedDial/SpeedDial.js +++ b/packages/material-ui/src/SpeedDial/SpeedDial.js @@ -366,7 +366,7 @@ const SpeedDial = React.forwardRef(function SpeedDial(inProps, ref) { } = child.props; const tooltipPlacement = - tooltipPlacementProp || getOrientation(direction) === 'vertical' ? 'left' : 'top'; + tooltipPlacementProp || (getOrientation(direction) === 'vertical' ? 'left' : 'top'); return React.cloneElement(child, { FabProps: { From d74bd2d718cb9c55a0cf0708f7b047b261fe5730 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Tue, 9 Mar 2021 20:19:24 +0100 Subject: [PATCH 04/11] move github comment inside source --- packages/material-ui/src/SpeedDial/SpeedDial.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/material-ui/src/SpeedDial/SpeedDial.test.js b/packages/material-ui/src/SpeedDial/SpeedDial.test.js index 0f1c3fa1de8b0c..609dccda994428 100644 --- a/packages/material-ui/src/SpeedDial/SpeedDial.test.js +++ b/packages/material-ui/src/SpeedDial/SpeedDial.test.js @@ -239,6 +239,8 @@ describe('', () => { }); expect(queryByRole('tooltip')).not.to.equal(null); + // Manually fire an event to avoid calling act with: + // fireEvent.keyDown(actions[0], { key: 'Escape' }); const escapeEvent = new window.Event('KeyboardEvent'); escapeEvent.initEvent('keydown', true); escapeEvent.key = 'Escape'; From f564e2b32a51f382a3bae913ec871b641dc16dc8 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Wed, 10 Mar 2021 09:46:35 +0100 Subject: [PATCH 05/11] actionsClosed -> aria-expanded --- .../material-ui/src/SpeedDial/SpeedDial.test.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/material-ui/src/SpeedDial/SpeedDial.test.js b/packages/material-ui/src/SpeedDial/SpeedDial.test.js index 609dccda994428..76fa2d8ed56a9d 100644 --- a/packages/material-ui/src/SpeedDial/SpeedDial.test.js +++ b/packages/material-ui/src/SpeedDial/SpeedDial.test.js @@ -104,14 +104,13 @@ describe('', () => { , ); const fab = getByRole('button'); - const menu = getByRole('menu'); const actions = getAllByRole('menuitem'); fireEvent.mouseEnter(fab); act(() => { clock.runAll(); }); - expect(menu).to.not.have.class(classes.actionsClosed); + expect(fab).to.have.attribute('aria-expanded', 'true'); fireEvent.mouseOver(actions[0]); act(() => { @@ -123,14 +122,14 @@ describe('', () => { act(() => { clock.runAll(); }); - expect(menu).to.have.class(classes.actionsClosed); + expect(fab).to.have.attribute('aria-expanded', 'false'); fireEvent.mouseEnter(fab); act(() => { clock.runAll(); }); expect(queryByRole('tooltip')).to.equal(null); - expect(menu).to.not.have.class(classes.actionsClosed); + expect(fab).to.have.attribute('aria-expanded', 'true'); }); describe('prop: onKeyDown', () => { @@ -224,14 +223,13 @@ describe('', () => { , ); const fab = getByRole('button'); - const menu = getByRole('menu'); const actions = getAllByRole('menuitem'); fab.focus(); act(() => { clock.runAll(); }); - expect(menu).to.not.have.class(classes.actionsClosed); + expect(fab).to.have.attribute('aria-expanded', 'true'); fireEvent.keyDown(fab, { key: 'ArrowUp' }); act(() => { @@ -249,14 +247,14 @@ describe('', () => { clock.runAll(); }); expect(queryByRole('tooltip')).to.equal(null); - expect(menu).to.have.class(classes.actionsClosed); + expect(fab).to.have.attribute('aria-expanded', 'false'); fab.focus(); act(() => { clock.runAll(); }); expect(queryByRole('tooltip')).to.equal(null); - expect(menu).to.not.have.class(classes.actionsClosed); + expect(fab).to.have.attribute('aria-expanded', 'true'); }); }); @@ -328,7 +326,7 @@ describe('', () => { it('displays the actions on focus gain', () => { renderSpeedDial(); expect(screen.getAllByRole('menuitem')).to.have.lengthOf(4); - expect(screen.getByRole('menu')).not.to.have.class(classes.actionsClosed); + expect(fabButton).to.have.attribute('aria-expanded', 'true'); }); it('considers arrow keys with the same initial orientation', () => { From 6740ecae031abd09d8e0da8c7f4dd7e8c51757f3 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Wed, 10 Mar 2021 09:54:05 +0100 Subject: [PATCH 06/11] add whitespace to distinguish act-assert --- packages/material-ui/src/SpeedDial/SpeedDial.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/material-ui/src/SpeedDial/SpeedDial.test.js b/packages/material-ui/src/SpeedDial/SpeedDial.test.js index 76fa2d8ed56a9d..61f0290a7b0eab 100644 --- a/packages/material-ui/src/SpeedDial/SpeedDial.test.js +++ b/packages/material-ui/src/SpeedDial/SpeedDial.test.js @@ -229,6 +229,7 @@ describe('', () => { act(() => { clock.runAll(); }); + expect(fab).to.have.attribute('aria-expanded', 'true'); fireEvent.keyDown(fab, { key: 'ArrowUp' }); @@ -246,6 +247,7 @@ describe('', () => { act(() => { clock.runAll(); }); + expect(queryByRole('tooltip')).to.equal(null); expect(fab).to.have.attribute('aria-expanded', 'false'); From 34ec9c6053c3c73ae6cfc31e8cf084aa0f0590ab Mon Sep 17 00:00:00 2001 From: eps1lon Date: Wed, 10 Mar 2021 09:55:03 +0100 Subject: [PATCH 07/11] REVERT LATER revert fix to verify added tests --- packages/material-ui/src/SpeedDialAction/SpeedDialAction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js b/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js index 2e9502ed68344c..169ab79defa1c9 100644 --- a/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js +++ b/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js @@ -202,7 +202,7 @@ const SpeedDialAction = React.forwardRef(function SpeedDialAction(inProps, ref) } if (!open && tooltipOpen) { - setTooltipOpen(false); + // setTooltipOpen(false); } return ( From 6af96beb1a90f037fc1dfe76145456ec5a167b9e Mon Sep 17 00:00:00 2001 From: eps1lon Date: Wed, 10 Mar 2021 10:05:48 +0100 Subject: [PATCH 08/11] Revert "REVERT LATER revert fix to verify added tests" This reverts commit 34ec9c6053c3c73ae6cfc31e8cf084aa0f0590ab. --- packages/material-ui/src/SpeedDialAction/SpeedDialAction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js b/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js index 169ab79defa1c9..2e9502ed68344c 100644 --- a/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js +++ b/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js @@ -202,7 +202,7 @@ const SpeedDialAction = React.forwardRef(function SpeedDialAction(inProps, ref) } if (!open && tooltipOpen) { - // setTooltipOpen(false); + setTooltipOpen(false); } return ( From 15987cba7e2c681add53a6b6475a371d5be2b43b Mon Sep 17 00:00:00 2001 From: Matheus Wichman Date: Wed, 10 Mar 2021 10:00:05 -0300 Subject: [PATCH 09/11] REVERT LATER false positive evidence --- packages/material-ui/src/SpeedDial/SpeedDial.test.js | 12 ++++++------ .../src/SpeedDialAction/SpeedDialAction.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/material-ui/src/SpeedDial/SpeedDial.test.js b/packages/material-ui/src/SpeedDial/SpeedDial.test.js index 61f0290a7b0eab..b23205a68e7865 100644 --- a/packages/material-ui/src/SpeedDial/SpeedDial.test.js +++ b/packages/material-ui/src/SpeedDial/SpeedDial.test.js @@ -96,7 +96,7 @@ describe('', () => { expect(actions.map((element) => element.className)).not.to.contain('is-closed'); }); - it('should reset the state of the tooltip when the speed dial is closed while it is open', () => { + it.skip('should reset the state of the tooltip when the speed dial is closed while it is open', () => { const { queryByRole, getByRole, getAllByRole } = render( @@ -239,11 +239,11 @@ describe('', () => { expect(queryByRole('tooltip')).not.to.equal(null); // Manually fire an event to avoid calling act with: - // fireEvent.keyDown(actions[0], { key: 'Escape' }); - const escapeEvent = new window.Event('KeyboardEvent'); - escapeEvent.initEvent('keydown', true); - escapeEvent.key = 'Escape'; - actions[0].dispatchEvent(escapeEvent); + fireEvent.keyDown(actions[0], { key: 'Escape' }); + // const escapeEvent = new window.Event('KeyboardEvent'); + // escapeEvent.initEvent('keydown', true); + // escapeEvent.key = 'Escape'; + // actions[0].dispatchEvent(escapeEvent); act(() => { clock.runAll(); }); diff --git a/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js b/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js index 2e9502ed68344c..169ab79defa1c9 100644 --- a/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js +++ b/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js @@ -202,7 +202,7 @@ const SpeedDialAction = React.forwardRef(function SpeedDialAction(inProps, ref) } if (!open && tooltipOpen) { - setTooltipOpen(false); + // setTooltipOpen(false); } return ( From 223cc2cc476dfca635dfb9bbab197f602a538152 Mon Sep 17 00:00:00 2001 From: Matheus Wichman Date: Wed, 10 Mar 2021 14:40:53 -0300 Subject: [PATCH 10/11] Revert "REVERT LATER false positive evidence" This reverts commit 15987cba7e2c681add53a6b6475a371d5be2b43b. --- packages/material-ui/src/SpeedDial/SpeedDial.test.js | 12 ++++++------ .../src/SpeedDialAction/SpeedDialAction.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/material-ui/src/SpeedDial/SpeedDial.test.js b/packages/material-ui/src/SpeedDial/SpeedDial.test.js index b23205a68e7865..61f0290a7b0eab 100644 --- a/packages/material-ui/src/SpeedDial/SpeedDial.test.js +++ b/packages/material-ui/src/SpeedDial/SpeedDial.test.js @@ -96,7 +96,7 @@ describe('', () => { expect(actions.map((element) => element.className)).not.to.contain('is-closed'); }); - it.skip('should reset the state of the tooltip when the speed dial is closed while it is open', () => { + it('should reset the state of the tooltip when the speed dial is closed while it is open', () => { const { queryByRole, getByRole, getAllByRole } = render( @@ -239,11 +239,11 @@ describe('', () => { expect(queryByRole('tooltip')).not.to.equal(null); // Manually fire an event to avoid calling act with: - fireEvent.keyDown(actions[0], { key: 'Escape' }); - // const escapeEvent = new window.Event('KeyboardEvent'); - // escapeEvent.initEvent('keydown', true); - // escapeEvent.key = 'Escape'; - // actions[0].dispatchEvent(escapeEvent); + // fireEvent.keyDown(actions[0], { key: 'Escape' }); + const escapeEvent = new window.Event('KeyboardEvent'); + escapeEvent.initEvent('keydown', true); + escapeEvent.key = 'Escape'; + actions[0].dispatchEvent(escapeEvent); act(() => { clock.runAll(); }); diff --git a/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js b/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js index 169ab79defa1c9..2e9502ed68344c 100644 --- a/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js +++ b/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js @@ -202,7 +202,7 @@ const SpeedDialAction = React.forwardRef(function SpeedDialAction(inProps, ref) } if (!open && tooltipOpen) { - // setTooltipOpen(false); + setTooltipOpen(false); } return ( From c689d64ff26fb98b702a33ac25318b4411ea2c30 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Fri, 12 Mar 2021 11:50:27 +0100 Subject: [PATCH 11/11] Use discrete semantics --- .../src/SpeedDial/SpeedDial.test.js | 8 ++--- test/utils/fireDiscreteEvent.js | 33 +++++++++++++++++-- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/packages/material-ui/src/SpeedDial/SpeedDial.test.js b/packages/material-ui/src/SpeedDial/SpeedDial.test.js index 61f0290a7b0eab..cbb887c8afed09 100644 --- a/packages/material-ui/src/SpeedDial/SpeedDial.test.js +++ b/packages/material-ui/src/SpeedDial/SpeedDial.test.js @@ -6,6 +6,7 @@ import { createClientRender, act, fireEvent, + fireDiscreteEvent, screen, describeConformanceV5, } from 'test/utils'; @@ -238,12 +239,7 @@ describe('', () => { }); expect(queryByRole('tooltip')).not.to.equal(null); - // Manually fire an event to avoid calling act with: - // fireEvent.keyDown(actions[0], { key: 'Escape' }); - const escapeEvent = new window.Event('KeyboardEvent'); - escapeEvent.initEvent('keydown', true); - escapeEvent.key = 'Escape'; - actions[0].dispatchEvent(escapeEvent); + fireDiscreteEvent.keyDown(actions[0], { key: 'Escape' }); act(() => { clock.runAll(); }); diff --git a/test/utils/fireDiscreteEvent.js b/test/utils/fireDiscreteEvent.js index de2172d614f604..dd9cef981d21c7 100644 --- a/test/utils/fireDiscreteEvent.js +++ b/test/utils/fireDiscreteEvent.js @@ -1,3 +1,11 @@ +import { configure, fireEvent, getConfig } from '@testing-library/react'; + +const noWrapper = (callback) => callback(); + +/** + * @param {() => void} callback + * @returns {void} + */ function withMissingActWarningsIgnored(callback) { const originalConsoleError = console.error; console.error = function silenceMissingActWarnings(message, ...args) { @@ -6,9 +14,16 @@ function withMissingActWarningsIgnored(callback) { originalConsoleError.call(console, message, ...args); } }; + + const originalConfig = getConfig(); + configure({ + eventWrapper: noWrapper, + }); + try { callback(); } finally { + configure(originalConfig); console.error = originalConsoleError; } } @@ -21,10 +36,22 @@ function withMissingActWarningsIgnored(callback) { // Be aware that "discrete events" are an implementation detail of React. // To test discrete events we cannot use `fireEvent` from `@testing-library/react` because they are all wrapped in `act`. // `act` overrides the "discrete event" semantics with "batching" semantics: https://github.com/facebook/react/blob/3fbd47b86285b6b7bdeab66d29c85951a84d4525/packages/react-reconciler/src/ReactFiberWorkLoop.old.js#L1061-L1064 +// Note that using `fireEvent` from `@testing-library/dom` would not work since /react configures both `fireEvent` to use `act` as a wrapper. // ----------------------------------------- -// eslint-disable-next-line import/prefer-default-export -- there are more than one discrete events. export function click(element) { - // TODO: Why are there different semantics between `element.click` and `dtlFireEvent.click` - return withMissingActWarningsIgnored(() => element.click()); + return withMissingActWarningsIgnored(() => { + fireEvent.click(element); + }); +} + +/** + * @param {Element} element + * @param {{}} [options] + * @returns {void} + */ +export function keyDown(element, options) { + return withMissingActWarningsIgnored(() => { + fireEvent.keyDown(element, options); + }); }