import { UniDriver } from '@wix/wix-ui-test-utils/unidriver'; import { PopoverMenuUniDriver, TooltipUniDriver, } from '@wix/design-system/dist/testkit/unidriver'; export const MoreActionsUniDriver = (base: UniDriver, body: UniDriver) => { const moreActionsPopoverDriver = (dataHook: string) => PopoverMenuUniDriver(base.$(`[data-hook="${dataHook}"]`), body); const getMoreActions = (dataHook = 'more-actions') => ({ exists: () => moreActionsPopoverDriver(dataHook).exists(), /** Gets trigger element of more Actions */ getTriggerElement: () => moreActionsPopoverDriver(dataHook).getTriggerElement( 'more-actions-popover-button', ), /** Opens the more actions popover */ open: () => moreActionsPopoverDriver(dataHook) .getTriggerElement('more-actions-popover-button') .click(), /** Indicates whether the more actions popover is open */ isOpen: () => moreActionsPopoverDriver(dataHook).isMenuOpen(), /** Clicks at child by data-hook */ clickAtChildByDataHook: (childDataHook: string) => moreActionsPopoverDriver(dataHook).clickAtChildByDataHook(childDataHook), /** Clicks at child by index */ clickAtChildByIndex: (index: number) => moreActionsPopoverDriver(dataHook).clickAtChild(index), /** Gets content at index */ childContentAt: (index: number) => moreActionsPopoverDriver(dataHook).itemContentAt(index), /** Gets children count */ childrenCount: () => moreActionsPopoverDriver(dataHook).childrenCount(), getTooltip: () => { return TooltipUniDriver( base.$('[data-hook="more-actions-tooltip"]'), body, ); }, }); return { getMoreActions, }; };