import { UniDriver } from '@wix/wix-ui-test-utils/unidriver'; import { SidePanelUniDriver } from '@wix/design-system/dist/testkit/unidriver'; export function ArchivedItemsPanelUniDriver( base: UniDriver, body: UniDriver, dataHook: string = 'custom-columns', ) { // Main container with overlay const containerBase = () => base.$(`[data-hook="${dataHook}-archived-items-panel-container"]`); // The SidePanel inside the container - use the design system driver const panelBase = () => containerBase().$(`[data-hook="${dataHook}-archived-items-panel"]`); const panel = () => SidePanelUniDriver(panelBase(), body); const list = () => panelBase().$(`[data-hook="${dataHook}-archived-items-list"]`); // Get all TableListItem elements (archived items) - direct children divs // Must use full selector path, not chained const getArchivedPanelItems = () => panelBase().$$(`[data-hook="${dataHook}-archived-items-list"] > div`); const getItemByIdBase = (id: string) => list().$(`[data-hook="${dataHook}-archived-item-${id}"]`); const getItemMenuBase = (id: string) => panelBase().$(`[data-hook="${dataHook}-archived-item-options-${id}"]`); const getItemMenuTrigger = (id: string) => getItemMenuBase(id).$(`[data-hook="${dataHook}-archived-item-options-trigger"]`); // Note: The 'Restore' and 'Delete' buttons appear in the body via PopoverMenu when an item's menu is opened. // Thus clickItemMenuTrigger must be invoked before so only the buttons on the relevant item's menu can be clicked const getItemRestoreButton = () => body.$(`[data-hook="${dataHook}-archived-item-options-restore"]`); const getItemDeleteButton = () => body.$(`[data-hook="${dataHook}-archived-item-options-delete"]`); return { getContainer: () => containerBase(), exists: () => containerBase().exists(), isVisible: () => containerBase().exists(), getTitle: () => panel().getTitleText(), getSubtitle: () => panel().getSubtitleText(), backButtonExists: () => panel().isBackButtonExists(), clickBackButton: () => panel().clickBack(), clickCloseButton: () => panel().clickClose(), getItemsCount: () => getArchivedPanelItems().count(), getItemText: (id: string) => getItemByIdBase(id).$(`[data-hook="${dataHook}-archived-item-label"]`).text(), clickItemMenuTrigger: (id: string) => getItemMenuTrigger(id).click(), clickRestore: () => getItemRestoreButton().click(), clickDelete: () => getItemDeleteButton().click(), }; }