import { DropdownBaseUniDriver, SegmentedToggleUniDriver, } from '@wix/design-system/dist/testkit/unidriver'; import { UniDriver } from '@wix/wix-ui-test-utils/unidriver'; export function TableGridSwitchButtonUniDriver( base: UniDriver, body: UniDriver, ) { const getSegmented = () => SegmentedToggleUniDriver(base, body); // New DropdownBase driver (experiment enabled) const getDropdown = () => DropdownBaseUniDriver(body.$('[data-hook="layout-switch-popover"]'), body); const getLayoutSwitchButton = () => body.$('[data-hook="layout-switch-button"]'); return { ...getSegmented(), /** Check if the SegmentedToggle (old UI) exists */ exists: () => base.exists(), /** Click table button in SegmentedToggle (old UI) */ clickTableButton: () => base .$(`[data-hook="toggle-option-table"] [data-hook="toggle-icon"]`) .click(), /** Click grid button in SegmentedToggle (old UI) */ clickGridButton: () => base .$(`[data-hook="toggle-option-grid"] [data-hook="toggle-icon"]`) .click(), popoverExists: () => getDropdown().exists(), layoutSwitchButtonExists: () => getLayoutSwitchButton().exists(), openPopover: () => getLayoutSwitchButton().click(), isPopoverOpen: () => getDropdown().isDropdownShown(), clickLayoutOption: (option: 'table' | 'grid' | 'spreadsheet') => getDropdown().selectOptionByDataHook(`layout-option-${option}`), getLayoutOptionsCount: () => getDropdown().optionsCount(), }; } export default TableGridSwitchButtonUniDriver;