UNPKG

@wix/design-system

Version:

@wix/design-system

72 lines 3.06 kB
import { baseUniDriverFactory } from '../utils/test-utils/unidriver'; import { testkit as inputUniDriverFactory } from '../Input/Input.uni.driver'; import { labelledElementDriverFactory as labelledElementUniDriverFactory } from '../LabelledElement/LabelledElement.uni.driver'; import { DATA_HOOKS } from './AutoCompleteWithLabel.constants'; import { dropdownLayoutDriverFactory } from '../DropdownLayout/DropdownLayout.uni.driver'; export const autoCompleteWithLabelDriverFactory = (base) => { const labelledElementSelector = `[data-hook="${DATA_HOOKS.labelledElement}"]`; const labelledElementDriver = labelledElementUniDriverFactory(base.$(labelledElementSelector)); const inputWrapperSelector = `[data-hook="${DATA_HOOKS.inputWithLabel}"]`; // @ts-expect-error body is a required argument but this driver does not use methods that require it const inputDriver = inputUniDriverFactory(base.$(inputWrapperSelector)); // @ts-expect-error body is a required argument but this driver does not use methods that require it const dropdownLayoutDriver = dropdownLayoutDriverFactory(base.$(`[data-hook="${DATA_HOOKS.inputDropdownLayout}"]`)); return { ...baseUniDriverFactory(base), /** * Gets label text * @return {Promise<string>} */ getLabelText: () => labelledElementDriver.getLabelText(), /** * Gets input value * @return {Promise<string>} */ getValue: () => inputDriver.getValue(), /** * Enters given text to input * @param {string} text Text to input * @returns {Promise<void>} */ enterText: async (text) => inputDriver.enterText(text), /** * Clicks an option at given index * @param {number} index Position of the option * @returns {Promise<void>} */ clickAtOption: async (index) => { await inputDriver.click(); return dropdownLayoutDriver.clickAtOption(index); }, /** * Clicks an option with a given value * @param {string} value The option value * @returns {Promise<void>} */ clickAtOptionWithValue: async (value) => { await inputDriver.click(); return dropdownLayoutDriver.clickAtOptionWithValue(value); }, /** * Clicks the menu arrow * @returns {Promise<void>} */ clickMenuArrow: () => inputDriver.clickMenuArrow(), /** * Checks if input is disabled * @returns {Promise<boolean>} */ isDisabled: async () => inputDriver.isDisabled(), /** * Triggers blur event on the input element * @returns {Promise<void>} */ blur: () => inputDriver.blur(), /** * Checks whether there's a visible error icon * @return {Promise<boolean>} */ hasError: () => inputDriver.hasStatus('error'), }; }; //# sourceMappingURL=AutoCompleteWithLabel.uni.driver.js.map