UNPKG

wix-style-react

Version:
151 lines (118 loc) 5.92 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _testkit = require("../../testkit"); var _Tooltip = require("wix-ui-core/dist/src/components/tooltip/Tooltip.driver"); var _constants = require("./constants"); var _ButtonLegacy = _interopRequireDefault(require("../Button/Button.legacy.driver")); var tableActionCellDriverFactory = function tableActionCellDriverFactory(_ref) { var _element = _ref.element, wrapper = _ref.wrapper, eventTrigger = _ref.eventTrigger; var visibleActions = function visibleActions() { return _element.querySelectorAll("[data-hook=\"".concat(_constants.dataHooks.visibleAction, "\"]")); }; var getPrimaryActionButtonDriver = function getPrimaryActionButtonDriver() { return (0, _ButtonLegacy["default"])({ element: _element.querySelector("[data-hook=\"".concat(_constants.dataHooks.primaryAction, "\"]")) }); }; var getVisibleActionTooltipDriver = function getVisibleActionTooltipDriver(actionIndex) { return (0, _Tooltip.tooltipDriverFactory)({ element: _element.querySelectorAll("[data-hook=\"".concat(_constants.dataHooks.visibleActionTooltip, "\"]"))[actionIndex], eventTrigger: eventTrigger }); }; var getVisibleActionByDataHookTooltipDriver = function getVisibleActionByDataHookTooltipDriver(dataHook) { return (0, _Tooltip.tooltipDriverFactory)({ element: _element.querySelector("[data-hook=\"".concat(dataHook, "\"]")), eventTrigger: eventTrigger }); }; var getVisibleActionButtonDriver = function getVisibleActionButtonDriver(actionIndex) { return (0, _ButtonLegacy["default"])({ element: visibleActions()[actionIndex] }); }; var getVisibleActionByDataHookButtonDriver = function getVisibleActionByDataHookButtonDriver(dataHook) { return (0, _ButtonLegacy["default"])({ element: _element.querySelector("[data-hook=\"".concat(dataHook, "\"]")) }); }; var getHiddenActionsPopoverMenuDriver = function getHiddenActionsPopoverMenuDriver() { return (0, _testkit.popoverMenuTestkitFactory)({ wrapper: wrapper, dataHook: _constants.dataHooks.popoverMenu }); }; return { /** Get the element */ element: function element() { return _element; }, /** Whether the element exists */ exists: function exists() { return !!_element; }, /** Get the driver of the primary action <Button/> from the action column */ getPrimaryActionButtonDriver: getPrimaryActionButtonDriver, /** Click the primary action button from the action column */ clickPrimaryActionButton: function clickPrimaryActionButton() { return getPrimaryActionButtonDriver().click(); }, /** Get whether the primary action button is disabled */ getIsPrimaryActionButtonDisabled: function getIsPrimaryActionButtonDisabled() { return getPrimaryActionButtonDriver().isButtonDisabled(); }, /** Get whether the primary action button prefix icon exists */ primaryActionButtonPrefixIconExists: function primaryActionButtonPrefixIconExists() { return getPrimaryActionButtonDriver().isPrefixIconExists(); }, /** Get whether the primary action button suffix icon exists */ primaryActionButtonSuffixIconExists: function primaryActionButtonSuffixIconExists() { return getPrimaryActionButtonDriver().isSuffixIconExists(); }, /** Get the number of the visible secondary actions */ getVisibleActionsCount: function getVisibleActionsCount() { return visibleActions().length; }, /** Get the number of hidden secondary actions (in the <PopoverMenu/>, requires it to be open) */ getHiddenActionsCount: function getHiddenActionsCount() { return getHiddenActionsPopoverMenuDriver().childrenCount(); }, /** Get the driver of a specific visible secondary action <Tooltip/> */ getVisibleActionTooltipDriver: getVisibleActionTooltipDriver, /** Get the driver of a specific visible secondary action <Tooltip/> by its specified dataHook */ getVisibleActionByDataHookTooltipDriver: getVisibleActionByDataHookTooltipDriver, /** Get the driver of a specific visible secondary action <Button/> */ getVisibleActionButtonDriver: getVisibleActionButtonDriver, /** Get the driver of a specific visible secondary action <Button/> by its specified dataHook */ getVisibleActionByDataHookButtonDriver: getVisibleActionByDataHookButtonDriver, /** Get the driver of the hidden secondary action <PopoverMenu/> */ getHiddenActionsPopoverMenuDriver: getHiddenActionsPopoverMenuDriver, /** Click an a visible secondary action */ clickVisibleAction: function clickVisibleAction(actionIndex) { return getVisibleActionButtonDriver(actionIndex).click(); }, /** Click an a visible secondary action by its specified dataHook */ clickVisibleActionByDataHook: function clickVisibleActionByDataHook(actionDataHook) { return getVisibleActionByDataHookButtonDriver(actionDataHook).click(); }, /** Click on the hidden secondary actions <PopoverMenu/> */ clickPopoverMenu: function clickPopoverMenu() { return getHiddenActionsPopoverMenuDriver().getTriggerElement(_constants.dataHooks.triggerElement).click(); }, /** Click on a hidden secondary action (requires the <PopoverMenu/> to be open) */ clickHiddenAction: function clickHiddenAction(actionIndex) { return getHiddenActionsPopoverMenuDriver().clickAtChild(actionIndex); }, clickHiddenActionByDataHook: function clickHiddenActionByDataHook(actionDataHook) { return getHiddenActionsPopoverMenuDriver().clickAtChildByDataHook(actionDataHook); } }; }; var _default = tableActionCellDriverFactory; exports["default"] = _default;