import { UniDriver } from '@wix/wix-ui-test-utils/unidriver'; import { baseUniDriverFactory } from '../../unidriver'; import { PickerStandaloneLayoutUniDriver } from '../PickerStandaloneLayout/PickerStandaloneLayout.uni.driver'; import { PickerUniDriver } from '../Picker/Picker.uni.driver'; import { ButtonUniDriver } from '@wix/design-system/dist/testkit/unidriver'; export function PickerStandaloneUniDriver(base: UniDriver, body: UniDriver) { const layout = PickerStandaloneLayoutUniDriver(base, body); const picker = PickerUniDriver(base.$('[data-hook="picker"]'), body); return { wait: (timeout?: number) => base.wait(timeout), ...baseUniDriverFactory(base), /** * Enter a value to the search input * @param {string} value * @returns {Promise} */ enterSearchTerm: layout.enterSearchTerm, /** * Clear the search input * @returns {Promise} */ clearSearchTerm: layout.clearSearchTerm, /** * Get the value of the search input * @returns {Promise} */ getSearchTerm: layout.getSearchTerm, /** * Returns whether the search component exists * @returns {Promise} */ searchExists: layout.searchExists, /** * Returns a promise that'll resolve when search loader is displayed * @param {number} [timeout] * @returns {Promise} */ waitSearchLoader: picker.waitSearchLoader, /** * Returns whether the search loader is displayed * @returns {Promise} */ searchLoaderExists: picker.searchLoaderExists, /** * Returns a promise that'll resolve when search loader is removed * @param {number} [timeout] * @returns {Promise} */ waitSearchLoaderRemoved: picker.waitSearchLoaderRemoved, /** * Returns whether the floating notification exists * @returns {Promise} */ floatingNotificationExists: picker.floatingNotificationExists, /** * Returns the floating notification's current text * @returns {Promise} */ getFloatingNotificationText: picker.getFloatingNotificationText, /** * Returns a promise that'll resolve when the initial loader is displayed * @param {number} [timeout] * @returns {Promise} */ waitInitialLoader: layout.waitInitialLoader, /** * Returns a promise that'll resolve when the initial loader is removed * @param {number} [timeout] * @returns {Promise} */ waitInitialLoaderRemoved: layout.waitInitialLoaderRemoved, /** * Indicates whether initial loader is in loading status * @returns {Promise} */ isInitialLoaderLoading: () => layout.isInitialLoaderLoading(), /** * Indicates whether initial loader exists * @returns {Promise} */ initialLoaderExists: () => layout.initialLoaderExists(), /** * Get a `TableListItem` driver at row index */ getTableListItemAt: picker.getTableListItemAt, /** * Get item primary button driver */ getPrimaryActionButtonAt: picker.getPrimaryActionButtonAt, /** * Wait for new row to finish enter animation */ waitRowEntered: picker.waitRowEntered, /** * Returns the picker's title * @returns {Promise} */ getTitleText: layout.getTitleText, /** * Returns the picker's subtitle * @returns {Promise} */ getSubtitleText: layout.getSubtitleText, /** * Returns the number of items currently displayed within the picker * @returns {Promise} */ numberOfItemsInList: picker.numberOfItemsInList, /** * Triggers hover state on a row */ hoverItemAt: picker.hoverItemAt, /** * Indicates whether the action button of the row exists */ primaryButtonExistsAt: picker.primaryButtonExistsAt, /** * Triggers "scroll" event on the list. * @returns {Promise} */ scrollDown: picker.scrollDown, /** * Triggers "scroll" event to a given item's index * @param {number} index * @returns {Promise} */ scrollTo: picker.scrollTo, /** * Selects item at given index * @param {number} index * @returns {Promise} */ toggleSelectorAt: picker.toggleSelectorAt, /** * Returns the amount of items selected * @returns {Promise} */ getTotalSelected: picker.getTotalSelected, /** * Returns whether a given item is currently selected * @param {number} index * @returns {Promise} */ isSelectorCheckedAt: picker.isSelectorCheckedAt, /** * Returns a promise that resolves when a given item is displayed * @param {number} index * @param {number} [timeout] * @returns {Promise} */ waitListItemAt: picker.waitListItemAt, /** * Returns the inner html of a given item * @param {number} index * @returns {Promise} */ getTitleTextAt: picker.getTitleTextAt, /** * Returns the title text of a given item * @param {number} index * @returns {Promise} */ getTitleTextContentAt: picker.getTitleTextContentAt, /** * Returns the subtitle inner html of a given item * @param {number} index * @returns {Promise} */ getSubtitleTextAt: picker.getSubtitleTextAt, /** * Returns the subtitle text of a given item * @param {number} index * @returns {Promise} */ getSubtitleTextContentAt: picker.getSubtitleTextAt, /** * Returns the element of a given item * @param {number} index * @returns {Promise} */ getImageElementAt: picker.getImageElementAt, /** * Returns the extra node element of a given item * @param {number} index * @returns {Promise} */ getExtraNodeElementAt: picker.getExtraNodeElementAt, /** * Returns the `EmptyState` component's UniDriver by its `dataHook` * @param {string} dataHook * @returns {Promise} */ getEmptyStateByDataHook: picker.getEmptyStateByDataHook, /** * Returns the splash error state component's UniDriver by its `dataHook` * @param {string} dataHook * @returns {Promise} */ getSplashErrorStateByDataHook: picker.getErrorStateByDataHook, /** * Returns the error state component's UniDriver by its `dataHook` * @param {string} dataHook * @returns {Promise} */ getErrorStateByDataHook: picker.getEmptyStateByDataHook, createNewItemCta: () => ButtonUniDriver(base.$('[data-hook="create-new-item-cta"]'), body), }; } export default PickerStandaloneUniDriver;