MCPcopy Index your code
hub / github.com/adobe/react-spectrum / pressElement

Function pressElement

packages/@react-aria/test-utils/src/utils.ts:137–155  ·  view source on GitHub ↗
(
  user: {
    click: (element: Element) => Promise<void>;
    keyboard: (keys: string) => Promise<void>;
    pointer: (opts: {target: Element; keys: string; coords?: any}) => Promise<void>;
  },
  element: HTMLElement,
  interactionType: UserOpts['interactionType']
)

Source from the content-addressed store, hash-verified

135
136// Docs cannot handle the types that userEvent actually declares, so hopefully this sub set is okay
137export async function pressElement(
138 user: {
139 click: (element: Element) => Promise<void>;
140 keyboard: (keys: string) => Promise<void>;
141 pointer: (opts: {target: Element; keys: string; coords?: any}) => Promise<void>;
142 },
143 element: HTMLElement,
144 interactionType: UserOpts['interactionType']
145): Promise<void> {
146 if (interactionType === 'mouse') {
147 // Add coords with pressure so this isn't detected as a virtual click
148 await user.pointer({target: element, keys: '[MouseLeft]', coords: {pressure: 0.5}});
149 } else if (interactionType === 'keyboard') {
150 act(() => element.focus());
151 await user.keyboard('[Space]');
152 } else if (interactionType === 'touch') {
153 await user.pointer({target: element, keys: '[TouchA]'});
154 }
155}

Callers 15

triggerTabMethod · 0.90
triggerRadioMethod · 0.90
toggleRowSelectionMethod · 0.90
toggleRowExpansionMethod · 0.90
triggerRowActionMethod · 0.90
toggleRowSelectionMethod · 0.90
toggleRowExpansionMethod · 0.90
toggleSortMethod · 0.90
triggerRowActionMethod · 0.90
toggleSelectAllMethod · 0.90
toggleCheckboxMethod · 0.90

Calls 2

actFunction · 0.90
focusMethod · 0.80

Tested by

no test coverage detected