@wix/design-system
Version:
@wix/design-system
60 lines • 2.37 kB
JavaScript
import { baseUniDriverFactory } from '../utils/test-utils/unidriver';
import { buttonDriverFactory, } from '../Button/Button.uni.driver';
import { tooltipDriverFactory } from '../Tooltip/Tooltip.uni.driver';
import { dataHooks } from './constants';
import { getFormattedDataHooks } from '../utils/test-utils';
const fDataHooks = getFormattedDataHooks(dataHooks);
export const baseModalLayoutDriverFactory = (base, body) => {
const getButtonDriver = (dataHook) => buttonDriverFactory(base.$(`[data-hook="${dataHook}"]`));
return {
...baseUniDriverFactory(base),
/**
* Gets the modal theme
*/
getTheme: async () => base.attr('data-skin'),
/**
* Gets the modal skin
*/
getSkin: async () => base.attr('data-skin'),
/**
* Clicks the modal close-button
*/
clickCloseButton: async () => base.$(fDataHooks.closeButton).click(),
/**
* Clicks the modal help-button
*/
clickHelpButton: async () => base.$(fDataHooks.helpButton).click(),
/**
* Checks whether a node with the provided dataHook exists
*/
childExists: async (dataHook) => base.$(`[data-hook="${dataHook}"]`).exists(),
/**
* Gets the title's text
*/
getTitleText: async () => base.$(fDataHooks.headerTitle).text(),
/**
* Gets the subtitle's text
*/
getSubtitleText: async () => base.$(fDataHooks.headerSubtitle).text(),
/**
* Gets the secondary button driver
*/
getSecondaryButtonDriver: async () => getButtonDriver(dataHooks.footerSecondaryButton),
/**
* Gets the primary button driver
*/
getPrimaryButtonDriver: async () => getButtonDriver(dataHooks.footerPrimaryButton),
/**
* Gets the primary button's tooltip content
*/
getPrimaryButtonTooltipContent: async () => {
const tooltipDriver = tooltipDriverFactory(base.$(fDataHooks.primaryButtonTooltip), body ?? base);
return tooltipDriver.getTooltipText();
},
/**
* Gets the illustration source
*/
getIllustrationSrc: async () => base.$(fDataHooks.illustrationSrc).attr('src'),
};
};
//# sourceMappingURL=BaseModalLayout.uni.driver.js.map