import { BrowsingPage , Viewer , Utils , Menu } from '@alfresco/aca-testing-shared' ; import { BrowserActions } from '@alfresco/adf-testing' ; const page = new BrowsingPage ( ) ; const { dataTable , toolbar } = page ; const contextMenu = dataTable . menu ; const viewer = new Viewer ( ) ; const viewerToolbar = viewer . toolbar ; const menu = new Menu ( ) ; export async function checkContextMenu ( item , expectedContextMenu ) { await dataTable . rightClickOnItem ( item ) ; await contextMenu . waitForMenuToOpen ( ) ; const actualActions = await contextMenu . getMenuItems ( ) ; expect ( actualActions ) . toEqual ( expectedContextMenu ) ; await Utils . pressEscape ( ) ; await menu . waitForMenuToClose ( ) ; } export async function checkToolbarPrimary ( item , expectedToolbarPrimary ) { await dataTable . selectItem ( item ) ; const actualPrimaryActions = await toolbar . getButtons ( ) ; expect ( actualPrimaryActions ) . toEqual ( expectedToolbarPrimary ) ; } export async function checkToolbarMoreActions ( item , expectedToolbarMore ) { await dataTable . selectItem ( item ) ; await toolbar . openMoreMenu ( ) ; const actualMoreActions = await toolbar . menu . getMenuItems ( ) ; expect ( actualMoreActions ) . toEqual ( expectedToolbarMore ) ; await toolbar . closeMoreMenu ( ) ; } export async function checkToolbarActions ( item , expectedToolbarPrimary , expectedToolbarMore ) { await dataTable . selectItem ( item ) ; const actualPrimaryActions = await toolbar . getButtons ( ) ; expect ( actualPrimaryActions ) . toEqual ( expectedToolbarPrimary ) ; await toolbar . openMoreMenu ( ) ; const actualMoreActions = await toolbar . menu . getMenuItems ( ) ; expect ( actualMoreActions ) . toEqual ( expectedToolbarMore ) ; await toolbar . closeMoreMenu ( ) ; } export async function checkMultipleSelContextMenu ( items , expectedContextMenu ) { await dataTable . selectMultipleItems ( items ) ; await dataTable . rightClickOnMultipleSelection ( ) ; await contextMenu . waitForMenuToOpen ( ) ; const actualActions = await contextMenu . getMenuItems ( ) ; expect ( actualActions ) . toEqual ( expectedContextMenu ) ; await Utils . pressEscape ( ) ; await menu . waitForMenuToClose ( ) ; } export async function checkMultipleSelToolbarPrimary ( items , expectedToolbarPrimary ) { await dataTable . selectMultipleItems ( items ) ; const actualPrimaryActions = await toolbar . getButtons ( ) ; expect ( actualPrimaryActions ) . toEqual ( expectedToolbarPrimary ) ; } export async function checkMultipleSelToolbarActions ( items , expectedToolbarPrimary , expectedToolbarMore ) { await dataTable . selectMultipleItems ( items ) ; const actualPrimaryActions = await toolbar . getButtons ( ) ; expect ( actualPrimaryActions ) . toEqual ( expectedToolbarPrimary ) ; await toolbar . openMoreMenu ( ) ; const actualMoreActions = await toolbar . menu . getMenuItems ( ) ; expect ( actualMoreActions ) . toEqual ( expectedToolbarMore ) ; await toolbar . closeMoreMenu ( ) ; } export async function checkViewerActions ( item , expectedToolbarPrimary , expectedToolbarMore ) { await dataTable . selectItem ( item ) ; await BrowserActions . click ( toolbar . viewButton ) ; await viewer . waitForViewerToOpen ( ) ; let actualPrimaryActions = await viewerToolbar . getButtons ( ) ; actualPrimaryActions = removeClosePreviousNextOldInfo ( actualPrimaryActions ) ; expect ( actualPrimaryActions ) . toEqual ( expectedToolbarPrimary ) ; await viewerToolbar . openMoreMenu ( ) ; const actualMoreActions = await viewerToolbar . menu . getMenuItems ( ) ; expect ( actualMoreActions ) . toEqual ( expectedToolbarMore ) ; await Utils . pressEscape ( ) ; await menu . waitForMenuToClose ( ) ; } const toRemove = [ 'Close' , 'Previous File' , 'Next File' , 'View details' ] ; function removeClosePreviousNextOldInfo ( actions ) { return actions . filter ( ( elem ) => ! toRemove . includes ( elem ) ) ; }