wix-style-react
Version:
wix-style-react
88 lines (87 loc) • 5.07 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _vanilla = require("@wix/wix-ui-test-utils/vanilla");
var _PopoverMenuUni = require("../PopoverMenu/PopoverMenu.uni.driver");
var _Tooltip = require("../Tooltip/Tooltip.driver");
var _constants = require("./constants");
var _ButtonLegacy = _interopRequireDefault(require("../Button/Button.legacy.driver"));
var popoverMenuTestkitFactory = (0, _vanilla.uniTestkitFactoryCreator)(_PopoverMenuUni.PopoverMenuDriver);
var tableActionCellDriverFactory = _ref => {
var {
element: _element,
wrapper,
eventTrigger
} = _ref;
var visibleActions = () => _element.querySelectorAll("[data-hook=\"".concat(_constants.dataHooks.visibleAction, "\"]"));
var getPrimaryActionButtonVisibility = () => _element.querySelector("[data-hook=\"".concat(_constants.dataHooks.primaryActionWrapper, "\"]")).getAttribute('data-display');
var getPrimaryActionButtonDriver = () => (0, _ButtonLegacy.default)({
element: _element.querySelector("[data-hook=\"".concat(_constants.dataHooks.primaryAction, "\"]"))
});
var getVisibleActionTooltipDriver = actionIndex => (0, _Tooltip.tooltipLegacyDriverFactory)({
element: _element.querySelectorAll("[data-hook=\"".concat(_constants.dataHooks.visibleActionTooltip, "\"]"))[actionIndex],
eventTrigger
});
var getVisibleActionByDataHookTooltipDriver = dataHook => (0, _Tooltip.tooltipLegacyDriverFactory)({
element: _element.querySelector("[data-hook=\"".concat(dataHook, "\"]")),
eventTrigger
});
var getVisibleActionButtonDriver = actionIndex => (0, _ButtonLegacy.default)({
element: visibleActions()[actionIndex]
});
var getVisibleActionByDataHookButtonDriver = dataHook => (0, _ButtonLegacy.default)({
element: _element.querySelector("[data-hook=\"".concat(dataHook, "\"]"))
});
var getHiddenActionsPopoverMenuDriver = () => popoverMenuTestkitFactory({
wrapper,
dataHook: _constants.dataHooks.popoverMenu
});
return {
/** Get the element */
element: () => _element,
/** Whether the element exists */
exists: () => !!_element,
/** Get the driver of the primary action <Button/> from the action column */
getPrimaryActionButtonDriver,
/** Click the primary action button from the action column */
clickPrimaryActionButton: () => getPrimaryActionButtonDriver().click(),
/** Get whether the primary action button is disabled */
getIsPrimaryActionButtonDisabled: () => getPrimaryActionButtonDriver().isButtonDisabled(),
/**
* Gets primary action visibility value
* @returns {Promise<'onHover' | 'always'>}
*/
getPrimaryActionButtonVisibility,
/** Get whether the primary action button prefix icon exists */
primaryActionButtonPrefixIconExists: () => getPrimaryActionButtonDriver().isPrefixIconExists(),
/** Get whether the primary action button suffix icon exists */
primaryActionButtonSuffixIconExists: () => getPrimaryActionButtonDriver().isSuffixIconExists(),
/** Get the number of the visible secondary actions */
getVisibleActionsCount: () => visibleActions().length,
/** Get the number of hidden secondary actions (in the <PopoverMenu/>, requires it to be open) */
getHiddenActionsCount: () => getHiddenActionsPopoverMenuDriver().childrenCount(),
/** Get the driver of a specific visible secondary action <Tooltip/> */
getVisibleActionTooltipDriver,
/** Get the driver of a specific visible secondary action <Tooltip/> by its specified dataHook */
getVisibleActionByDataHookTooltipDriver,
/** Get the driver of a specific visible secondary action <Button/> */
getVisibleActionButtonDriver,
/** Get the driver of a specific visible secondary action <Button/> by its specified dataHook */
getVisibleActionByDataHookButtonDriver,
/** Get the driver of the hidden secondary action <PopoverMenu/> */
getHiddenActionsPopoverMenuDriver,
/** Click an a visible secondary action */
clickVisibleAction: actionIndex => getVisibleActionButtonDriver(actionIndex).click(),
/** Click an a visible secondary action by its specified dataHook */
clickVisibleActionByDataHook: actionDataHook => getVisibleActionByDataHookButtonDriver(actionDataHook).click(),
/** Click on the hidden secondary actions <PopoverMenu/> */
clickPopoverMenu: () => getHiddenActionsPopoverMenuDriver().getTriggerElement(_constants.dataHooks.triggerElement).click(),
/** Click on a hidden secondary action (requires the <PopoverMenu/> to be open) */
clickHiddenAction: actionIndex => getHiddenActionsPopoverMenuDriver().clickAtChild(actionIndex),
clickHiddenActionByDataHook: actionDataHook => getHiddenActionsPopoverMenuDriver().clickAtChildByDataHook(actionDataHook),
getMoreActionsTooltipText: () => _element.getAttribute('data-more-actions-tooltip-text')
};
};
var _default = exports.default = tableActionCellDriverFactory;
//# sourceMappingURL=TableActionCell.driver.js.map