import { UniDriver } from '@wix/wix-ui-test-utils/unidriver'; import { baseUniDriverFactory } from '../../unidriver'; import { ToolbarCollectionErrorStateUniDriver } from '../ErrorState/ToolbarCollectionErrorState.uni.driver'; import { CollectionEmptyStateUniDriver } from '../EmptyState/CollectionEmptyState.uni.driver'; import { CollectionToolbarUniDriver } from '../CollectionToolbar/CollectionToolbar.uni.driver'; import { TextButtonUniDriver } from '@wix/design-system/dist/testkit/unidriver'; import { GridFoldersSectionUniDriver } from './GridFoldersSection.uni.driver'; import { AppliedFiltersTagListUniDriver } from '../AppliedFiltersTagList/AppliedFiltersTagList.uni.driver'; import { SummaryBarUniDriver } from '../SummaryBar/SummaryBar.uni.driver'; export function GridFoldersUniDriver(base: UniDriver, body: UniDriver) { const toolbarBase = () => base.$('[data-hook="collection-toolbar"]'); const foldersSectionBase = () => base.$('[data-hook="folders-section"]'); const itemsSectionBase = () => base.$('[data-hook="items-section"]'); const toggleShowAllFoldersButtonBase = () => foldersSectionBase().$('[data-hook="toggle-show-all-folders-button"]'); const toolbar = () => CollectionToolbarUniDriver(toolbarBase(), body); const getSummaryBar = () => SummaryBarUniDriver(base, body); return { ...baseUniDriverFactory(base), /** Gets a [CollectionToolbarUniDriver](./?path=/story/common-components--collectiontoolbar) */ toolbar: () => toolbar(), getErrorStateByDataHook: (dataHook = 'grid-folders-error-state') => ToolbarCollectionErrorStateUniDriver( base.$(`[data-hook="${dataHook}"]`), body, ), getEmptyStateByDataHook: (dataHook = 'grid-folders-empty-state') => CollectionEmptyStateUniDriver(base.$(`[data-hook="${dataHook}"]`), body), getCardErrorStateByDataHook: (dataHook = 'collection-card-error-state') => ToolbarCollectionErrorStateUniDriver( base.$(`[data-hook="${dataHook}"]`), body, ), _toggleShowAllFoldersButton: () => TextButtonUniDriver(toggleShowAllFoldersButtonBase(), body), /** Clicks the "Show All"/"Show Less" toggle button */ clickToggleShowAllFoldersButton: () => toggleShowAllFoldersButtonBase().click(), /** Indicates the "Show All"/"Show Less" exists */ toggleShowAllFoldersButtonExists: () => toggleShowAllFoldersButtonBase().exists(), /** Gets a [GridFoldersSectionUniDriver](./?path=/story/base-components-collections-gridfolders-gridfolderssection--gridfolderssection) for the folders section */ foldersSection: () => GridFoldersSectionUniDriver(foldersSectionBase(), body), /** Gets a [GridFoldersSectionUniDriver](./?path=/story/base-components-collections-gridfolders-gridfolderssection--gridfolderssection) for the items section */ itemsSection: () => GridFoldersSectionUniDriver(itemsSectionBase(), body), /** Indicates the initial skeleton loader exists */ initialLoaderExists: () => base.$('[data-hook="initial-loader"]').exists(), /** Gets [CollectionSubToolbarUniDriver](./?path=/story/common-components--collectionsubtoolbar) */ subToolbar: () => AppliedFiltersTagListUniDriver( base.$('[data-hook="collection-table-sub-toolbar"]'), body, ), getSummaryBar, }; } export default GridFoldersUniDriver;