import { AccessibleRoleLocator, assertValidClickCount, BlurOption, BoundingRect, ClickOption, CssProperty, dateUtil, defaultWaitForOption, ElementNotFoundError, EnterTextOption, FocusOption, HoverOption, Interactor, interactorUtil, locatorUtil, MouseDownOption, MouseEnterOption, MouseLeaveOption, MouseMoveOption, MouseOutOption, MouseUpOption, Optional, PartLocator, Point, PressKeyOption, timingUtil, elementStateUtil, visibilityUtil, WaitForOption, WaitUntilOption, } from '@atomic-testing/core'; import { fireEvent, queryAllByRole } from '@testing-library/dom'; import defaultUserEvent from '@testing-library/user-event'; import { FakeDataTransfer, FakeMouseEvent } from './fakeEvents'; import { DOMInteractorOption, UserEventDispatcher } from './types'; /** * Derive a `KeyboardEvent.code` from a `KeyboardEvent.key`, approximating what * a real browser reports for a standard US layout: letters map to `KeyX`, * digits to `DigitX`, space to `Space`, and named keys (`ArrowRight`, `Enter`, * `Home`, …) carry their own name as the code. jsdom leaves `code` empty * unless supplied, but real keyboard events always populate it — and component * libraries legitimately switch on `code` (PrimeVue's Slider does), so the * jsdom leg must match. Left/right-variant modifiers (`Shift` → `ShiftLeft`) * are not disambiguated; a bare modifier press is not a supported gesture here. */ function deriveKeyCode(key: string): string { if (key === ' ') { return 'Space'; } if (/^[a-zA-Z]$/.test(key)) { return `Key${key.toUpperCase()}`; } if (/^[0-9]$/.test(key)) { return `Digit${key}`; } return key; } /** * Whether a key press on this element needs `beforeinput`/`input` fidelity — true * only for a `contenteditable` host. Such a host commits edits from input events * that a bare `keydown`/`keyup` never produces (the MUI X picker section field * clears on `Backspace` this way, see #903), so it must go through * `userEvent.keyboard`. * * Everything else — including ``/`