MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / selectReactSelectOption

Function selectReactSelectOption

console/src/test/utils.tsx:247–261  ·  view source on GitHub ↗
(
  container: HTMLElement,
  optionText: string,
)

Source from the content-addressed store, hash-verified

245 * @param optionText - The text of the option to select.
246 */
247export async function selectReactSelectOption(
248 container: HTMLElement,
249 optionText: string,
250) {
251 const input = container.querySelector("input");
252 assert(input !== null, "Could not find react-select input");
253 await userEvent.click(input);
254 const optionEls = Array.from(container.querySelectorAll('[role="option"]'));
255 const option = optionEls.find((el) => el.textContent === optionText);
256 assert(
257 option !== undefined,
258 `Could not find react-select option '${optionText}'. Found: ${buildStringifiedOptions(optionEls)}`,
259 );
260 await userEvent.click(option);
261}
262
263/**
264 * Determine whether there are invalid form fields in the document.

Calls 4

assertFunction · 0.90
buildStringifiedOptionsFunction · 0.85
fromMethod · 0.45
findMethod · 0.45

Tested by 4

fillRequiredFormFieldsFunction · 0.72
fillRequiredFormFieldsFunction · 0.72
fillRequiredFormFieldsFunction · 0.72