import { RepoClient , Utils , AdminActions , UserActions , LoginPage , SearchResultsPage , BrowsingPage } from '@alfresco/aca-testing-shared' ; import * as testData from './test-data' ; import * as testUtil from '../test-util' ; describe ( 'Folders - available actions : ' , ( ) => { const random = testData . random ; const username = `user-${ Utils . random ( ) }` ; const parentName = `parent-${ Utils . random ( ) }` ; let parentId ; let folderFavId ; let folderFav2Id ; let fileFavId ; const userApi = new RepoClient ( username , username ) ; const adminApiActions = new AdminActions ( ) ; const userActions = new UserActions ( ) ; const loginPage = new LoginPage ( ) ; const page = new BrowsingPage ( ) ; const { dataTable } = page ; const { searchInput } = page . header ; const searchResultsPage = new SearchResultsPage ( ) ; beforeAll ( async ( ) => { await adminApiActions . createUser ( { username } ) ; parentId = ( await userApi . nodes . createFolder ( parentName ) ) . entry . id ; await userApi . nodes . createFile ( testData . file . name , parentId ) ; fileFavId = ( await userApi . nodes . createFile ( testData . fileFav . name , parentId ) ) . entry . id ; await userApi . nodes . createFolder ( testData . folder . name , parentId ) ; folderFavId = ( await userApi . nodes . createFolder ( testData . folderFav . name , parentId ) ) . entry . id ; folderFav2Id = ( await userApi . nodes . createFolder ( testData . folderFav2 . name , parentId ) ) . entry . id ; const initialFavoritesTotalItems = ( await userApi . favorites . getFavoritesTotalItems ( ) ) || 0 ; await userApi . favorites . addFavoritesByIds ( 'folder' , [ folderFavId , folderFav2Id ] ) ; await userApi . favorites . addFavoritesByIds ( 'file' , [ fileFavId ] ) ; await userApi . favorites . waitForApi ( { expect : initialFavoritesTotalItems + 3 } ) ; await userApi . search . waitForNodes ( random , { expect : 5 } ) ; await loginPage . loginWith ( username ) ; } ) ; afterAll ( async ( ) => { await userActions . login ( username , username ) ; await userActions . deleteNodes ( [ parentId ] ) ; await userActions . emptyTrashcan ( ) ; } ) ; beforeEach ( async ( ) => { await Utils . pressEscape ( ) ; } ) ; describe ( 'on Personal Files : ' , ( ) => { beforeAll ( async ( ) => { await page . clickPersonalFilesAndWait ( ) ; await dataTable . doubleClickOnRowByName ( parentName ) ; await dataTable . waitForHeader ( ) ; } ) ; it ( 'Folder not favorite  - [C213123]' , async ( ) => { await testUtil . checkToolbarActions ( testData . folder . name , testData . folder . toolbarPrimary , testData . folder . toolbarMore ) ; await testUtil . checkContextMenu ( testData . folder . name , testData . folder . contextMenu ) ; } ) ; it ( 'Folder favorite - [C280451]' , async ( ) => { await testUtil . checkToolbarActions ( testData . folderFav . name , testData . folderFav . toolbarPrimary , testData . folderFav . toolbarMore ) ; await testUtil . checkContextMenu ( testData . folderFav . name , testData . folderFav . contextMenu ) ; } ) ; it ( 'multiple folders - [C280459]' , async ( ) => { await testUtil . checkMultipleSelContextMenu ( [ testData . folderFav . name , testData . folder . name ] , testData . multipleSel . contextMenu ) ; await testUtil . checkMultipleSelToolbarActions ( [ testData . folderFav . name , testData . folder . name ] , testData . multipleSel . toolbarPrimary , testData . multipleSel . toolbarMore ) ; } ) ; it ( 'both files and folders - [C280460]' , async ( ) => { await testUtil . checkMultipleSelContextMenu ( [ testData . file . name , testData . folder . name ] , testData . multipleSel . contextMenu ) ; await testUtil . checkMultipleSelToolbarActions ( [ testData . file . name , testData . folder . name ] , testData . multipleSel . toolbarPrimary , testData . multipleSel . toolbarMore ) ; } ) ; } ) ; describe ( 'on Favorites Files : ' , ( ) => { beforeAll ( async ( ) => { await page . clickFavoritesAndWait ( ) ; } ) ; it ( 'Folder favorite - [C291817]' , async ( ) => { await testUtil . checkToolbarActions ( testData . folderFav . name , testData . folderFav . toolbarPrimary , testData . folderFav . favoritesToolbarMore ) ; await testUtil . checkContextMenu ( testData . folderFav . name , testData . folderFav . favoritesContextMenu ) ; } ) ; it ( 'multiple folders - [C280664]' , async ( ) => { await testUtil . checkMultipleSelContextMenu ( [ testData . folderFav . name , testData . folderFav2 . name ] , testData . multipleSelAllFav . favoritesContextMenu ) ; await testUtil . checkMultipleSelToolbarActions ( [ testData . folderFav . name , testData . folderFav2 . name ] , testData . multipleSelAllFav . toolbarPrimary , testData . multipleSelAllFav . favoritesToolbarMore ) ; } ) ; it ( 'both files and folders - [C280657]' , async ( ) => { await testUtil . checkMultipleSelContextMenu ( [ testData . fileFav . name , testData . folderFav . name ] , testData . multipleSelAllFav . favoritesContextMenu ) ; await testUtil . checkMultipleSelToolbarActions ( [ testData . fileFav . name , testData . folderFav . name ] , testData . multipleSelAllFav . toolbarPrimary , testData . multipleSelAllFav . favoritesToolbarMore ) ; } ) ; } ) ; describe ( 'on Search Results : ' , ( ) => { describe ( 'on a folder' , ( ) => { beforeAll ( async ( ) => { await page . clickPersonalFiles ( ) ; await searchInput . clickSearchButton ( ) ; await searchInput . searchFor ( random ) ; await searchResultsPage . waitForResults ( ) ; } ) ; it ( '[C280609] Folder not favorite' , async ( ) => { await testUtil . checkToolbarActions ( testData . folder . name , testData . folder . searchToolbarPrimary , testData . folder . searchToolbarMore ) ; await testUtil . checkContextMenu ( testData . folder . name , testData . folder . searchContextMenu ) ; } ) ; it ( '[C291828] Folder favorite' , async ( ) => { await testUtil . checkToolbarActions ( testData . folderFav . name , testData . folderFav . searchToolbarPrimary , testData . folderFav . searchToolbarMore ) ; await testUtil . checkContextMenu ( testData . folderFav . name , testData . folderFav . searchContextMenu ) ; } ) ; } ) ; describe ( 'on multiple selection' , ( ) => { it ( '[C291821] multiple folders' , async ( ) => { await searchInput . clickSearchButton ( ) ; await searchInput . searchFor ( random ) ; await searchResultsPage . waitForResults ( ) ; await testUtil . checkMultipleSelContextMenu ( [ testData . folder . name , testData . folderFav . name ] , testData . multipleSel . searchContextMenu ) ; await testUtil . checkMultipleSelToolbarActions ( [ testData . folder . name , testData . folderFav . name ] , testData . multipleSel . searchToolbarPrimary , testData . multipleSel . searchToolbarMore ) ; } ) ; it ( '[C291822] both files and folders' , async ( ) => { await searchInput . clickSearchButton ( ) ; await searchInput . searchFor ( `${ testData . file . name } or ${ testData . folderFav . name }` ) ; await searchResultsPage . waitForResults ( ) ; await testUtil . checkMultipleSelContextMenu ( [ testData . file . name , testData . folderFav . name ] , testData . multipleSel . searchContextMenu ) ; await testUtil . checkMultipleSelToolbarActions ( [ testData . file . name , testData . folderFav . name ] , testData . multipleSel . searchToolbarPrimary , testData . multipleSel . searchToolbarMore ) ; } ) ; } ) ; } ) ; } ) ;