UNPKG

@wix/design-system

Version:

@wix/design-system

51 lines 3.08 kB
import buttonDriverFactory from '../Button/Button.legacy.driver'; import { dataHooks } from './constants'; import { getFormattedDataHooks, isClassExists } from '../utils/test-utils'; import ReactTestUtils from 'react-dom/test-utils'; import { tooltipLegacyDriverFactory } from '../Tooltip/Tooltip.driver'; import deprecationTestkitLog from '../utils/deprecationTestkitLog'; const fDataHooks = getFormattedDataHooks(dataHooks); export const baseModalLayoutDriverFactory = ({ element, eventTrigger }) => { deprecationTestkitLog('baseModalLayoutDriverFactory legacy testkit is deprecated and will be removed in next major release. Please use the BaseModalLayout.uni.driver factory instead.'); const getButtonDriver = dataHook => buttonDriverFactory({ element: element.querySelector(`[data-hook-internal="${dataHook}"]`), }); const tooltipTestkit = tooltipLegacyDriverFactory({ element: element.querySelector(fDataHooks.primaryButtonTooltip), eventTrigger, }); return { exists: () => !!element, _hasClass: className => isClassExists(element, className), _closeButtonExists: () => !!element.querySelector(fDataHooks.closeButton), _helpButtonExists: () => !!element.querySelector(fDataHooks.helpButton), /** Returns the modal theme */ getTheme: () => element.getAttribute('data-theme'), /** Click the modal close-button */ clickCloseButton: () => ReactTestUtils.Simulate.click(element.querySelector(fDataHooks.closeButton)), clickHelpButton: () => ReactTestUtils.Simulate.click(element.querySelector(fDataHooks.helpButton)), /** Checks that a node with the provided dataHook exists */ childExists: dataHook => !!element.querySelector(`[data-hook="${dataHook}"]`) || !!element.querySelector(`[data-hook-internal="${dataHook}"]`), /** Get the title's text */ getTitleText: () => element.querySelector(fDataHooks.headerTitle).textContent, /** Get the subtitle's text */ getSubtitleText: () => element.querySelector(fDataHooks.headerSubtitle).textContent, /** Return the secondary button driver*/ secondaryButtonDriver: getButtonDriver(dataHooks.footerSecondaryButton), /** * @deprecated use secondaryButtonDriver * Return the secondary button driver*/ getSecondaryButtonDriver: () => getButtonDriver(dataHooks.footerSecondaryButton), /** Return the primary button driver */ primaryButtonDriver: getButtonDriver(dataHooks.footerPrimaryButton), /** * @deprecated use primaryButtonDriver * Return the primary button driver */ getPrimaryButtonDriver: () => getButtonDriver(dataHooks.footerPrimaryButton), /** Return the primary button tooltip's content */ getPrimaryButtonTooltipContent: () => tooltipTestkit.getTooltipText(), getIllustrationSrc: () => element.querySelector(fDataHooks.illustrationSrc).getAttribute('src'), }; }; //# sourceMappingURL=BaseModalLayout.legacy.driver.js.map