diff --git a/e2e/components/data-table/data-table.ts b/e2e/components/data-table/data-table.ts index 8e2975b55..b65c7e05d 100755 --- a/e2e/components/data-table/data-table.ts +++ b/e2e/components/data-table/data-table.ts @@ -57,7 +57,13 @@ export class DataTable extends Component { emptyListTitle: '.adf-empty-content__title', emptyListSubtitle: '.adf-empty-content__subtitle', - emptyListText: '.adf-empty-content__text' + emptyListText: '.adf-empty-content__text', + + emptySearchText: '.empty-search__text', + + searchResultsRow: 'aca-search-results-row', + searchResultsRowLine: '.line', + searchResultsNameLink: '.link' }; head: ElementFinder = this.component.element(by.css(DataTable.selectors.head)); @@ -69,6 +75,8 @@ export class DataTable extends Component { emptyListSubtitle: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListSubtitle)); emptyListText: ElementArrayFinder = this.component.all(by.css(DataTable.selectors.emptyListText)); + emptySearchText: ElementFinder = this.component.element(by.css(DataTable.selectors.emptySearchText)); + menu: Menu = new Menu(); constructor(ancestor?: ElementFinder) { @@ -76,12 +84,12 @@ export class DataTable extends Component { } // Wait methods (waits for elements) - waitForHeader() { - return browser.wait(EC.presenceOf(this.head), BROWSER_WAIT_TIMEOUT, '--- timeout waitForHeader ---'); + async waitForHeader() { + return await browser.wait(EC.presenceOf(this.head), BROWSER_WAIT_TIMEOUT, '--- timeout waitForHeader ---'); } - waitForBody() { - return browser.wait(EC.presenceOf(this.body), BROWSER_WAIT_TIMEOUT, '--- timeout waitForBody ---'); + async waitForBody() { + return await browser.wait(EC.presenceOf(this.body), BROWSER_WAIT_TIMEOUT, '--- timeout waitForBody ---'); } async waitForEmptyState() { @@ -166,20 +174,28 @@ export class DataTable extends Component { return this.body.element(by.cssContainingText(DataTable.selectors.row, name)); } + getRowCells(name: string, location: string = '') { + return this.getRowByName(name, location).all(by.css(DataTable.selectors.cell)); + } + + async getRowCellsCount(itemName: string) { + return await this.getRowCells(itemName).count(); + } + getRowFirstCell(name: string, location: string = '') { - return this.getRowByName(name, location).all(by.css(DataTable.selectors.cell)).get(0); + return this.getRowCells(name, location).get(0); } - getRowNameCell(name: string) { - return this.getRowByName(name).all(by.css(DataTable.selectors.cell)).get(1); + getRowNameCell(name: string, location: string = '') { + return this.getRowCells(name, location).get(1); } - getRowNameCellText(name: string) { - return this.getRowNameCell(name).$('span'); + getRowNameCellSpan(name: string, location: string = '') { + return this.getRowNameCell(name, location).$('span'); } - async getItemNameTooltip(name: string) { - return await this.getRowNameCellText(name).getAttribute('title'); + async getItemNameTooltip(name: string, location: string = '') { + return await this.getRowNameCellSpan(name, location).getAttribute('title'); } async hasCheckMarkIcon(itemName: string, location: string = '') { @@ -266,7 +282,6 @@ export class DataTable extends Component { } async rightClickOnMultipleSelection() { - await this.wait(); const itemFromSelection = this.getSelectedRows().get(0); await browser.actions().click(itemFromSelection, protractor.Button.RIGHT).perform(); } @@ -330,6 +345,10 @@ export class DataTable extends Component { } } + async getEmptySearchResultsText() { + return await this.emptySearchText.getText(); + } + async getCellsContainingName(name: string) { const rows = this.getRows().all(by.cssContainingText(DataTable.selectors.cell, name)); return rows.map(async cell => await cell.getText()); @@ -370,4 +389,53 @@ export class DataTable extends Component { }, {}); } + getSearchResultsRowByName(name: string, location: string = '') { + if (location) { + return this.body.all(by.cssContainingText(DataTable.selectors.searchResultsRow, name)) + .filter(async (elem) => await browser.isElementPresent(elem.element(by.cssContainingText(DataTable.selectors.searchResultsRowLine, location)))) + .first(); + } + return this.body.element(by.cssContainingText(DataTable.selectors.searchResultsRow, name)); + } + + getSearchResultRowLines(name: string, location: string = '') { + return this.getSearchResultsRowByName(name, location).all(by.css(DataTable.selectors.searchResultsRowLine)); + } + + async getSearchResultLinesCount(name: string, location: string = '') { + return await this.getSearchResultRowLines(name, location).count(); + } + + getSearchResultNthLine(name: string, location: string = '', index: number) { + return this.getSearchResultRowLines(name, location).get(index); + } + + async getSearchResultNameAndTitle(name: string, location: string = '') { + return await this.getSearchResultNthLine(name, location, 0).getText(); + } + + async getSearchResultDescription(name: string, location: string = '') { + return await this.getSearchResultNthLine(name, location, 1).getText(); + } + + async getSearchResultModified(name: string, location: string = '') { + return await this.getSearchResultNthLine(name, location, 2).getText(); + } + + async getSearchResultLocation(name: string, location: string = '') { + return await this.getSearchResultNthLine(name, location, 3).getText(); + } + + getSearchResultNameLink(itemName: string, location: string = '') { + return this.getSearchResultsRowByName(itemName, location).$(DataTable.selectors.searchResultsNameLink); + } + + async hasLinkOnSearchResultName(itemName: string, location: string = '') { + return await this.getSearchResultNameLink(itemName, location).isPresent(); + } + + async clickSearchResultNameLink(itemName: string, location: string = '') { + await this.getSearchResultNameLink(itemName, location).click(); + } + } diff --git a/e2e/components/dialog/confirm-dialog.ts b/e2e/components/dialog/confirm-dialog.ts index f26265890..e536dff60 100755 --- a/e2e/components/dialog/confirm-dialog.ts +++ b/e2e/components/dialog/confirm-dialog.ts @@ -109,7 +109,7 @@ export class ConfirmDialog extends Component { } async clickCancel() { - return await this.clickButton('Cancel'); + return await this.cancelButton.click(); } async clickKeep() { diff --git a/e2e/components/login/login.ts b/e2e/components/login/login.ts index 9d33decb2..b4e654f44 100755 --- a/e2e/components/login/login.ts +++ b/e2e/components/login/login.ts @@ -68,8 +68,8 @@ export class LoginComponent extends Component { await this.enterPassword(password); } - submit() { - return this.submitButton.click(); + async submit() { + await this.submitButton.click(); } async clickPasswordVisibility() { diff --git a/e2e/components/menu/menu.ts b/e2e/components/menu/menu.ts index 07b9ae09c..94aa73639 100755 --- a/e2e/components/menu/menu.ts +++ b/e2e/components/menu/menu.ts @@ -82,7 +82,6 @@ export class Menu extends Component { } async waitForMenuToOpen() { - await browser.wait(EC.presenceOf(browser.element(by.css('.cdk-overlay-backdrop'))), BROWSER_WAIT_TIMEOUT); await browser.wait(EC.presenceOf(browser.element(by.css('.mat-menu-panel'))), BROWSER_WAIT_TIMEOUT); await browser.wait(EC.visibilityOf(this.items.get(0)), BROWSER_WAIT_TIMEOUT); } diff --git a/e2e/components/search/search-input.ts b/e2e/components/search/search-input.ts index 6246561ca..37ebec3fc 100755 --- a/e2e/components/search/search-input.ts +++ b/e2e/components/search/search-input.ts @@ -167,9 +167,4 @@ export class SearchInput extends Component { await this.searchBar.sendKeys(text); await this.searchBar.sendKeys(protractor.Key.ENTER); } - - async searchForTextAndCloseSearchOptions(text: string) { - await this.searchFor(text); - await Utils.pressEscape(); - } } diff --git a/e2e/pages/page.ts b/e2e/pages/page.ts index 0d7a72ceb..6663b7e66 100755 --- a/e2e/pages/page.ts +++ b/e2e/pages/page.ts @@ -25,6 +25,7 @@ import { browser, by, ElementFinder, ExpectedConditions as EC, until } from 'protractor'; import { BROWSER_WAIT_TIMEOUT, USE_HASH_STRATEGY } from './../configs'; +import { Utils } from '../utilities/utils'; export abstract class Page { protected static locators = { @@ -81,6 +82,16 @@ export abstract class Page { await browser.wait(EC.visibilityOf(this.dialogContainer), BROWSER_WAIT_TIMEOUT); } + async isDialogOpen() { + return await browser.isElementPresent(this.dialogContainer); + } + + async closeOpenDialogs() { + while (await this.isDialogOpen()) { + await Utils.pressEscape(); + } + } + async refresh() { await browser.refresh(); await this.waitForApp(); diff --git a/e2e/pages/search-results-page.ts b/e2e/pages/search-results-page.ts index 5ec2a4e10..a6b7c6a57 100755 --- a/e2e/pages/search-results-page.ts +++ b/e2e/pages/search-results-page.ts @@ -23,35 +23,37 @@ * along with Alfresco. If not, see . */ -import { browser, ElementFinder } from 'protractor'; +import { browser, by } from 'protractor'; import { BrowsingPage } from './browsing-page'; export class SearchResultsPage extends BrowsingPage { private static selectors = { - root: 'aca-search-results', - filter: 'adf-search-filter', - expansionPanel: 'mat-expansion-panel', - size: '#expansion-panel-SEARCH.CATEGORIES.SIZE', - createdDate: '#expansion-panel-SEARCH.CATEGORIES.CREATED_DATE', - modifiedDate: '#expansion-panel-SEARCH.CATEGORIES.MODIFIED_DATE', - fileType: '#expansion-panel-SEARCH.FACET_FIELDS.FILE_TYPE', - creator: '#expansion-panel-SEARCH.CATEGORIES.CREATOR', - modifier: '#expansion-panel-SEARCH.CATEGORIES.MODIFIER', - location: '#expansion-panel-SEARCH.CATEGORIES.LOCATION', + root: 'aca-search-results', - resultsContent: 'adf-search-results__content', - resultsContentHeader: 'adf-search-results__content-header', - resultsInfoText: 'adf-search-results--info-text', - resultsFacets: 'adf-search-results__facets', + filter: 'adf-search-filter', + expansionPanel: 'mat-expansion-panel', + size: '#expansion-panel-SEARCH.CATEGORIES.SIZE', + createdDate: '#expansion-panel-SEARCH.CATEGORIES.CREATED_DATE', + modifiedDate: '#expansion-panel-SEARCH.CATEGORIES.MODIFIED_DATE', + fileType: '#expansion-panel-SEARCH.FACET_FIELDS.FILE_TYPE', + creator: '#expansion-panel-SEARCH.CATEGORIES.CREATOR', + modifier: '#expansion-panel-SEARCH.CATEGORIES.MODIFIER', + location: '#expansion-panel-SEARCH.CATEGORIES.LOCATION', - sortingPicker: 'adf-sorting-picker' + resultsContent: 'adf-search-results__content', + resultsContentHeader: '.adf-search-results__content-header', + resultsInfoText: 'adf-search-results--info-text', + resultsFacets: 'adf-search-results__facets', + + sortingPicker: 'adf-sorting-picker' }; - root: ElementFinder = browser.$(SearchResultsPage.selectors.root); - - waitForResults() { - return this.dataTable.waitForBody(); + async waitForResults() { + return await this.dataTable.waitForBody(); } + async getResultsHeader() { + return await browser.element(by.css(SearchResultsPage.selectors.resultsContentHeader)).getText(); + } } diff --git a/e2e/suites/actions/context-menu-multiple-selection.test.ts b/e2e/suites/actions/context-menu-multiple-selection.test.ts index 0283d3a9f..8e1366c8a 100755 --- a/e2e/suites/actions/context-menu-multiple-selection.test.ts +++ b/e2e/suites/actions/context-menu-multiple-selection.test.ts @@ -576,7 +576,7 @@ describe('Context menu actions - multiple selection : ', () => { it('correct actions appear when multiple files are selected - [C291831]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFiles(); - await searchInput.searchForTextAndCloseSearchOptions('my-inSite-file'); + await searchInput.searchFor('my-inSite-file'); await dataTable.selectMultipleItems([ file1Site, file2Site ]); await dataTable.rightClickOnMultipleSelection(); @@ -596,7 +596,7 @@ describe('Context menu actions - multiple selection : ', () => { it('correct actions appear when multiple locked files are selected - [C297632]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFiles(); - await searchInput.searchForTextAndCloseSearchOptions('my-inSite-file'); + await searchInput.searchFor('my-inSite-file'); await dataTable.selectMultipleItems([ fileLocked1Site, fileLocked2Site ]); await dataTable.rightClickOnMultipleSelection(); @@ -616,7 +616,7 @@ describe('Context menu actions - multiple selection : ', () => { it('correct actions appear when multiple folders are selected - [C291832]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFolders(); - await searchInput.searchForTextAndCloseSearchOptions('my-inSite-folder'); + await searchInput.searchFor('my-inSite-folder'); await dataTable.selectMultipleItems([ folder1Site, folder2Site ]); await dataTable.rightClickOnMultipleSelection(); @@ -636,7 +636,7 @@ describe('Context menu actions - multiple selection : ', () => { it('correct actions appear when both files and folders are selected - [C291833]', async () => { await searchInput.clickSearchButton(); await searchInput.checkFilesAndFolders(); - await searchInput.searchForTextAndCloseSearchOptions('my-inSite-f'); + await searchInput.searchFor('my-inSite-f'); await dataTable.selectMultipleItems([ file1Site, file2Site, folder1Site, folder2Site ]); await dataTable.rightClickOnMultipleSelection(); diff --git a/e2e/suites/actions/context-menu-single-selection.test.ts b/e2e/suites/actions/context-menu-single-selection.test.ts index ed80b3d02..ea9798ac7 100755 --- a/e2e/suites/actions/context-menu-single-selection.test.ts +++ b/e2e/suites/actions/context-menu-single-selection.test.ts @@ -359,7 +359,7 @@ describe('Context menu actions - single selection : ', () => { it('Available actions for a library - Search Results - user is a member - [C291812]', async () => { await searchInput.clickSearchButton(); await searchInput.checkLibraries(); - await searchInput.searchForTextAndCloseSearchOptions(siteName); + await searchInput.searchFor(siteName); await dataTable.rightClickOnItem(siteName); expect(await dataTable.hasContextMenu()).toBe(true, 'Context menu is not displayed'); @@ -371,7 +371,7 @@ describe('Context menu actions - single selection : ', () => { it('Available actions for a library - Search Results - user is not a member - [C291813]', async () => { await searchInput.clickSearchButton(); await searchInput.checkLibraries(); - await searchInput.searchForTextAndCloseSearchOptions(adminPublic); + await searchInput.searchFor(adminPublic); await dataTable.rightClickOnItem(adminPublic); expect(await dataTable.hasContextMenu()).toBe(true, 'Context menu is not displayed'); @@ -383,7 +383,7 @@ describe('Context menu actions - single selection : ', () => { it('Available actions for a moderated library - Search Results - user requested to join - [C291814]', async () => { await searchInput.clickSearchButton(); await searchInput.checkLibraries(); - await searchInput.searchForTextAndCloseSearchOptions(adminModerated); + await searchInput.searchFor(adminModerated); await dataTable.rightClickOnItem(adminModerated); expect(await dataTable.hasContextMenu()).toBe(true, 'Context menu is not displayed'); @@ -632,7 +632,7 @@ describe('Context menu actions - single selection : ', () => { it('Context menu has the correct actions for a file - [C291827]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFiles(); - await searchInput.searchForTextAndCloseSearchOptions(fileSiteUser); + await searchInput.searchFor(fileSiteUser); await dataTable.rightClickOnItem(fileSiteUser); expect(await contextMenu.isEditOfflinePresent()).toBe(true, `Edit offline is not displayed for ${fileSiteUser}`); @@ -654,7 +654,7 @@ describe('Context menu actions - single selection : ', () => { it('Context menu has the correct actions for a locked file - [C297638]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFiles(); - await searchInput.searchForTextAndCloseSearchOptions(fileLocked); + await searchInput.searchFor(fileLocked); await dataTable.rightClickOnItem(fileLocked); expect(await contextMenu.isEditOfflinePresent()).toBe(false, `Edit offline is displayed for ${fileLocked}`); @@ -676,7 +676,7 @@ describe('Context menu actions - single selection : ', () => { it('Context menu has the correct actions for a folder - [C291828]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFolders(); - await searchInput.searchForTextAndCloseSearchOptions(folderSiteUser); + await searchInput.searchFor(folderSiteUser); await dataTable.rightClickOnItem(folderSiteUser); expect(await contextMenu.isDownloadPresent()).toBe(true, `Download is not displayed for ${folderSiteUser}`); diff --git a/e2e/suites/actions/copy.test.ts b/e2e/suites/actions/copy.test.ts index 4de50108e..b805557ac 100755 --- a/e2e/suites/actions/copy.test.ts +++ b/e2e/suites/actions/copy.test.ts @@ -36,6 +36,7 @@ describe('Copy content', () => { const destinationRF = `destinationRecent-${Utils.random()}`; let destinationIdRF; const destinationSF = `destinationShared-${Utils.random()}`; let destinationIdSF; const destinationFav = `destinationFav-${Utils.random()}`; let destinationIdFav; + const destinationSearch = `destinationSearch-${Utils.random()}`; let destinationIdSearch; const file1 = `file1-${Utils.random()}.txt`; let file1Id; @@ -48,7 +49,7 @@ describe('Copy content', () => { const existingFile = `existing-${Utils.random()}`; let existingFileId; const existingFolder = `existing-${Utils.random()}`; - let existingId1, existingId2, existingId2RF, existingId2SF, existingId2Fav; + let existingId1, existingId2, existingId2RF, existingId2SF, existingId2Fav, existingId2Search; const file2InFolder = `file2InFolder-${Utils.random()}.txt`; const file3InFolder = `file3InFolder-${Utils.random()}.txt`; @@ -57,6 +58,7 @@ describe('Copy content', () => { const folderSiteRF = `folderSiteRecent-${Utils.random()}`; const folderSiteSF = `folderSiteShared-${Utils.random()}`; const folderSiteFav = `folderSiteFav-${Utils.random()}`; + const folderSiteSearch = `folderSiteSearch-${Utils.random()}`; const apis = { admin: new RepoClient(), @@ -67,6 +69,7 @@ describe('Copy content', () => { const page = new BrowsingPage(); const { dataTable, toolbar } = page; const copyDialog = new CopyMoveDialog(); + const { searchInput } = page.header; beforeAll(async (done) => { await apis.admin.people.createUser({ username }); @@ -76,6 +79,7 @@ describe('Copy content', () => { destinationIdRF = (await apis.user.nodes.createFolder(destinationRF)).entry.id; destinationIdSF = (await apis.user.nodes.createFolder(destinationSF)).entry.id; destinationIdFav = (await apis.user.nodes.createFolder(destinationFav)).entry.id; + destinationIdSearch = (await apis.user.nodes.createFolder(destinationSearch)).entry.id; file1Id = (await apis.user.nodes.createFile(file1, sourceId)).entry.id; await apis.user.shared.shareFileById(file1Id); @@ -99,17 +103,20 @@ describe('Copy content', () => { await apis.user.nodes.createFile(`${existingFile}.txt`, destinationIdRF); await apis.user.nodes.createFile(`${existingFile}.txt`, destinationIdSF); await apis.user.nodes.createFile(`${existingFile}.txt`, destinationIdFav); + await apis.user.nodes.createFile(`${existingFile}.txt`, destinationIdSearch); existingId1 = (await apis.user.nodes.createFolder(existingFolder, sourceId)).entry.id; existingId2 = (await apis.user.nodes.createFolder(existingFolder, destinationIdPF)).entry.id; existingId2RF = (await apis.user.nodes.createFolder(existingFolder, destinationIdRF)).entry.id; existingId2SF = (await apis.user.nodes.createFolder(existingFolder, destinationIdSF)).entry.id; existingId2Fav = (await apis.user.nodes.createFolder(existingFolder, destinationIdFav)).entry.id; + existingId2Search = (await apis.user.nodes.createFolder(existingFolder, destinationIdSearch)).entry.id; await apis.user.nodes.createFile(file2InFolder, existingId1); await apis.user.nodes.createFile(file3InFolder, existingId2); await apis.user.nodes.createFile(file3InFolder, existingId2RF); await apis.user.nodes.createFile(file3InFolder, existingId2SF); await apis.user.nodes.createFile(file3InFolder, existingId2Fav); + await apis.user.nodes.createFile(file3InFolder, existingId2Search); await apis.user.favorites.addFavoriteById('folder', existingId1); await apis.user.sites.createSite(siteName); @@ -118,6 +125,7 @@ describe('Copy content', () => { await apis.user.nodes.createFolder(folderSiteRF, docLibId); await apis.user.nodes.createFolder(folderSiteSF, docLibId); await apis.user.nodes.createFolder(folderSiteFav, docLibId); + await apis.user.nodes.createFolder(folderSiteSearch, docLibId); await apis.user.shared.waitForApi({ expect: 4 }); await apis.user.favorites.waitForApi({ expect: 7 }); @@ -128,10 +136,6 @@ describe('Copy content', () => { afterAll(async (done) => { await apis.user.nodes.deleteNodeById(sourceId); - await apis.user.nodes.deleteNodeById(destinationIdPF); - await apis.user.nodes.deleteNodeById(destinationIdRF); - await apis.user.nodes.deleteNodeById(destinationIdSF); - await apis.user.nodes.deleteNodeById(destinationIdFav); await apis.user.sites.deleteSite(siteName); done(); }); @@ -144,6 +148,11 @@ describe('Copy content', () => { done(); }); + afterAll(async done => { + await apis.user.nodes.deleteNodeById(destinationIdPF); + done(); + }); + it('Copy a file - [C217135]', async () => { await dataTable.selectItem(file1); await toolbar.clickMoreActionsCopy(); @@ -273,6 +282,11 @@ describe('Copy content', () => { done(); }); + afterAll(async done => { + await apis.user.nodes.deleteNodeById(destinationIdRF); + done(); + }); + it('Copy a file - [C280194]', async () => { await dataTable.selectItem(file1, source); await toolbar.clickMoreActionsCopy(); @@ -351,6 +365,11 @@ describe('Copy content', () => { done(); }); + afterAll(async done => { + await apis.user.nodes.deleteNodeById(destinationIdSF); + done(); + }); + it('Copy a file - [C280206]', async () => { await dataTable.selectItem(file1, source); await toolbar.clickMoreActionsCopy(); @@ -431,6 +450,11 @@ describe('Copy content', () => { done(); }); + afterAll(async done => { + await apis.user.nodes.deleteNodeById(destinationIdFav); + done(); + }); + it('Copy a file - [C280218]', async () => { await dataTable.selectItem(file1); await toolbar.clickMoreActionsCopy(); @@ -553,4 +577,156 @@ describe('Copy content', () => { }); }); + describe('from Search Results', () => { + beforeEach(async (done) => { + await Utils.pressEscape(); + done(); + }); + + afterAll(async done => { + await apis.user.nodes.deleteNodeById(destinationIdSearch); + done(); + }); + + it('Copy a file - [C306932]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(file1); + await dataTable.waitForBody(); + + await dataTable.selectItem(file1, source); + await toolbar.clickMoreActionsCopy(); + await copyDialog.selectLocation('Personal Files'); + await copyDialog.selectDestination(destinationSearch); + await copyDialog.clickCopy(); + const msg = await page.getSnackBarMessage(); + expect(msg).toContain('Copied 1 item'); + expect(msg).toContain('Undo'); + + await copyDialog.waitForDialogToClose(); + await page.clickPersonalFilesAndWait(); + await dataTable.doubleClickOnRowByName(destinationSearch); + expect(await dataTable.isItemPresent(file1)).toBe(true, `${file1} not present in destination folder`); + }); + + it('Copy a folder with content - [C306943]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(folder1); + await dataTable.waitForBody(); + + await dataTable.selectItem(folder1, source); + await toolbar.clickMoreActionsCopy(); + await copyDialog.selectLocation('Personal Files'); + await copyDialog.selectDestination(destinationSearch); + await copyDialog.clickCopy(); + const msg = await page.getSnackBarMessage(); + expect(msg).toContain('Copied 1 item'); + expect(msg).toContain('Undo'); + + await copyDialog.waitForDialogToClose(); + await page.clickPersonalFilesAndWait(); + await dataTable.doubleClickOnRowByName(destinationSearch); + expect(await dataTable.isItemPresent(folder1)).toBe(true, `${folder1} not present in destination folder`); + expect(await dataTable.isItemPresent(fileInFolder)).toBe(false, `${fileInFolder} is present in destination`); + + await dataTable.doubleClickOnRowByName(folder1); + expect(await dataTable.isItemPresent(fileInFolder)).toBe(true, `${fileInFolder} is not present in parent folder`); + }); + + it('Copy multiple items - [C306944]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor('file'); + await dataTable.waitForBody(); + + await dataTable.selectMultipleItems([file2, file3], source); + await toolbar.clickMoreActionsCopy(); + await copyDialog.selectLocation('Personal Files'); + await copyDialog.selectDestination(destinationSearch); + await copyDialog.clickCopy(); + const msg = await page.getSnackBarMessage(); + expect(msg).toContain('Copied 2 items'); + expect(msg).toContain('Undo'); + + await copyDialog.waitForDialogToClose(); + await page.clickPersonalFilesAndWait(); + await dataTable.doubleClickOnRowByName(destinationSearch); + expect(await dataTable.isItemPresent(file2)).toBe(true, `${file2} not present in destination folder`); + expect(await dataTable.isItemPresent(file3)).toBe(true, `${file3} not present in destination folder`); + }); + + it('Copy a file with a name that already exists on the destination - [C306933]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(existingFile); + await dataTable.waitForBody(); + + await dataTable.selectItem(existingFile, source); + await toolbar.clickMoreActionsCopy(); + await copyDialog.selectLocation('Personal Files'); + await copyDialog.selectDestination(destinationSearch); + await copyDialog.clickCopy(); + const msg = await page.getSnackBarMessage(); + expect(msg).toContain('Copied 1 item'); + expect(msg).toContain('Undo'); + + await copyDialog.waitForDialogToClose(); + await page.clickPersonalFilesAndWait(); + await dataTable.doubleClickOnRowByName(destinationSearch); + expect(await dataTable.isItemPresent(`${existingFile}.txt`)).toBe(true, `${existingFile}.txt not present in destination folder`); + expect(await dataTable.isItemPresent(`${existingFile}-1.txt`)).toBe(true, `${existingFile}-1.txt not present in destination folder`); + }); + + it('Copy a folder with a name that already exists on the destination - [C306934]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(existingFolder); + await dataTable.waitForBody(); + + await dataTable.selectItem(existingFolder, source); + await toolbar.clickMoreActionsCopy(); + await copyDialog.selectLocation('Personal Files'); + await copyDialog.selectDestination(destinationSearch); + await copyDialog.clickCopy(); + const msg = await page.getSnackBarMessage(); + expect(msg).toContain('Copied 1 item'); + expect(msg).toContain('Undo'); + + await copyDialog.waitForDialogToClose(); + await page.clickPersonalFilesAndWait(); + await dataTable.doubleClickOnRowByName(destinationSearch); + expect(await dataTable.isItemPresent(existingFolder)).toBe(true, `${existingFolder} not present in destination folder`); + await dataTable.doubleClickOnRowByName(existingFolder); + expect(await dataTable.isItemPresent(file2InFolder)).toBe(true, `${file2InFolder} not present in destination folder`); + expect(await dataTable.isItemPresent(file3InFolder)).toBe(true, `${file3InFolder} not present in destination folder`); + }); + + it('Copy items into a library - [C306942]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor('file'); + await dataTable.waitForBody(); + + await dataTable.selectMultipleItems([file1, file2], source); + await toolbar.clickMoreActionsCopy(); + await copyDialog.selectLocation('File Libraries'); + await copyDialog.doubleClickOnRow(siteName); + await copyDialog.doubleClickOnRow('documentLibrary'); + await copyDialog.selectDestination(folderSiteSearch); + await copyDialog.clickCopy(); + const msg = await page.getSnackBarMessage(); + expect(msg).toContain('Copied 2 items'); + expect(msg).toContain('Undo'); + + await copyDialog.waitForDialogToClose(); + await page.goToMyLibraries(); + await dataTable.doubleClickOnRowByName(siteName); + await dataTable.doubleClickOnRowByName(folderSiteSearch); + + expect(await dataTable.isItemPresent(file1)).toBe(true, `${file1} not present in destination folder`); + expect(await dataTable.isItemPresent(file2)).toBe(true, `${file2} not present in destination folder`); + }); + }); + }); diff --git a/e2e/suites/actions/download.test.ts b/e2e/suites/actions/download.test.ts index 8391e010e..02c694f31 100755 --- a/e2e/suites/actions/download.test.ts +++ b/e2e/suites/actions/download.test.ts @@ -105,7 +105,7 @@ describe('Download', () => { await apis.user.trashcan.emptyTrash(); done(); }); - + afterEach(async (done) => { await Utils.renameFile(archiveZip, `${Utils.random()}.zip`); done(); @@ -273,7 +273,7 @@ describe('Download', () => { await page.clickPersonalFilesAndWait(); await searchInput.clickSearchButton(); await searchInput.checkFilesAndFolders(); - await searchInput.searchForTextAndCloseSearchOptions('*Search*'); + await searchInput.searchFor('*Search*'); done(); }); diff --git a/e2e/suites/actions/edit-folder.test.ts b/e2e/suites/actions/edit-folder.test.ts index e66128c63..780c6ca66 100755 --- a/e2e/suites/actions/edit-folder.test.ts +++ b/e2e/suites/actions/edit-folder.test.ts @@ -39,7 +39,8 @@ describe('Edit folder', () => { const folderNameToEdit = `folder-${Utils.random()}`; const duplicateFolderName = `folder-${Utils.random()}`; - const folderNameEdited = `folder-${Utils.random()}`; + const folderNameEdited = `folder-renamed-${Utils.random()}`; + const folderNameEdited2 = `folder-search-renamed-${Utils.random()}`; const folderDescriptionEdited = 'description edited'; const sitePrivate = `site-private-${Utils.random()}`; @@ -54,6 +55,10 @@ describe('Edit folder', () => { const folderFavoriteToEdit = `folder-fav-${Utils.random()}`; let folderFavoriteToEditId; const folderFavoriteDuplicate = `folder-fav-${Utils.random()}`; let folderFavoriteDuplicateId; + const folderSearch = `folder-search-${Utils.random()}`; + const folderSearchToEdit = `folder-search-${Utils.random()}`; let folderSearchToEditId; + const folderSearchDuplicate = `folder-search-${Utils.random()}`; + const apis = { admin: new RepoClient(), user: new RepoClient(username, username) @@ -63,6 +68,7 @@ describe('Edit folder', () => { const page = new BrowsingPage(); const editDialog = new CreateOrEditFolderDialog(); const { dataTable, toolbar } = page; + const { searchInput } = page.header; beforeAll(async (done) => { await apis.admin.people.createUser({ username }); @@ -86,6 +92,10 @@ describe('Edit folder', () => { folderFavoriteToEditId = (await apis.user.nodes.createFolder(folderFavoriteToEdit)).entry.id; folderFavoriteDuplicateId = (await apis.user.nodes.createFolder(folderFavoriteDuplicate)).entry.id; + await apis.user.nodes.createFolder(folderSearch); + folderSearchToEditId = (await apis.user.nodes.createFolder(folderSearchToEdit)).entry.id; + await apis.user.nodes.createFolder(folderSearchDuplicate); + await apis.user.favorites.addFavoriteById('folder', folderFavoriteId); await apis.user.favorites.addFavoriteById('folder', folderFavoriteToEditId); await apis.user.favorites.addFavoriteById('folder', folderFavoriteDuplicateId); @@ -98,7 +108,7 @@ describe('Edit folder', () => { await Promise.all([ apis.admin.sites.deleteSite(sitePrivate), apis.user.sites.deleteSite(siteName), - apis.user.nodes.deleteNodesById([ parentId, folderFavoriteToEditId, folderFavoriteDuplicateId ]) + apis.user.nodes.deleteNodesById([ parentId, folderFavoriteToEditId, folderFavoriteDuplicateId, folderSearchToEditId ]) ]); done(); }); @@ -288,4 +298,51 @@ describe('Edit folder', () => { expect(await editDialog.isDialogOpen()).toBe(true, 'dialog is not present'); }); }); + + describe('on Search Results', () => { + beforeAll(async (done) => { + await apis.user.search.waitForNodes('folder-search', { expect: 3 }); + done(); + }); + + it('properties are modified when pressing OK - [C306947]', async () => { + await page.clickPersonalFiles(); + await searchInput.clickSearchButton(); + await searchInput.checkOnlyFolders(); + await searchInput.searchFor(folderSearchToEdit); + await dataTable.waitForBody(); + + await dataTable.selectItem(folderSearchToEdit); + await toolbar.openMoreMenu(); + await toolbar.menu.clickEditFolder(); + await editDialog.waitForDialogToOpen(); + await editDialog.enterDescription(folderDescriptionEdited); + await editDialog.enterName(folderNameEdited2); + await editDialog.clickUpdate(); + await editDialog.waitForDialogToClose(); + + await page.refresh(); + expect(await dataTable.isItemPresent(folderNameEdited2)).toBe(true, 'Folder not displayed'); + const desc = await apis.user.nodes.getNodeProperty(folderSearchToEditId, 'cm:description'); + expect(desc).toEqual(folderDescriptionEdited); + }); + + it('with duplicate folder name - [C306948]', async () => { + await page.clickPersonalFiles(); + await searchInput.clickSearchButton(); + await searchInput.checkOnlyFolders(); + await searchInput.searchFor(folderSearch); + await dataTable.waitForBody(); + + await dataTable.selectItem(folderSearch); + await toolbar.openMoreMenu(); + await toolbar.menu.clickEditFolder(); + await editDialog.waitForDialogToOpen(); + await editDialog.enterName(folderSearchDuplicate); + await editDialog.clickUpdate(); + + expect(await page.getSnackBarMessage()).toEqual(`There's already a folder with this name. Try a different name.`); + expect(await editDialog.isDialogOpen()).toBe(true, 'dialog is not present'); + }); + }); }); diff --git a/e2e/suites/actions/edit-offline.test.ts b/e2e/suites/actions/edit-offline.test.ts index 96e5ecb91..30ee08b68 100755 --- a/e2e/suites/actions/edit-offline.test.ts +++ b/e2e/suites/actions/edit-offline.test.ts @@ -35,10 +35,15 @@ describe('Edit offline', () => { const fileLocked = `file-locked-${Utils.random()}.docx`; let fileLockedId; const fileLocked2 = `file-locked2-${Utils.random()}.docx`; let fileLocked2Id; + const fileSearch1 = `file-search-1-${Utils.random()}.docx`; let fileSearch1Id; + const fileSearchLocked = `file-search-locked-${Utils.random()}.docx`; let fileSearchLockedId; + const fileSearchLocked2 = `file-search-locked2-${Utils.random()}.docx`; let fileSearchLocked2Id; + const parentPF = `parentPersonal-${Utils.random()}`; let parentPFId; const parentSF = `parentShared-${Utils.random()}`; let parentSFId; const parentRF = `parentRecent-${Utils.random()}`; let parentRFId; const parentFav = `parentFav-${Utils.random()}`; let parentFavId; + const parentSearch = `parentSearch-${Utils.random()}`; let parentSearchId; const apis = { admin: new RepoClient(), @@ -48,6 +53,7 @@ describe('Edit offline', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable, toolbar } = page; + const { searchInput } = page.header; beforeAll(async (done) => { await apis.admin.people.createUser({ username }); @@ -56,6 +62,7 @@ describe('Edit offline', () => { parentSFId = (await apis.user.nodes.createFolder(parentSF)).entry.id; parentRFId = (await apis.user.nodes.createFolder(parentRF)).entry.id; parentFavId = (await apis.user.nodes.createFolder(parentFav)).entry.id; + parentSearchId = (await apis.user.nodes.createFolder(parentSearch)).entry.id; done(); }); @@ -65,6 +72,7 @@ describe('Edit offline', () => { await apis.user.nodes.deleteNodeById(parentSFId); await apis.user.nodes.deleteNodeById(parentRFId); await apis.user.nodes.deleteNodeById(parentFavId); + await apis.user.nodes.deleteNodeById(parentSearchId); done(); }); @@ -143,7 +151,7 @@ describe('Edit offline', () => { done(); }); - xit('File is locked and downloaded when clicking Edit Offline - []', async () => { + xit('File is locked and downloaded when clicking Edit Offline - [C306950]', async () => { await dataTable.selectItem(file1, parentSF); await toolbar.clickMoreActionsEditOffline(); @@ -151,13 +159,13 @@ describe('Edit offline', () => { expect(await apis.user.nodes.isFileLockedWrite(file1Id)).toBe(true, `${file1} is not locked`); }); - xit('Lock information is displayed - []', async () => { + xit('Lock information is displayed - [C306951]', async () => { expect(await dataTable.isItemPresent(fileLocked2, parentSF)).toBe(true, `${fileLocked2} is not displayed`); expect(await dataTable.hasLockIcon(fileLocked2, parentSF)).toBe(true, `${fileLocked2} does not have a lock icon`); expect(await dataTable.getLockOwner(fileLocked2, parentSF)).toContain(username, `${fileLocked2} does not have correct lock owner info`); }); - xit('Cancel Editing unlocks the file - []', async () => { + xit('Cancel Editing unlocks the file - [C306952]', async () => { await dataTable.selectItem(fileLocked); await toolbar.clickMoreActionsCancelEditing(); await dataTable.clearSelection(); @@ -243,7 +251,7 @@ describe('Edit offline', () => { done(); }); - xit('File is locked and downloaded when clicking Edit Offline - []', async () => { + xit('File is locked and downloaded when clicking Edit Offline - [C306956]', async () => { await dataTable.selectItem(file1); await toolbar.clickMoreActionsEditOffline(); @@ -251,13 +259,13 @@ describe('Edit offline', () => { expect(await apis.user.nodes.isFileLockedWrite(file1Id)).toBe(true, `${file1} is not locked`); }); - xit('Lock information is displayed - []', async () => { + xit('Lock information is displayed - [C306957]', async () => { expect(await dataTable.isItemPresent(fileLocked2)).toBe(true, `${fileLocked2} is not displayed`); expect(await dataTable.hasLockIcon(fileLocked2)).toBe(true, `${fileLocked2} does not have a lock icon`); expect(await dataTable.getLockOwner(fileLocked2)).toContain(username, `${fileLocked2} does not have correct lock owner info`); }); - xit('Cancel Editing unlocks the file - []', async () => { + xit('Cancel Editing unlocks the file - [C306958]', async () => { await dataTable.selectItem(fileLocked); await toolbar.clickMoreActionsCancelEditing(); await dataTable.clearSelection(); @@ -267,4 +275,58 @@ describe('Edit offline', () => { }); }); + describe('on Search Results', () => { + beforeAll(async (done) => { + fileSearch1Id = (await apis.user.upload.uploadFileWithRename(FILES.docxFile, parentSearchId, fileSearch1)).entry.id; + fileSearchLockedId = (await apis.user.upload.uploadFileWithRename(FILES.docxFile, parentSearchId, fileSearchLocked)).entry.id; + fileSearchLocked2Id = (await apis.user.upload.uploadFileWithRename(FILES.docxFile, parentSearchId, fileSearchLocked2)).entry.id; + + await apis.user.nodes.lockFile(fileSearchLockedId); + await apis.user.nodes.lockFile(fileSearchLocked2Id); + + await apis.user.search.waitForNodes('file-search', { expect: 3 }); + + await loginPage.loginWith(username); + done(); + }); + + beforeEach(async (done) => { + await page.clickPersonalFilesAndWait(); + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor('file-search'); + await dataTable.waitForBody(); + done(); + }); + + afterEach(async (done) => { + await Utils.pressEscape(); + done(); + }); + + it('File is locked and downloaded when clicking Edit Offline - [C306953]', async () => { + await dataTable.selectItem(fileSearch1); + await toolbar.clickMoreActionsEditOffline(); + + expect(await Utils.fileExistsOnOS(fileSearch1)).toBe(true, 'File not found in download location'); + expect(await apis.user.nodes.isFileLockedWrite(fileSearch1Id)).toBe(true, `${fileSearch1} is not locked`); + }); + + // TODO: enable when ACA-2314 is fixed + xit('Lock information is displayed - [C306954]', async () => { + expect(await dataTable.isItemPresent(fileSearchLocked2, parentSearch)).toBe(true, `${fileSearchLocked2} is not displayed`); + expect(await dataTable.hasLockIcon(fileSearchLocked2, parentSearch)).toBe(true, `${fileSearchLocked2} does not have a lock icon`); + expect(await dataTable.getLockOwner(fileSearchLocked2, parentSearch)).toContain(username, `${fileSearchLocked2} does not have correct lock owner info`); + }); + + it('Cancel Editing unlocks the file - [C306955]', async () => { + await dataTable.selectItem(fileSearchLocked); + await toolbar.clickMoreActionsCancelEditing(); + await dataTable.clearSelection(); + + expect(await apis.user.nodes.isFileLockedWrite(fileSearchLockedId)).toBe(false, `${fileSearchLocked} is still locked`); + // TODO: enable when ACA-2314 is fixed + // expect(await dataTable.hasLockIcon(fileSearchLocked, parentSearch)).toBe(false, `${fileSearchLocked} has a lock icon`); + }); + }); }); diff --git a/e2e/suites/actions/library-actions.test.ts b/e2e/suites/actions/library-actions.test.ts index 1bc988c4c..5abc635c7 100755 --- a/e2e/suites/actions/library-actions.test.ts +++ b/e2e/suites/actions/library-actions.test.ts @@ -36,10 +36,26 @@ describe('Library actions', () => { const sitePublic2Admin = `admin-public2-${Utils.random()}`; const sitePublic3Admin = `admin-public3-${Utils.random()}`; const sitePublic4Admin = `admin-public4-${Utils.random()}`; + const sitePublic5Admin = `admin-public5-${Utils.random()}`; + const sitePublic6Admin = `admin-public6-${Utils.random()}`; + const sitePublic7Admin = `admin-public7-${Utils.random()}`; + const sitePublic8Admin = `admin-public8-${Utils.random()}`; + + const sitePublicUser = `user-public1-${Utils.random()}`; + const siteForDelete1 = `user-public2-${Utils.random()}`; + const siteForDelete2 = `user-public3-${Utils.random()}`; + const siteModerated1Admin = `admin-moderated1-${Utils.random()}`; const siteModerated2Admin = `admin-moderated2-${Utils.random()}`; - const sitePublicUser = `user-public-${Utils.random()}`; + const siteSearchModerated1Admin = `site-moderated-search-1-${Utils.random()}`; + const siteSearchModerated2Admin = `site-moderated-search-2-${Utils.random()}`; + + const siteSearchPublic1Admin = `site-public-search-1-${Utils.random()}`; + const siteSearchPublic2Admin = `site-public-search-2-${Utils.random()}`; + const siteSearchPublic3Admin = `site-public-search-3-${Utils.random()}`; + const siteSearchPublic4Admin = `site-public-search-4-${Utils.random()}`; + const siteSearchForDelete = `site-public-search-5-${Utils.random()}`; const apis = { admin: new RepoClient(), @@ -49,30 +65,23 @@ describe('Library actions', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable, toolbar } = page; + const { searchInput } = page.header; const confirmDialog = new ConfirmDialog(); beforeAll(async (done) => { await apis.admin.people.createUser({ username }); - await apis.admin.sites.createSite(sitePublic1Admin); - await apis.admin.sites.createSite(sitePublic2Admin); - await apis.admin.sites.createSite(sitePublic3Admin); - await apis.admin.sites.createSite(sitePublic4Admin); - await apis.admin.sites.createSite(siteModerated1Admin, SITE_VISIBILITY.MODERATED); - await apis.admin.sites.createSite(siteModerated2Admin, SITE_VISIBILITY.MODERATED); - await apis.user.sites.createSite(sitePublicUser); + await apis.admin.sites.createSite(siteSearchPublic1Admin); + await apis.admin.sites.createSite(siteSearchPublic2Admin); + await apis.admin.sites.createSite(siteSearchPublic3Admin); + await apis.admin.sites.createSite(siteSearchPublic4Admin); + await apis.admin.sites.createSite(siteSearchModerated1Admin, SITE_VISIBILITY.MODERATED); + await apis.admin.sites.createSite(siteSearchModerated2Admin, SITE_VISIBILITY.MODERATED); + await apis.user.sites.createSite(siteSearchForDelete); - await apis.admin.sites.addSiteMember(sitePublic2Admin, username, SITE_ROLES.SITE_COLLABORATOR.ROLE); - await apis.admin.sites.addSiteMember(sitePublic3Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); - await apis.admin.sites.addSiteMember(sitePublic4Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); - - await apis.user.favorites.addFavoriteById('site', sitePublic1Admin); - await apis.user.favorites.addFavoriteById('site', sitePublic3Admin); - await apis.user.favorites.addFavoriteById('site', siteModerated1Admin); - await apis.user.favorites.addFavoriteById('site', siteModerated2Admin); - - await apis.user.sites.requestToJoin(siteModerated2Admin); + await apis.user.queries.waitForSites('site-public-search', { expect: 5 }); + await apis.user.queries.waitForSites('site-moderated-search', { expect: 2 }); await loginPage.loginWith(username); done(); @@ -80,104 +89,343 @@ describe('Library actions', () => { afterEach(async (done) => { await Utils.pressEscape(); - await dataTable.clearSelection(); + await page.header.expandSideNav(); + await page.clickPersonalFiles(); done(); }); afterAll(async (done) => { await apis.admin.sites.deleteSite(sitePublic1Admin); + await apis.admin.sites.deleteSite(siteSearchPublic1Admin); await apis.admin.sites.deleteSite(sitePublic2Admin); await apis.admin.sites.deleteSite(sitePublic3Admin); await apis.admin.sites.deleteSite(sitePublic4Admin); + await apis.admin.sites.deleteSite(sitePublic5Admin); + await apis.admin.sites.deleteSite(sitePublic6Admin); + await apis.admin.sites.deleteSite(sitePublic7Admin); + await apis.admin.sites.deleteSite(sitePublic8Admin); + + await apis.admin.sites.deleteSite(siteSearchPublic2Admin); + await apis.admin.sites.deleteSite(siteSearchPublic3Admin); + await apis.admin.sites.deleteSite(siteSearchPublic4Admin); await apis.admin.sites.deleteSite(siteModerated1Admin); await apis.admin.sites.deleteSite(siteModerated2Admin); + await apis.admin.sites.deleteSite(siteSearchModerated1Admin); + await apis.admin.sites.deleteSite(siteSearchModerated2Admin); await apis.user.sites.deleteSite(sitePublicUser); + await apis.admin.trashcan.emptyTrash(); done(); }); - it('Join a public library - Favorite Libraries - [C290105]', async () => { - await page.goToFavoriteLibrariesAndWait(); - await dataTable.selectItem(sitePublic1Admin); - await toolbar.clickJoin(); + describe('Join a public library', () => { + + beforeAll(async done => { + await apis.admin.sites.createSite(sitePublic1Admin); + await apis.user.favorites.addFavoriteById('site', sitePublic1Admin); + done(); + }); + + it('from Favorite Libraries - [C290105]', async () => { + await page.goToFavoriteLibrariesAndWait(); + await dataTable.selectItem(sitePublic1Admin); + await toolbar.clickJoin(); + + expect(await dataTable.getLibraryRole(sitePublic1Admin)).toEqual('Consumer'); + }); + + it('from Search Results - [C306959]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkLibraries(); + await searchInput.searchFor(siteSearchPublic1Admin); + await dataTable.waitForBody(); + + await dataTable.selectItem(siteSearchPublic1Admin); + await toolbar.clickJoin(); + + expect(await dataTable.getLibraryRole(siteSearchPublic1Admin)).toEqual('Consumer'); + }); - expect(await dataTable.getLibraryRole(sitePublic1Admin)).toEqual('Consumer'); }); - it('Join a moderated library - Favorite Libraries - [C290109]', async () => { - await page.goToFavoriteLibrariesAndWait(); - await dataTable.selectItem(siteModerated1Admin); - await toolbar.clickJoin(); + describe('Join a moderated library', () => { + + beforeAll(async done => { + await apis.admin.sites.createSite(siteModerated1Admin, SITE_VISIBILITY.MODERATED); + await apis.user.favorites.addFavoriteById('site', siteModerated1Admin); + await apis.user.queries.waitForSites(siteSearchModerated1Admin, { expect: 1 }); + done(); + }); + + it('from Favorite Libraries - [C290109]', async () => { + await page.goToFavoriteLibrariesAndWait(); + await dataTable.selectItem(siteModerated1Admin); + await toolbar.clickJoin(); + + expect(await dataTable.getLibraryRole(siteModerated1Admin)).toEqual(''); + const hasJoinRequest = await apis.user.sites.hasMembershipRequest(siteModerated1Admin); + expect(hasJoinRequest).toBe(true, `Join request does not exist on ${siteModerated1Admin}`); + }); + + it('from Search Results - [C306960]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkLibraries(); + await searchInput.searchFor(siteSearchModerated1Admin); + await dataTable.waitForBody(); + + await dataTable.selectItem(siteSearchModerated1Admin); + await toolbar.clickJoin(); + + expect(await dataTable.getLibraryRole(siteSearchModerated1Admin)).toEqual(''); + const hasJoinRequest = await apis.user.sites.hasMembershipRequest(siteSearchModerated1Admin); + expect(hasJoinRequest).toBe(true, `Join request does not exist on ${siteSearchModerated1Admin}`); + }); - expect(await dataTable.getLibraryRole(siteModerated1Admin)).toEqual(''); - const hasJoinRequest = await apis.user.sites.hasMembershipRequest(siteModerated1Admin); - expect(hasJoinRequest).toBe(true, `Join request does not exist on ${siteModerated1Admin}`); }); - it('Leave a library - My Libraries - [C290106]', async () => { - await page.goToMyLibrariesAndWait(); - await dataTable.selectItem(sitePublic2Admin); - await toolbar.clickLeave(); - await page.waitForDialog(); - await confirmDialog.clickOk(); + describe('Leave a library', () => { - expect(await page.getSnackBarMessage()).toEqual(`You have left the library`); - expect(await dataTable.isItemPresent(sitePublic2Admin)).toBe(false, `${sitePublic2Admin} is displayed`); + beforeAll(async done => { + await apis.admin.sites.createSite(sitePublic2Admin); + await apis.admin.sites.createSite(sitePublic3Admin); + await apis.admin.sites.createSite(sitePublic4Admin); + await apis.admin.sites.createSite(sitePublic5Admin); + await apis.user.sites.createSite(sitePublicUser); + await apis.user.favorites.addFavoriteById('site', sitePublic3Admin); + await apis.admin.sites.addSiteMember(sitePublic2Admin, username, SITE_ROLES.SITE_COLLABORATOR.ROLE); + await apis.admin.sites.addSiteMember(sitePublic3Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); + await apis.admin.sites.addSiteMember(siteSearchPublic2Admin, username, SITE_ROLES.SITE_CONTRIBUTOR.ROLE); + await apis.admin.sites.addSiteMember(sitePublic4Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); + await apis.admin.sites.addSiteMember(sitePublic5Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); + await apis.user.queries.waitForSites(siteSearchPublic2Admin, { expect: 1 }); + done(); + }); + + it('from My Libraries - [C290106]', async () => { + await page.goToMyLibrariesAndWait(); + await dataTable.selectItem(sitePublic2Admin); + await toolbar.clickLeave(); + await page.waitForDialog(); + await confirmDialog.clickOk(); + + expect(await page.getSnackBarMessage()).toEqual(`You have left the library`); + expect(await dataTable.isItemPresent(sitePublic2Admin)).toBe(false, `${sitePublic2Admin} is displayed`); + }); + + it('from Favorite Libraries - [C290110]', async () => { + await page.goToFavoriteLibrariesAndWait(); + await dataTable.selectItem(sitePublic3Admin); + await toolbar.clickLeave(); + await page.waitForDialog(); + await confirmDialog.clickOk(); + + expect(await page.getSnackBarMessage()).toEqual(`You have left the library`); + expect(await dataTable.isItemPresent(sitePublic3Admin)).toBe(true, `${sitePublic3Admin} is not displayed`); + }); + + it('from Search Results - [C306961]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkLibraries(); + await searchInput.searchFor(siteSearchPublic2Admin); + await dataTable.waitForBody(); + + await dataTable.selectItem(siteSearchPublic2Admin); + await toolbar.clickLeave(); + await page.waitForDialog(); + await confirmDialog.clickOk(); + + expect(await page.getSnackBarMessage()).toEqual(`You have left the library`); + expect(await dataTable.isItemPresent(siteSearchPublic2Admin)).toBe(true, `${siteSearchPublic2Admin} is not displayed`); + }); + + it('Confirmation dialog UI - [C290136]', async () => { + await page.goToMyLibrariesAndWait(); + await dataTable.selectItem(sitePublic4Admin); + await toolbar.clickLeave(); + await page.waitForDialog(); + + expect(await confirmDialog.isDialogOpen()).toBe(true, 'Confirm delete dialog not open'); + expect(await confirmDialog.getTitle()).toContain('Leave this library?'); + expect(await confirmDialog.getText()).toContain('Leaving will remove your access.'); + expect(await confirmDialog.isOkEnabled()).toBe(true, 'OK button is not enabled'); + expect(await confirmDialog.isCancelEnabled()).toBe(true, 'Cancel button is not enabled'); + }); + + it('Cancel Leave library - [C290111]', async () => { + await page.goToMyLibrariesAndWait(); + await dataTable.selectItem(sitePublic5Admin); + await toolbar.clickLeave(); + await page.waitForDialog(); + + expect(await confirmDialog.isCancelEnabled()).toBe(true, 'Cancel button is not enabled'); + await confirmDialog.clickCancel(); + expect(await dataTable.isItemPresent(sitePublic5Admin)).toBe(true, `${sitePublic5Admin} was deleted`); + }); + + it('Leave a library - failure notification - [C290107]', async () => { + await page.goToMyLibrariesAndWait(); + await dataTable.selectItem(sitePublicUser); + await toolbar.clickLeave(); + await page.waitForDialog(); + await confirmDialog.clickOk(); + + expect(await page.getSnackBarMessage()).toEqual(`Cannot leave this library`); + }); }); - it('Leave a library - Favorite Libraries - [C290110]', async () => { - await page.goToFavoriteLibrariesAndWait(); - await dataTable.selectItem(sitePublic3Admin); - await toolbar.clickLeave(); - await page.waitForDialog(); - await confirmDialog.clickOk(); + describe('Cancel join', () => { + + beforeAll(async done => { + await apis.admin.sites.createSite(siteModerated2Admin, SITE_VISIBILITY.MODERATED); + await apis.user.favorites.addFavoriteById('site', siteModerated2Admin); + await apis.user.sites.requestToJoin(siteModerated2Admin); + await apis.user.sites.requestToJoin(siteSearchModerated2Admin); + await apis.user.queries.waitForSites(siteSearchModerated2Admin, { expect: 1 }); + done(); + }); + + it('from Favorite Libraries - [C290108]', async () => { + await page.goToFavoriteLibrariesAndWait(); + await dataTable.selectItem(siteModerated2Admin); + await toolbar.clickButton('Cancel join request'); + + expect(await page.getSnackBarMessage()).toEqual(`Canceled the request to join the library`); + + const hasJoinRequest = await apis.user.sites.hasMembershipRequest(siteModerated2Admin); + expect(hasJoinRequest).toBe(false, `Join request exists on ${siteModerated2Admin}`); + }); + + it('from Search Results - [C306962]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkLibraries(); + await searchInput.searchFor(siteSearchModerated2Admin); + await dataTable.waitForBody(); + + await dataTable.selectItem(siteSearchModerated2Admin); + await toolbar.clickButton('Cancel join request'); + + expect(await page.getSnackBarMessage()).toEqual(`Canceled the request to join the library`); + + const hasJoinRequest = await apis.user.sites.hasMembershipRequest(siteSearchModerated2Admin); + expect(hasJoinRequest).toBe(false, `Join request exists on ${siteSearchModerated2Admin}`); + }); - expect(await page.getSnackBarMessage()).toEqual(`You have left the library`); - expect(await dataTable.isItemPresent(sitePublic3Admin)).toBe(true, `${sitePublic3Admin} is not displayed`); }); - it('Confirmation dialog UI - [C290136]', async () => { - await page.goToMyLibrariesAndWait(); - await dataTable.selectItem(sitePublic4Admin); - await toolbar.clickLeave(); - await page.waitForDialog(); + describe('Mark library as favorite', () => { + + beforeAll(async done => { + await apis.admin.sites.createSite(sitePublic6Admin); + await apis.admin.sites.addSiteMember(sitePublic6Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); + await apis.user.queries.waitForSites(siteSearchPublic3Admin, { expect: 1 }); + done(); + }); + + it('from My Libraries - [C289974]', async () => { + await page.goToMyLibrariesAndWait(); + await dataTable.selectItem(sitePublic6Admin); + await toolbar.clickMoreActionsFavorite(); + + expect(await apis.user.favorites.isFavoriteWithRetry(sitePublic6Admin, { expect: true })).toBe(true, `${sitePublic6Admin} not favorite`); + }); + + it('from on Search Results - [C306963]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkLibraries(); + await searchInput.searchFor(siteSearchPublic3Admin); + await dataTable.waitForBody(); + + await dataTable.selectItem(siteSearchPublic3Admin); + await toolbar.clickMoreActionsFavorite(); + + expect(await apis.user.favorites.isFavoriteWithRetry(siteSearchPublic3Admin, { expect: true })).toBe(true, `${siteSearchPublic3Admin} not favorite`); + }); - expect(await confirmDialog.isDialogOpen()).toBe(true, 'Confirm delete dialog not open'); - expect(await confirmDialog.getTitle()).toContain('Leave this library?'); - expect(await confirmDialog.getText()).toContain('Leaving will remove your access.'); - expect(await confirmDialog.isOkEnabled()).toBe(true, 'OK button is not enabled'); - expect(await confirmDialog.isCancelEnabled()).toBe(true, 'Cancel button is not enabled'); }); - it('Cancel Leave library - [C290111]', async () => { - await page.goToMyLibrariesAndWait(); - await dataTable.selectItem(sitePublic4Admin); - await toolbar.clickLeave(); - await page.waitForDialog(); + describe('Remove library from favorites', () => { - expect(await confirmDialog.isCancelEnabled()).toBe(true, 'Cancel button is not enabled'); - await confirmDialog.clickCancel(); - expect(await dataTable.isItemPresent(sitePublic4Admin)).toBe(true, `${sitePublic4Admin} was deleted`); + beforeAll(async done => { + await apis.admin.sites.createSite(sitePublic7Admin); + await apis.admin.sites.createSite(sitePublic8Admin); + await apis.user.favorites.addFavoriteById('site', sitePublic7Admin); + await apis.user.favorites.addFavoriteById('site', sitePublic8Admin); + await apis.user.favorites.addFavoriteById('site', siteSearchPublic4Admin); + await apis.admin.sites.addSiteMember(sitePublic7Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); + await apis.admin.sites.addSiteMember(sitePublic8Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); + await apis.admin.sites.addSiteMember(siteSearchPublic4Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); + await apis.user.queries.waitForSites(siteSearchPublic4Admin, { expect: 1 }); + done(); + }); + + it('from My Libraries - [C289975]', async () => { + await page.goToMyLibrariesAndWait(); + await dataTable.selectItem(sitePublic7Admin); + await toolbar.clickMoreActionsRemoveFavorite(); + + expect(await apis.user.favorites.isFavoriteWithRetry(sitePublic7Admin, { expect: false })).toBe(false, `${sitePublic7Admin} still favorite`); + }); + + it('from Favorite Libraries - [C289976]', async () => { + await page.goToFavoriteLibrariesAndWait(); + await dataTable.selectItem(sitePublic8Admin); + await toolbar.clickMoreActionsRemoveFavorite(); + + expect(await dataTable.isItemPresent(sitePublic8Admin)).toBe(false, `${sitePublic8Admin} is displayed`); + expect(await apis.user.favorites.isFavoriteWithRetry(sitePublic8Admin, { expect: false })).toBe(false, `${sitePublic8Admin} still favorite`); + }); + + it('from Search Results - [C306964]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkLibraries(); + await searchInput.searchFor(siteSearchPublic4Admin); + await dataTable.waitForBody(); + + await dataTable.selectItem(siteSearchPublic4Admin); + await toolbar.clickMoreActionsRemoveFavorite(); + + expect(await apis.user.favorites.isFavoriteWithRetry(siteSearchPublic4Admin, { expect: false })).toBe(false, `${siteSearchPublic4Admin} still favorite`); + }); }); - it('Leave a library - failure notification - [C290107]', async () => { - await page.goToMyLibrariesAndWait(); - await dataTable.selectItem(sitePublicUser); - await toolbar.clickLeave(); - await page.waitForDialog(); - await confirmDialog.clickOk(); + describe('Delete a library', () => { - expect(await page.getSnackBarMessage()).toEqual(`Cannot leave this library`); - }); + beforeAll(async done => { + await apis.user.sites.createSite(siteForDelete1); + await apis.user.sites.createSite(siteForDelete2); + await apis.user.queries.waitForSites(siteSearchForDelete, { expect: 1 }); + done(); + }); - it('Cancel join - Favorite Libraries - [C290108]', async () => { - await page.goToFavoriteLibrariesAndWait(); - await dataTable.selectItem(siteModerated2Admin); - await toolbar.clickButton('Cancel join request'); + it('from My Libraries - [C289988]', async () => { + await page.goToMyLibrariesAndWait(); + await dataTable.selectItem(siteForDelete1); + await toolbar.clickMoreActionsDelete(); - expect(await page.getSnackBarMessage()).toEqual(`Canceled the request to join the library`); + expect(await page.getSnackBarMessage()).toEqual(`Library deleted`); + expect(await dataTable.isItemPresent(siteForDelete1)).toBe(false, `${siteForDelete1} still displayed`); + }); - const hasJoinRequest = await apis.user.sites.hasMembershipRequest(siteModerated2Admin); - expect(hasJoinRequest).toBe(false, `Join request exists on ${siteModerated2Admin}`); + it('from Favorite Libraries - [C289991]', async () => { + await page.goToFavoriteLibrariesAndWait(); + await dataTable.selectItem(siteForDelete2); + await toolbar.clickMoreActionsDelete(); + + expect(await page.getSnackBarMessage()).toEqual(`Library deleted`); + expect(await dataTable.isItemPresent(siteForDelete2)).toBe(false, `${siteForDelete2} still displayed`); + }); + + it('from Search Results - [C306965]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkLibraries(); + await searchInput.searchFor(siteSearchForDelete); + await dataTable.waitForBody(); + + await dataTable.selectItem(siteSearchForDelete); + await toolbar.clickMoreActionsDelete(); + + expect(await page.getSnackBarMessage()).toEqual(`Library deleted`); + expect(await dataTable.isItemPresent(siteSearchForDelete)).toBe(false, `${siteSearchForDelete} still displayed`); + }); }); }); diff --git a/e2e/suites/actions/mark-favorite.test.ts b/e2e/suites/actions/mark-favorite.test.ts index 9b517c4d9..01c4370f9 100644 --- a/e2e/suites/actions/mark-favorite.test.ts +++ b/e2e/suites/actions/mark-favorite.test.ts @@ -24,7 +24,7 @@ */ import { LoginPage, BrowsingPage } from '../../pages/pages'; -import { SITE_VISIBILITY, SITE_ROLES } from '../../configs'; +import { SITE_VISIBILITY } from '../../configs'; import { RepoClient } from '../../utilities/repo-client/repo-client'; import { Utils } from '../../utilities/utils'; @@ -47,6 +47,19 @@ describe('Mark items as favorites', () => { let fileNotFavUIId, fileFavUIId, fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id, folderId, parentId; + const fileSearchNotFav1 = `search-fileNotFav1-${Utils.random()}.txt`; + const fileSearchNotFav2 = `search-fileNotFav2-${Utils.random()}.txt`; + const fileSearchNotFav3 = `search-fileNotFav3-${Utils.random()}.txt`; + const fileSearchNotFav4 = `search-fileNotFav4-${Utils.random()}.txt`; + const fileSearchFav1 = `search-fileFav1-${Utils.random()}.txt`; + const fileSearchFav2 = `search-fileFav2-${Utils.random()}.txt`; + const fileSearchFav3 = `search-fileFav3-${Utils.random()}.txt`; + const fileSearchFav4 = `search-fileFav4-${Utils.random()}.txt`; + const folderSearch = `search-folder-${Utils.random()}`; + + let fileSearchNotFav1Id, fileSearchNotFav2Id, fileSearchNotFav3Id, fileSearchNotFav4Id; + let fileSearchFav1Id, fileSearchFav2Id, fileSearchFav3Id, fileSearchFav4Id, folderSearchId; + const apis = { admin: new RepoClient(), user: new RepoClient(username, username) @@ -55,6 +68,7 @@ describe('Mark items as favorites', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable, toolbar } = page; + const { searchInput } = page.header; beforeAll(async (done) => { await apis.admin.people.createUser({ username }); @@ -73,8 +87,19 @@ describe('Mark items as favorites', () => { fileFav4Id = (await apis.user.nodes.createFile(fileFav4, parentId)).entry.id; folderId = (await apis.user.nodes.createFolder(folder, parentId)).entry.id; + fileSearchNotFav1Id = (await apis.user.nodes.createFile(fileSearchNotFav1, parentId)).entry.id; + fileSearchNotFav2Id = (await apis.user.nodes.createFile(fileSearchNotFav2, parentId)).entry.id; + fileSearchNotFav3Id = (await apis.user.nodes.createFile(fileSearchNotFav3, parentId)).entry.id; + fileSearchNotFav4Id = (await apis.user.nodes.createFile(fileSearchNotFav4, parentId)).entry.id; + fileSearchFav1Id = (await apis.user.nodes.createFile(fileSearchFav1, parentId)).entry.id; + fileSearchFav2Id = (await apis.user.nodes.createFile(fileSearchFav2, parentId)).entry.id; + fileSearchFav3Id = (await apis.user.nodes.createFile(fileSearchFav3, parentId)).entry.id; + fileSearchFav4Id = (await apis.user.nodes.createFile(fileSearchFav4, parentId)).entry.id; + folderSearchId = (await apis.user.nodes.createFolder(folderSearch, parentId)).entry.id; + await apis.user.favorites.addFavoritesByIds('file', [ fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]); - await apis.user.favorites.waitForApi({ expect: 5 }); + await apis.user.favorites.addFavoritesByIds('file', [ fileSearchFav1Id, fileSearchFav2Id, fileSearchFav3Id, fileSearchFav4Id ]); + await apis.user.favorites.waitForApi({ expect: 9 }); await apis.user.shared.shareFilesByIds([ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]); await apis.user.shared.shareFilesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]); @@ -89,12 +114,17 @@ describe('Mark items as favorites', () => { done(); }); + afterEach(async (done) => { + await Utils.pressEscape(); + done(); + }); + describe('on Personal Files', () => { afterAll(async (done) => { await apis.user.favorites.addFavoritesByIds('file', [ fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]); await apis.user.favorites.addFavoriteById('folder', folderId); await apis.user.favorites.removeFavoritesByIds([ fileNotFavUIId , fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]); - await apis.user.favorites.waitForApi({ expect: 6 }); + await apis.user.favorites.waitForApi({ expect: 10 }); done(); }); @@ -176,7 +206,7 @@ describe('Mark items as favorites', () => { afterAll(async (done) => { await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]); await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]); - await apis.user.favorites.waitForApi({ expect: 6 }); + await apis.user.favorites.waitForApi({ expect: 10 }); done(); }); @@ -229,7 +259,7 @@ describe('Mark items as favorites', () => { afterAll(async (done) => { await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]); await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]); - await apis.user.favorites.waitForApi({ expect: 6 }); + await apis.user.favorites.waitForApi({ expect: 10 }); done(); }); @@ -282,7 +312,7 @@ describe('Mark items as favorites', () => { afterAll(async (done) => { await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]); await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]); - await apis.user.favorites.waitForApi({ expect: 6 }); + await apis.user.favorites.waitForApi({ expect: 10 }); done(); }); @@ -319,6 +349,73 @@ describe('Mark items as favorites', () => { }); }); + describe('on Search Results', () => { + beforeAll(async done => { + await apis.user.search.waitForNodes('search-f', { expect: 9 }); + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor('search-f'); + await dataTable.waitForBody(); + done(); + }); + + beforeEach(async (done) => { + await Utils.pressEscape(); + done(); + }); + + afterAll(async done => { + await page.header.expandSideNav(); + await page.clickPersonalFiles(); + done(); + }); + + it('favorite a file - [C306966]', async () => { + await dataTable.selectItem(fileSearchNotFav1); + await toolbar.clickMoreActionsFavorite(); + + expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchNotFav1Id, { expect: true })).toBe(true, `${fileSearchNotFav1} not marked as favorite`); + }); + + it('favorite a folder - [C306971]', async () => { + await dataTable.selectItem(folderSearch); + await toolbar.clickMoreActionsFavorite(); + + expect(await apis.user.favorites.isFavoriteWithRetry(folderSearchId, { expect: true })).toBe(true, `${folderSearch} not marked as favorite`); + }); + + it('unfavorite an item - [C306967]', async () => { + await dataTable.selectItem(fileSearchFav1); + await toolbar.clickMoreActionsRemoveFavorite(); + + expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchFav1Id, { expect: false })).toBe(false, `${fileSearchFav1} is marked as favorite`); + }); + + it('favorite multiple items - all unfavorite - [C306968]', async () => { + await dataTable.selectMultipleItems([ fileSearchNotFav2, fileSearchNotFav3 ]); + await toolbar.clickMoreActionsFavorite(); + + expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchNotFav2Id, { expect: true })).toBe(true, `${fileSearchNotFav2} not marked as favorite`); + expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchNotFav3Id, { expect: true })).toBe(true, `${fileSearchNotFav3} not marked as favorite`); + }); + + it('favorite multiple items - some favorite and some unfavorite - [C306970]', async () => { + await dataTable.selectMultipleItems([ fileSearchNotFav4, fileSearchFav2 ]); + await toolbar.clickMoreActionsFavorite(); + + expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchNotFav4Id, { expect: true })).toBe(true, `${fileSearchNotFav4} not marked as favorite`); + expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchFav2Id, { expect: true })).toBe(true, `${fileSearchFav2} not marked as favorite`); + }); + + it('unfavorite multiple items - [C306969]', async () => { + await dataTable.selectMultipleItems([ fileSearchFav3, fileSearchFav4 ]) + await toolbar.clickMoreActionsRemoveFavorite(); + + expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchFav3Id, { expect: false })).toBe(false, `${fileSearchFav3} marked as favorite`); + expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchFav4Id, { expect: false })).toBe(false, `${fileSearchFav4} marked as favorite`); + }); + }); + describe ('on File Libraries', () => { const siteName = `site-public-${Utils.random()}`; @@ -423,60 +520,4 @@ describe('Mark items as favorites', () => { expect(await apis.user.favorites.isFavoriteWithRetry(fileSiteFav4Id, { expect: true })).toBe(true, 'item not marked as favorite'); }); }); - - describe('on a library', () => { - const adminSite1 = `adminSite1-${Utils.random()}`; - const adminSite2 = `adminSite2-${Utils.random()}`; - const adminSite3 = `adminSite3-${Utils.random()}`; - - beforeAll(async (done) => { - await apis.admin.sites.createSite(adminSite1); - await apis.admin.sites.createSite(adminSite2); - await apis.admin.sites.createSite(adminSite3); - await apis.admin.sites.addSiteMember(adminSite1, username, SITE_ROLES.SITE_CONSUMER.ROLE); - await apis.admin.sites.addSiteMember(adminSite2, username, SITE_ROLES.SITE_CONSUMER.ROLE); - await apis.admin.sites.addSiteMember(adminSite3, username, SITE_ROLES.SITE_CONSUMER.ROLE); - - await apis.user.favorites.addFavoriteById('site', adminSite2); - await apis.user.favorites.addFavoriteById('site', adminSite3); - done(); - }); - - beforeEach(async (done) => { - await Utils.pressEscape(); - done(); - }); - - afterAll(async (done) => { - await apis.admin.sites.deleteSite(adminSite1); - await apis.admin.sites.deleteSite(adminSite2); - await apis.admin.sites.deleteSite(adminSite3); - done(); - }); - - it('Mark a library as favorite - [C289974]', async () => { - await page.goToMyLibrariesAndWait(); - await dataTable.selectItem(adminSite1); - await toolbar.clickMoreActionsFavorite(); - - expect(await apis.user.favorites.isFavoriteWithRetry(adminSite1, { expect: true })).toBe(true, `${adminSite1} not favorite`); - }); - - it('Remove a library from favorites - on My Libraries - [C289975]', async () => { - await page.goToMyLibrariesAndWait(); - await dataTable.selectItem(adminSite2); - await toolbar.clickMoreActionsRemoveFavorite(); - - expect(await apis.user.favorites.isFavoriteWithRetry(adminSite2, { expect: false })).toBe(false, `${adminSite2} still favorite`); - }); - - it('Remove a library from favorites - on Favorite Libraries - [C289976]', async () => { - await page.goToFavoriteLibrariesAndWait(); - await dataTable.selectItem(adminSite3); - await toolbar.clickMoreActionsRemoveFavorite(); - - expect(await dataTable.isItemPresent(adminSite3)).toBe(false, `${adminSite3} is displayed`); - expect(await apis.user.favorites.isFavoriteWithRetry(adminSite3, { expect: false })).toBe(false, `${adminSite3} still favorite`); - }); - }); }); diff --git a/e2e/suites/actions/share-file.test.ts b/e2e/suites/actions/share-file.test.ts index ddaafda7c..ab1db28eb 100755 --- a/e2e/suites/actions/share-file.test.ts +++ b/e2e/suites/actions/share-file.test.ts @@ -49,6 +49,7 @@ describe('Share a file', () => { const shareDialog = new ShareDialog(); const viewer = new Viewer(); const contextMenu = dataTable.menu; + const { searchInput } = page.header; beforeAll(async (done) => { await apis.admin.people.createUser({ username }); @@ -154,10 +155,6 @@ describe('Share a file', () => { const sharedId = await apis.user.nodes.getSharedId(file3Id); expect(await apis.user.nodes.isFileShared(file3Id)).toBe(true, `${file3} is not shared`); expect(url).toContain(sharedId); - - // TODO: disable check cause api is slow to update - // await page.clickSharedFiles(); - // expect(await dataTable.isItemPresent(file3)).toBe(true, `${file3} is not in the Shared files list`); }); it('Copy shared file URL - [C286330]', async () => { @@ -244,6 +241,7 @@ describe('Share a file', () => { it('Share a file from the context menu - [C286345]', async () => { await dataTable.rightClickOnItem(file9); + await contextMenu.waitForMenuToOpen(); await contextMenu.clickShare(); await shareDialog.waitForDialogToOpen(); @@ -252,10 +250,6 @@ describe('Share a file', () => { const sharedId = await apis.user.nodes.getSharedId(file9Id); expect(await apis.user.nodes.isFileShared(file9Id)).toBe(true, `${file9} is not shared`); expect(url).toContain(sharedId); - - // TODO: disable check cause api is slow to update - // await page.clickSharedFiles(); - // expect(await dataTable.isItemPresent(file9)).toBe(true, `${file9} is not in the Shared files list`); }); }); @@ -305,6 +299,7 @@ describe('Share a file', () => { afterEach(async (done) => { await Utils.pressEscape(); + await page.clickPersonalFilesAndWait(); done(); }); @@ -350,10 +345,6 @@ describe('Share a file', () => { const sharedId = await apis.user.nodes.getSharedId(file3Id); expect(await apis.user.nodes.isFileShared(file3Id)).toBe(true, `${file3} is not shared`); expect(url).toContain(sharedId); - - // TODO: disable check cause api is slow to update - // await page.clickSharedFiles(); - // expect(await dataTable.isItemPresent(file3)).toBe(true, `${file3} is not in the Shared files list`); }); it('Copy shared file URL - [C286642]', async () => { @@ -440,6 +431,7 @@ describe('Share a file', () => { it('Share a file from the context menu - [C286647]', async () => { await dataTable.rightClickOnItem(file9); + await contextMenu.waitForMenuToOpen(); await contextMenu.clickShare(); await shareDialog.waitForDialogToOpen(); @@ -448,10 +440,6 @@ describe('Share a file', () => { const sharedId = await apis.user.nodes.getSharedId(file9Id); expect(await apis.user.nodes.isFileShared(file9Id)).toBe(true, `${file9} is not shared`); expect(url).toContain(sharedId); - - // TODO: disable check cause api is slow to update - // await page.clickSharedFiles(); - // expect(await dataTable.isItemPresent(file9)).toBe(true, `${file9} is not in the Shared files list`); }); }); @@ -484,13 +472,13 @@ describe('Share a file', () => { }); beforeEach(async (done) => { - await page.refresh(); await page.clickRecentFilesAndWait(); done(); }); afterEach(async (done) => { await Utils.pressEscape(); + await page.clickPersonalFilesAndWait(); done(); }); @@ -544,10 +532,6 @@ describe('Share a file', () => { const sharedId = await apis.user.nodes.getSharedId(file3Id); expect(await apis.user.nodes.isFileShared(file3Id)).toBe(true, `${file3} is not shared`); expect(url).toContain(sharedId); - - // TODO: disable check cause api is slow to update - // await page.clickSharedFiles(); - // expect(await dataTable.isItemPresent(file3)).toBe(true, `${file3} is not in the Shared files list`); }); it('Copy shared file URL - [C286660]', async () => { @@ -634,6 +618,7 @@ describe('Share a file', () => { it('Share a file from the context menu - [C286665]', async () => { await dataTable.rightClickOnItem(file9); + await contextMenu.waitForMenuToOpen(); await contextMenu.clickShare(); await shareDialog.waitForDialogToOpen(); @@ -642,10 +627,6 @@ describe('Share a file', () => { const sharedId = await apis.user.nodes.getSharedId(file9Id); expect(await apis.user.nodes.isFileShared(file9Id)).toBe(true, `${file9} is not shared`); expect(url).toContain(sharedId); - - // TODO: disable check cause api is slow to update - // await page.clickSharedFiles(); - // expect(await dataTable.isItemPresent(file9)).toBe(true, `${file9} is not in the Shared files list`); }); }); @@ -680,13 +661,13 @@ describe('Share a file', () => { }); beforeEach(async (done) => { - await page.refresh(); await page.clickSharedFilesAndWait(); done(); }); afterEach(async (done) => { await Utils.pressEscape(); + await page.clickPersonalFilesAndWait(); done(); }); @@ -791,6 +772,7 @@ describe('Share a file', () => { it('Open Share dialog from context menu - [C286656]', async () => { await dataTable.rightClickOnItem(file7); + await contextMenu.waitForMenuToOpen(); await contextMenu.clickSharedLinkSettings(); await shareDialog.waitForDialogToOpen(); @@ -853,6 +835,7 @@ describe('Share a file', () => { afterEach(async (done) => { await Utils.pressEscape(); + await page.clickPersonalFilesAndWait(); done(); }); @@ -906,10 +889,6 @@ describe('Share a file', () => { const sharedId = await apis.user.nodes.getSharedId(file3Id); expect(await apis.user.nodes.isFileShared(file3Id)).toBe(true, `${file3} is not shared`); expect(url).toContain(sharedId); - - // TODO: disable check cause api is slow to update - // await page.clickSharedFiles(); - // expect(await dataTable.isItemPresent(file3)).toBe(true, `${file3} is not in the Shared files list`); }); it('Copy shared file URL - [C286669]', async () => { @@ -996,6 +975,7 @@ describe('Share a file', () => { it('Share a file from the context menu - [C286674]', async () => { await dataTable.rightClickOnItem(file9); + await contextMenu.waitForMenuToOpen(); await contextMenu.clickShare(); await shareDialog.waitForDialogToOpen(); @@ -1004,10 +984,124 @@ describe('Share a file', () => { const sharedId = await apis.user.nodes.getSharedId(file9Id); expect(await apis.user.nodes.isFileShared(file9Id)).toBe(true, `${file9} is not shared`); expect(url).toContain(sharedId); + }); + }); - // TODO: disable check cause api is slow to update - // await page.clickSharedFiles(); - // expect(await dataTable.isItemPresent(file9)).toBe(true, `${file9} is not in the Shared files list`); + describe('from Search Results', () => { + const file3 = `search-file3-${Utils.random()}.txt`; let file3Id; + const file5 = `search-file5-${Utils.random()}.txt`; let file5Id; + const file6 = `search-file6-${Utils.random()}.txt`; let file6Id; + const file7 = `search-file7-${Utils.random()}.txt`; let file7Id; + const file9 = `search-file9-${Utils.random()}.txt`; let file9Id; + + beforeAll(async (done) => { + file3Id = (await apis.user.nodes.createFile(file3, parentId)).entry.id; + file5Id = (await apis.user.nodes.createFile(file5, parentId)).entry.id; + file6Id = (await apis.user.nodes.createFile(file6, parentId)).entry.id; + file7Id = (await apis.user.nodes.createFile(file7, parentId)).entry.id; + file9Id = (await apis.user.nodes.createFile(file9, parentId)).entry.id; + await apis.user.shared.shareFileById(file6Id, expiryDate); + await apis.user.shared.shareFileById(file7Id, expiryDate); + await apis.user.shared.waitForApi({ expect: 2 }); + await apis.user.search.waitForNodes('search-f', { expect: 5 }); + done(); + }); + + beforeEach(async done => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor('search-f'); + await dataTable.waitForBody(); + done(); + }); + + afterEach(async (done) => { + await Utils.pressEscape(); + await page.clickPersonalFilesAndWait(); + done(); + }); + + afterAll(async (done) => { + await apis.user.nodes.deleteNodeById(file3Id); + await apis.user.nodes.deleteNodeById(file5Id); + await apis.user.nodes.deleteNodeById(file6Id); + await apis.user.nodes.deleteNodeById(file7Id); + await apis.user.nodes.deleteNodeById(file9Id); + await apis.user.shared.waitForApi({ expect: 0 }); + done(); + }); + + it('Share a file - [C306975]', async () => { + await dataTable.selectItem(file3); + await toolbar.clickShare(); + await shareDialog.waitForDialogToOpen(); + + const url = await shareDialog.getLinkUrl(); + await Utils.pressEscape(); + const sharedId = await apis.user.nodes.getSharedId(file3Id); + expect(await apis.user.nodes.isFileShared(file3Id)).toBe(true, `${file3} is not shared`); + expect(url).toContain(sharedId); + }); + + it('Share a file with expiration date - [C306977]', async () => { + await dataTable.selectItem(file5); + await toolbar.clickShare(); + await shareDialog.waitForDialogToOpen(); + + await shareDialog.clickExpirationToggle(); + expect(await shareDialog.isExpireToggleEnabled()).toBe(true, 'Expire toggle not checked'); + expect(await shareDialog.dateTimePicker.isCalendarOpen()).toBe(true, 'Calendar not opened'); + const date = await shareDialog.dateTimePicker.setDefaultDay(); + await shareDialog.dateTimePicker.waitForDateTimePickerToClose(); + + const setDate = (`${date}`).replace(',', ''); + const inputDate = await shareDialog.getExpireDate(); + + expect(new Date(inputDate)).toEqual(new Date(setDate)); + + const expireDateProperty = await apis.user.nodes.getSharedExpiryDate(file5Id); + + expect(Utils.formatDate(expireDateProperty)).toEqual(Utils.formatDate(inputDate)); + }); + + it('Expire date is displayed correctly - [C306978]', async () => { + await dataTable.selectItem(file6); + await toolbar.clickSharedLinkSettings(); + await shareDialog.waitForDialogToOpen(); + + const expireProperty = await apis.user.nodes.getSharedExpiryDate(file6Id); + expect(expireProperty).toEqual(expiryDate); + expect(await shareDialog.isExpireToggleEnabled()).toBe(true, 'Expiration is not checked'); + expect(Utils.formatDate(await shareDialog.getExpireDate())).toEqual(Utils.formatDate(expiryDate)); + }); + + it('Disable the share link expiration - [C306979]', async () => { + await dataTable.selectItem(file7); + await toolbar.clickSharedLinkSettings(); + await shareDialog.waitForDialogToOpen(); + + expect(await shareDialog.isExpireToggleEnabled()).toBe(true, 'Expiration is not checked'); + expect(await shareDialog.getExpireDate()).not.toBe('', 'Expire date input is empty'); + + await shareDialog.clickExpirationToggle(); + expect(await shareDialog.isExpireToggleEnabled()).toBe(false, 'Expiration is checked'); + expect(await shareDialog.getExpireDate()).toBe('', 'Expire date input is not empty'); + + await shareDialog.clickClose(); + expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe(undefined, `${file7} link still has expiration`); + }); + + it('Share a file from the context menu - [C306981]', async () => { + await dataTable.rightClickOnItem(file9); + await contextMenu.waitForMenuToOpen(); + await contextMenu.clickShare(); + await shareDialog.waitForDialogToOpen(); + + const url = await shareDialog.getLinkUrl(); + await Utils.pressEscape(); + const sharedId = await apis.user.nodes.getSharedId(file9Id); + expect(await apis.user.nodes.isFileShared(file9Id)).toBe(true, `${file9} is not shared`); + expect(url).toContain(sharedId); }); }); diff --git a/e2e/suites/actions/single-click.test.ts b/e2e/suites/actions/single-click.test.ts index e76b1a0df..328d7f967 100755 --- a/e2e/suites/actions/single-click.test.ts +++ b/e2e/suites/actions/single-click.test.ts @@ -49,6 +49,7 @@ describe('Single click on item name', () => { const page = new BrowsingPage(); const { dataTable, breadcrumb } = page; const viewer = new Viewer(); + const { searchInput } = page.header; beforeAll(async (done) => { await apis.admin.people.createUser({ username }); @@ -198,4 +199,43 @@ describe('Single click on item name', () => { }); }); + describe('on Search Results', () => { + beforeEach(async done => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + done(); + }); + + afterEach(async (done) => { + await Utils.pressEscape(); + await page.clickPersonalFilesAndWait(); + done(); + }); + + it('Hyperlink appears when mouse over a file - [C306988]', async () => { + await searchInput.searchFor(file1); + await dataTable.waitForBody(); + + expect(await dataTable.hasLinkOnSearchResultName(file1)).toBe(true, 'Link on name is missing'); + }); + + it('File preview opens when clicking the hyperlink - [C306989]', async () => { + await searchInput.searchFor(file1); + await dataTable.waitForBody(); + await dataTable.clickSearchResultNameLink(file1); + + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + + await Utils.pressEscape(); + }); + + it('Navigate inside the folder when clicking the hyperlink - [C306990]', async () => { + await searchInput.searchFor(folder1); + await dataTable.waitForBody(); + await dataTable.clickSearchResultNameLink(folder1); + + expect(await breadcrumb.getCurrentItemName()).toBe(folder1); + }); + }); + }); diff --git a/e2e/suites/actions/special-permissions-available-actions.test.ts b/e2e/suites/actions/special-permissions-available-actions.test.ts index 06a76ed68..5320290d4 100755 --- a/e2e/suites/actions/special-permissions-available-actions.test.ts +++ b/e2e/suites/actions/special-permissions-available-actions.test.ts @@ -217,7 +217,7 @@ describe('Special permissions available actions : ', () => { it('on Search Results - [C291823]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFiles(); - await searchInput.searchForTextAndCloseSearchOptions('my-file'); + await searchInput.searchFor('my-file'); await dataTable.selectMultipleItems([file1, file2]); expect(await toolbar.isViewPresent()).toBe(false, `View is displayed for selected files`); @@ -335,7 +335,7 @@ describe('Special permissions available actions : ', () => { it('on Search Results - [C291818]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFiles(); - await searchInput.searchForTextAndCloseSearchOptions(file1); + await searchInput.searchFor(file1); await dataTable.selectItem(file1); expect(await toolbar.isViewPresent()).toBe(true, `View is not displayed for ${file1}`); @@ -428,7 +428,7 @@ describe('Special permissions available actions : ', () => { it('on Search Results - [C291819]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFolders(); - await searchInput.searchForTextAndCloseSearchOptions(folder1); + await searchInput.searchFor(folder1); await dataTable.selectItem(folder1); expect(await toolbar.isViewPresent()).toBe(false, `View is displayed for ${folder1}`); @@ -541,7 +541,7 @@ describe('Special permissions available actions : ', () => { it('on Search Results - [C291824]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFiles(); - await searchInput.searchForTextAndCloseSearchOptions('my-file'); + await searchInput.searchFor('my-file'); await dataTable.selectMultipleItems([file1, file2]); expect(await toolbar.isViewPresent()).toBe(false, 'View is displayed'); @@ -630,7 +630,7 @@ describe('Special permissions available actions : ', () => { it('on Search Results - [C291825]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFolders(); - await searchInput.searchForTextAndCloseSearchOptions('my-folder'); + await searchInput.searchFor('my-folder'); await dataTable.selectMultipleItems([folder1, folder2]); expect(await toolbar.isViewPresent()).toBe(false, 'View is displayed'); @@ -719,7 +719,7 @@ describe('Special permissions available actions : ', () => { it('on Search Results - [C291826]', async () => { await searchInput.clickSearchButton(); await searchInput.checkFilesAndFolders(); - await searchInput.searchForTextAndCloseSearchOptions('my-f'); + await searchInput.searchFor('my-f'); await dataTable.selectMultipleItems([file1, folder1]); expect(await toolbar.isViewPresent()).toBe(false, 'View is displayed'); @@ -822,7 +822,7 @@ describe('Special permissions available actions : ', () => { it('on Search Results - [C291829]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFiles(); - await searchInput.searchForTextAndCloseSearchOptions(file1); + await searchInput.searchFor(file1); await dataTable.rightClickOnItem(file1); expect(await contextMenu.isEditOfflinePresent()).toBe(false, `Edit offline is displayed for ${file1}`); @@ -898,7 +898,7 @@ describe('Special permissions available actions : ', () => { it('on Search Results - [C291830]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFolders(); - await searchInput.searchForTextAndCloseSearchOptions(folder1); + await searchInput.searchFor(folder1); await dataTable.rightClickOnItem(folder1); expect(await contextMenu.isDownloadPresent()).toBe(true, `Download is not displayed for ${folder1}`); @@ -916,7 +916,7 @@ describe('Special permissions available actions : ', () => { }); }); - describe('context menu actions are correct for multiple selection of files', () => { + describe('context menu actions are correct for multiple selection of files', () => { beforeEach(async (done) => { await Utils.pressEscape(); await dataTable.clearSelection(); @@ -990,7 +990,7 @@ describe('Special permissions available actions : ', () => { it('on Search Results - [C291834]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFiles(); - await searchInput.searchForTextAndCloseSearchOptions('my-file'); + await searchInput.searchFor('my-file'); await dataTable.selectMultipleItems([file1, file2]); await dataTable.rightClickOnMultipleSelection(); @@ -1066,7 +1066,7 @@ describe('Special permissions available actions : ', () => { it('on Search Results - [C291835]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFolders(); - await searchInput.searchForTextAndCloseSearchOptions('my-folder'); + await searchInput.searchFor('my-folder'); await dataTable.selectMultipleItems([folder1, folder2]); await dataTable.rightClickOnMultipleSelection(); @@ -1141,7 +1141,7 @@ describe('Special permissions available actions : ', () => { it('on Search Results - [C291836]', async () => { await searchInput.clickSearchButton(); await searchInput.checkFilesAndFolders(); - await searchInput.searchForTextAndCloseSearchOptions('my-f'); + await searchInput.searchFor('my-f'); await dataTable.selectMultipleItems([file1, folder1]); await dataTable.rightClickOnMultipleSelection(); @@ -1162,7 +1162,6 @@ describe('Special permissions available actions : ', () => { describe('toolbar actions appear correctly in the viewer', () => { beforeEach(async (done) => { await Utils.pressEscape(); - await dataTable.clearSelection(); await page.clickPersonalFiles(); done(); }); @@ -1254,6 +1253,36 @@ describe('Special permissions available actions : ', () => { await toolbar.closeMoreMenu(); }); + + it('file from Search Results - [C306991]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkOnlyFiles(); + await searchInput.searchFor(docxFile); + await dataTable.waitForBody(); + await dataTable.doubleClickOnRowByName(docxFile); + await viewer.waitForViewerToOpen(); + + expect(await viewerToolbar.isViewPresent()).toBe(false, `View is displayed`); + expect(await viewerToolbar.isDownloadPresent()).toBe(true, `Download is not displayed`); + expect(await viewerToolbar.isPrintPresent()).toBe(true, `Print is not displayed`); + expect(await viewerToolbar.isFullScreenPresent()).toBe(true, `Full screen is not displayed`); + expect(await viewerToolbar.isSharedLinkSettingsPresent()).toBe(true, 'Shared link settings is not displayed'); + expect(await viewerToolbar.isViewDetailsPresent()).toBe(true, `View details is not displayed`); + + await viewerToolbar.openMoreMenu(); + + expect(await viewerToolbar.menu.isEditOfflinePresent()).toBe(false, `Edit offline is displayed`); + expect(await viewerToolbar.menu.isCancelEditingPresent()).toBe(false, `Cancel editing is displayed`); + expect(await viewerToolbar.menu.isToggleRemoveFavoritePresent()).toBe(true, `Remove favorite is not displayed`); + expect(await viewerToolbar.menu.isSharePresent()).toBe(false, `Share is displayed in More actions`); + expect(await viewerToolbar.menu.isCopyPresent()).toBe(true, `Copy is not displayed`); + expect(await viewerToolbar.menu.isMovePresent()).toBe(false, `Move is displayed`); + expect(await viewerToolbar.menu.isDeletePresent()).toBe(false, `Delete is displayed`); + expect(await viewerToolbar.menu.isManageVersionsPresent()).toBe(true, `Manage versions is not displayed`); + expect(await viewerToolbar.menu.isUploadNewVersionPresent()).toBe(false, `Upload new version is displayed`); + + await toolbar.closeMoreMenu(); + }); }); }); @@ -1345,7 +1374,7 @@ describe('Special permissions available actions : ', () => { it('on Search Results - [C297653]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFiles(); - await searchInput.searchForTextAndCloseSearchOptions(file1); + await searchInput.searchFor(file1); await dataTable.selectItem(file1); expect(await toolbar.isViewPresent()).toBe(true, `View is not displayed for ${file1}`); @@ -1463,6 +1492,36 @@ describe('Special permissions available actions : ', () => { await viewerToolbar.closeMoreMenu(); }); + + it('file opened from Search Results - [C306992]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkOnlyFiles(); + await searchInput.searchFor(docxFile); + await dataTable.waitForBody(); + await dataTable.doubleClickOnRowByName(docxFile); + await viewer.waitForViewerToOpen(); + + expect(await viewerToolbar.isViewPresent()).toBe(false, `View is displayed`); + expect(await viewerToolbar.isDownloadPresent()).toBe(true, `Download is not displayed`); + expect(await viewerToolbar.isPrintPresent()).toBe(true, `Print is not displayed`); + expect(await viewerToolbar.isFullScreenPresent()).toBe(true, `Full screen is not displayed`); + expect(await viewerToolbar.isSharedLinkSettingsPresent()).toBe(true, 'Shared link settings is not displayed'); + expect(await viewerToolbar.isViewDetailsPresent()).toBe(true, `View details is not displayed`); + + await viewerToolbar.openMoreMenu(); + + expect(await viewerToolbar.menu.isEditOfflinePresent()).toBe(true, `Edit offline is not displayed`); + expect(await viewerToolbar.menu.isCancelEditingPresent()).toBe(false, `Cancel editing is displayed`); + expect(await viewerToolbar.menu.isToggleRemoveFavoritePresent()).toBe(true, `Remove favorite is not displayed`); + expect(await viewerToolbar.menu.isSharePresent()).toBe(false, `Share is displayed in More actions`); + expect(await viewerToolbar.menu.isCopyPresent()).toBe(true, `Copy is not displayed`); + expect(await viewerToolbar.menu.isMovePresent()).toBe(false, `Move is displayed`); + expect(await viewerToolbar.menu.isDeletePresent()).toBe(false, `Delete is displayed`); + expect(await viewerToolbar.menu.isManageVersionsPresent()).toBe(true, `Manage versions is not displayed`); + expect(await viewerToolbar.menu.isUploadNewVersionPresent()).toBe(true, `Upload new version is not displayed`); + + await viewerToolbar.closeMoreMenu(); + }); }); }); @@ -1554,7 +1613,7 @@ describe('Special permissions available actions : ', () => { it('on Search Results - [C297660]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFiles(); - await searchInput.searchForTextAndCloseSearchOptions(fileLocked); + await searchInput.searchFor(fileLocked); await dataTable.selectItem(fileLocked); expect(await toolbar.isViewPresent()).toBe(true, `View is not displayed for ${fileLocked}`); @@ -1673,6 +1732,36 @@ describe('Special permissions available actions : ', () => { await viewerToolbar.closeMoreMenu(); }); + + it('file opened from Search Results - [C306993]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkOnlyFiles(); + await searchInput.searchFor(fileLocked); + await dataTable.waitForBody(); + await dataTable.doubleClickOnRowByName(fileLocked); + await viewer.waitForViewerToOpen(); + + expect(await viewerToolbar.isViewPresent()).toBe(false, `View is displayed`); + expect(await viewerToolbar.isDownloadPresent()).toBe(true, `Download is not displayed`); + expect(await viewerToolbar.isPrintPresent()).toBe(true, `Print is not displayed`); + expect(await viewerToolbar.isFullScreenPresent()).toBe(true, `Full screen is not displayed`); + expect(await viewerToolbar.isSharedLinkSettingsPresent()).toBe(true, 'Shared link settings is not displayed'); + expect(await viewerToolbar.isViewDetailsPresent()).toBe(true, `View details is not displayed`); + + await viewerToolbar.openMoreMenu(); + + expect(await viewerToolbar.menu.isEditOfflinePresent()).toBe(false, `Edit offline is displayed`); + expect(await viewerToolbar.menu.isCancelEditingPresent()).toBe(true, `Cancel editing is not displayed`); + expect(await viewerToolbar.menu.isToggleRemoveFavoritePresent()).toBe(true, `Remove favorite is not displayed`); + expect(await viewerToolbar.menu.isSharePresent()).toBe(false, `Share is displayed in More actions`); + expect(await viewerToolbar.menu.isCopyPresent()).toBe(true, `Copy is not displayed`); + expect(await viewerToolbar.menu.isMovePresent()).toBe(false, `Move is displayed`); + expect(await viewerToolbar.menu.isDeletePresent()).toBe(false, `Delete is displayed`); + expect(await viewerToolbar.menu.isManageVersionsPresent()).toBe(true, `Manage versions is not displayed`); + expect(await viewerToolbar.menu.isUploadNewVersionPresent()).toBe(true, `Upload new version is not displayed`); + + await viewerToolbar.closeMoreMenu(); + }); }); }); @@ -1764,7 +1853,7 @@ describe('Special permissions available actions : ', () => { it('on Search Results - [C297667]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFiles(); - await searchInput.searchForTextAndCloseSearchOptions(fileLocked); + await searchInput.searchFor(fileLocked); await dataTable.selectItem(fileLocked); expect(await toolbar.isViewPresent()).toBe(true, `View is not displayed for ${fileLocked}`); @@ -1883,6 +1972,38 @@ describe('Special permissions available actions : ', () => { await viewerToolbar.closeMoreMenu(); }); + + it('file opened from Search Results - [C306994]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkOnlyFiles(); + await searchInput.searchFor(fileLocked); + await dataTable.waitForBody(); + await dataTable.doubleClickOnRowByName(fileLocked); + await viewer.waitForViewerToOpen(); + + expect(await viewerToolbar.isViewPresent()).toBe(false, `View is displayed`); + expect(await viewerToolbar.isDownloadPresent()).toBe(true, `Download is not displayed`); + expect(await viewerToolbar.isPrintPresent()).toBe(true, `Print is not displayed`); + expect(await viewerToolbar.isFullScreenPresent()).toBe(true, `Full screen is not displayed`); + expect(await viewerToolbar.isSharedLinkSettingsPresent()).toBe(true, 'Shared link settings is not displayed'); + expect(await viewerToolbar.isViewDetailsPresent()).toBe(true, `View details is not displayed`); + + await viewerToolbar.openMoreMenu(); + + expect(await viewerToolbar.menu.isEditOfflinePresent()).toBe(false, `Edit offline is displayed`); + expect(await viewerToolbar.menu.isCancelEditingPresent()).toBe(true, `Cancel editing is not displayed`); + expect(await viewerToolbar.menu.isToggleRemoveFavoritePresent()).toBe(true, `Remove favorite is not displayed`); + expect(await viewerToolbar.menu.isSharePresent()).toBe(false, `Share is displayed in More actions`); + expect(await viewerToolbar.menu.isCopyPresent()).toBe(true, `Copy is not displayed`); + // TODO: change expect to true when ACA-2319 is fixed + expect(await viewerToolbar.menu.isMovePresent()).toBe(false, `Move is not displayed`); + // TODO: change expect to true when ACA-2319 is fixed + expect(await viewerToolbar.menu.isDeletePresent()).toBe(false, `Delete is not displayed`); + expect(await viewerToolbar.menu.isManageVersionsPresent()).toBe(true, `Manage versions is not displayed`); + expect(await viewerToolbar.menu.isUploadNewVersionPresent()).toBe(false, `Upload new version is displayed`); + + await viewerToolbar.closeMoreMenu(); + }); }); }); }); diff --git a/e2e/suites/actions/toolbar-multiple-selection.test.ts b/e2e/suites/actions/toolbar-multiple-selection.test.ts index 3ba1aaae0..47ad8ada6 100755 --- a/e2e/suites/actions/toolbar-multiple-selection.test.ts +++ b/e2e/suites/actions/toolbar-multiple-selection.test.ts @@ -607,7 +607,7 @@ describe('Toolbar actions - multiple selection : ', () => { it('correct actions appear when multiple files are selected - [C291820]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFiles(); - await searchInput.searchForTextAndCloseSearchOptions('my-fileInSite'); + await searchInput.searchFor('my-fileInSite'); await dataTable.selectMultipleItems([file1InSite, file2InSite]); expect(await toolbar.isViewPresent()).toBe(false, 'View is displayed for selected files'); @@ -631,7 +631,7 @@ describe('Toolbar actions - multiple selection : ', () => { it('correct actions appear when multiple locked files are selected - [C297626]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFiles(); - await searchInput.searchForTextAndCloseSearchOptions('my-fileLockedInSite'); + await searchInput.searchFor('my-fileLockedInSite'); await dataTable.selectMultipleItems([fileLocked1InSite, fileLocked2InSite]); expect(await toolbar.isViewPresent()).toBe(false, 'View is displayed for selected files'); @@ -655,7 +655,7 @@ describe('Toolbar actions - multiple selection : ', () => { it('correct actions appear when multiple folders are selected - [C291821]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFolders(); - await searchInput.searchForTextAndCloseSearchOptions('my-folderInSite'); + await searchInput.searchFor('my-folderInSite'); await dataTable.selectMultipleItems([folder1InSite, folder2InSite]); expect(await toolbar.isViewPresent()).toBe(false, 'View is displayed'); @@ -679,7 +679,7 @@ describe('Toolbar actions - multiple selection : ', () => { it('correct actions appear when both files and folders are selected - [C291822]', async () => { await searchInput.clickSearchButton(); await searchInput.checkFilesAndFolders(); - await searchInput.searchForTextAndCloseSearchOptions('my-f'); + await searchInput.searchFor('my-f'); await dataTable.selectMultipleItems([file1InSite, file2InSite, folder1InSite, folder2InSite]); expect(await toolbar.isViewPresent()).toBe(false, 'View is displayed'); diff --git a/e2e/suites/actions/toolbar-single-selection.test.ts b/e2e/suites/actions/toolbar-single-selection.test.ts index 1119da491..4d8b17af4 100755 --- a/e2e/suites/actions/toolbar-single-selection.test.ts +++ b/e2e/suites/actions/toolbar-single-selection.test.ts @@ -365,7 +365,7 @@ describe('Toolbar actions - single selection : ', () => { it('Available actions for a library - Search Results - [C290084]', async () => { await searchInput.clickSearchButton(); await searchInput.checkLibraries(); - await searchInput.searchForTextAndCloseSearchOptions(siteName); + await searchInput.searchFor(siteName); await dataTable.selectItem(siteName); expect(await toolbar.isEmpty()).toBe(false, 'toolbar not displayed'); @@ -383,7 +383,7 @@ describe('Toolbar actions - single selection : ', () => { it('Available actions for a library - Search Results - user is not a member - [C290085]', async () => { await searchInput.clickSearchButton(); await searchInput.checkLibraries(); - await searchInput.searchForTextAndCloseSearchOptions(adminPublic); + await searchInput.searchFor(adminPublic); await dataTable.selectItem(adminPublic); expect(await toolbar.isEmpty()).toBe(false, 'toolbar not displayed'); @@ -401,7 +401,7 @@ describe('Toolbar actions - single selection : ', () => { it('Available actions for a moderated library - Search Results - user requested to join - [C290086]', async () => { await searchInput.clickSearchButton(); await searchInput.checkLibraries(); - await searchInput.searchForTextAndCloseSearchOptions(adminModerated); + await searchInput.searchFor(adminModerated); await dataTable.selectItem(adminModerated); expect(await toolbar.isEmpty()).toBe(false, 'toolbar not displayed'); @@ -676,7 +676,7 @@ describe('Toolbar actions - single selection : ', () => { it('nodes actions are not displayed when no item is selected - [C291815]', async () => { await searchInput.clickSearchButton(); await searchInput.checkFilesAndFolders(); - await searchInput.searchForTextAndCloseSearchOptions(fileInSite); + await searchInput.searchFor(fileInSite); expect(await toolbar.isToggleSearchFiltersPresent()).toBe(true, `Search filter toggle is not displayed`); expect(await toolbar.numberOfAvailableActions()).toBe(1, `more than 1 action is present`); @@ -685,7 +685,7 @@ describe('Toolbar actions - single selection : ', () => { it('correct actions appear when a file is selected - [C291816]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFiles(); - await searchInput.searchForTextAndCloseSearchOptions(fileUser); + await searchInput.searchFor(fileUser); await dataTable.selectItem(fileUser); expect(await toolbar.isEmpty()).toBe(false, `actions not displayed for ${fileUser}`); @@ -710,7 +710,7 @@ describe('Toolbar actions - single selection : ', () => { it('correct actions appear when a locked file is selected - [C297618]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFiles(); - await searchInput.searchForTextAndCloseSearchOptions(fileLocked); + await searchInput.searchFor(fileLocked); await dataTable.selectItem(fileLocked); expect(await toolbar.isEmpty()).toBe(false, `actions not displayed for ${fileLocked}`); @@ -735,7 +735,7 @@ describe('Toolbar actions - single selection : ', () => { it('correct actions appear when a folder is selected - [C291817]', async () => { await searchInput.clickSearchButton(); await searchInput.checkOnlyFolders(); - await searchInput.searchForTextAndCloseSearchOptions(folderUser); + await searchInput.searchFor(folderUser); await dataTable.selectItem(folderUser); expect(await toolbar.isEmpty()).toBe(false, `actions not displayed for ${folderUser}`); diff --git a/e2e/suites/actions/unshare-file-search-results.test.ts b/e2e/suites/actions/unshare-file-search-results.test.ts new file mode 100755 index 000000000..5b494b835 --- /dev/null +++ b/e2e/suites/actions/unshare-file-search-results.test.ts @@ -0,0 +1,239 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2019 Alfresco Software Limited + * + * This file is part of the Alfresco Example Content Application. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * The Alfresco Example Content Application is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Alfresco Example Content Application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +import { browser } from 'protractor'; +import { LoginPage, BrowsingPage } from '../../pages/pages'; +import { SITE_VISIBILITY, SITE_ROLES } from '../../configs'; +import { RepoClient } from '../../utilities/repo-client/repo-client'; +import { ShareDialog } from '../../components/dialog/share-dialog'; +import { ConfirmDialog } from '../../components/dialog/confirm-dialog'; +import { Viewer } from '../../components/viewer/viewer'; +import { Utils } from '../../utilities/utils'; + +describe('Unshare a file from Search Results', () => { + const username = `user-${Utils.random()}`; + + const parent = `parent-${Utils.random()}`; let parentId; + + const file1 = `search-file1-${Utils.random()}.txt`; let file1Id; + const file2 = `search-file2-${Utils.random()}.txt`; let file2Id; + const file3 = `search-file3-${Utils.random()}.txt`; let file3Id; + const file4 = `search-file4-${Utils.random()}.txt`; let file4Id; + + const sitePrivate = `site-private-${Utils.random()}`; + + const fileSite1 = `search-fileSite1-${Utils.random()}.txt`; let fileSite1Id; + const fileSite2 = `search-fileSite2-${Utils.random()}.txt`; let fileSite2Id; + + const apis = { + admin: new RepoClient(), + user: new RepoClient(username, username) + }; + + const loginPage = new LoginPage(); + const page = new BrowsingPage(); + const { dataTable, toolbar } = page; + const shareDialog = new ShareDialog(); + const confirmDialog = new ConfirmDialog(); + const contextMenu = dataTable.menu; + const viewer = new Viewer(); + const { searchInput } = page.header; + + beforeAll(async (done) => { + await apis.admin.people.createUser({ username }); + parentId = (await apis.user.nodes.createFolder(parent)).entry.id; + + file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; + file2Id = (await apis.user.nodes.createFile(file2, parentId)).entry.id; + file3Id = (await apis.user.nodes.createFile(file3, parentId)).entry.id; + file4Id = (await apis.user.nodes.createFile(file4, parentId)).entry.id; + + await apis.user.shared.shareFileById(file1Id); + await apis.user.shared.shareFileById(file2Id); + await apis.user.shared.shareFileById(file3Id); + await apis.user.shared.shareFileById(file4Id); + + await apis.admin.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE); + const docLibId = await apis.admin.sites.getDocLibId(sitePrivate); + + fileSite1Id = (await apis.admin.nodes.createFile(fileSite1, docLibId)).entry.id; + fileSite2Id = (await apis.admin.nodes.createFile(fileSite2, docLibId)).entry.id; + + await apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONSUMER.ROLE); + + await apis.admin.shared.shareFileById(fileSite1Id); + await apis.user.shared.shareFileById(fileSite2Id); + + await apis.user.shared.waitForApi({ expect: 6 }); + await apis.user.search.waitForNodes('search-file', { expect: 6 }); + + await loginPage.loginWith(username); + done(); + }); + + afterAll(async (done) => { + await apis.user.nodes.deleteNodeById(parentId); + await apis.admin.sites.deleteSite(sitePrivate); + done(); + }); + + afterEach(async (done) => { + await page.closeOpenDialogs(); + await page.clickPersonalFilesAndWait(); + done(); + }); + + it('Unshare dialog UI - [C306995]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(file1); + await dataTable.waitForBody(); + + await dataTable.selectItem(file1); + await toolbar.clickSharedLinkSettings(); + await shareDialog.waitForDialogToOpen(); + + expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked'); + await shareDialog.clickShareToggle(); + + expect(await confirmDialog.isDialogOpen()).toBe(true, 'Unshare dialog is not open'); + expect(await confirmDialog.getTitle()).toContain('Remove this shared link'); + expect(await confirmDialog.getText()).toContain('This link will be deleted and a new link will be created next time this file is shared'); + expect(await confirmDialog.isRemoveEnabled()).toBe(true, 'REMOVE button is not enabled'); + expect(await confirmDialog.isCancelEnabled()).toBe(true, 'CANCEL button is not enabled'); + }); + + it('Unshare a file - [C306996]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(file2); + await dataTable.waitForBody(); + + await dataTable.selectItem(file2); + await toolbar.clickSharedLinkSettings(); + await shareDialog.waitForDialogToOpen(); + const url = await shareDialog.getLinkUrl(); + await shareDialog.clickShareToggle(); + + await confirmDialog.clickRemove(); + await confirmDialog.waitForDialogToClose(); + await shareDialog.waitForDialogToClose(); + expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open'); + expect(await apis.user.nodes.isFileShared(file2Id)).toBe(false, `${file2} is shared`); + + await browser.get(url); + expect(await viewer.isViewerOpened()).toBe(true, 'viewer is not open'); + expect(await viewer.getFileTitle()).not.toEqual(file2); + + await page.load(); + }); + + it('Cancel the Unshare action - [C306997]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(file3); + await dataTable.waitForBody(); + + await dataTable.selectItem(file3); + await toolbar.clickSharedLinkSettings(); + await shareDialog.waitForDialogToOpen(); + + const urlBefore = await shareDialog.getLinkUrl(); + await shareDialog.clickShareToggle(); + + await confirmDialog.clickCancel(); + await confirmDialog.waitForDialogToClose(); + expect(await shareDialog.isDialogOpen()).toBe(true, 'Share dialog not open'); + expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle is off'); + + const urlAfter = await shareDialog.getLinkUrl(); + expect(urlBefore).toEqual(urlAfter); + }); + + it('Unshare a file from the context menu - [C306999]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(file4); + await dataTable.waitForBody(); + + await dataTable.rightClickOnItem(file4); + await contextMenu.waitForMenuToOpen(); + await contextMenu.clickSharedLinkSettings(); + await shareDialog.waitForDialogToOpen(); + const url = await shareDialog.getLinkUrl(); + await shareDialog.clickShareToggle(); + + await confirmDialog.clickRemove(); + await confirmDialog.waitForDialogToClose(); + await shareDialog.waitForDialogToClose(); + expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open'); + expect(await apis.user.nodes.isFileShared(file4Id)).toBe(false, `${file4} is shared`); + + await browser.get(url); + expect(await viewer.isViewerOpened()).toBe(true, 'viewer is not open'); + expect(await viewer.getFileTitle()).not.toEqual(file4); + + await page.load(); + }); + + it('Consumer - on Search Results - file shared by other user - [C306998]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(fileSite1); + await dataTable.waitForBody(); + await dataTable.selectItem(fileSite1); + await toolbar.clickSharedLinkSettings(); + await shareDialog.waitForDialogToOpen(); + + expect(await shareDialog.isShareToggleDisabled()).toBe(false, 'Share toggle disabled for consumer'); + + await shareDialog.clickShareToggle(); + await confirmDialog.clickRemove(); + + const msg = await page.getSnackBarMessage(); + expect(msg).toContain(`You don't have permission to unshare this file`); + }); + + it('Consumer - on Search Results - file shared by the user - [C307000]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(fileSite2); + await dataTable.waitForBody(); + await dataTable.selectItem(fileSite2); + await toolbar.clickSharedLinkSettings(); + await shareDialog.waitForDialogToOpen(); + + expect(await shareDialog.isShareToggleDisabled()).toBe(false, 'Share toggle disabled for consumer'); + + await shareDialog.clickShareToggle(); + await confirmDialog.clickRemove(); + await confirmDialog.waitForDialogToClose(); + await shareDialog.waitForDialogToClose(); + + expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open'); + expect(await apis.user.nodes.isFileShared(fileSite2Id)).toBe(false, `${fileSite2} is shared`); + }); + +}); diff --git a/e2e/suites/actions/unshare-file.test.ts b/e2e/suites/actions/unshare-file.test.ts index dee4dc7f9..e3b802962 100755 --- a/e2e/suites/actions/unshare-file.test.ts +++ b/e2e/suites/actions/unshare-file.test.ts @@ -83,7 +83,7 @@ describe('Unshare a file', () => { }); beforeEach(async (done) => { - await page.refresh(); + await page.closeOpenDialogs(); await page.clickPersonalFilesAndWait(); await dataTable.doubleClickOnRowByName(parent); await dataTable.waitForHeader(); @@ -91,7 +91,7 @@ describe('Unshare a file', () => { }); afterEach(async (done) => { - await Utils.pressEscape(); + await page.closeOpenDialogs(); done(); }); @@ -132,10 +132,6 @@ describe('Unshare a file', () => { expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open'); expect(await apis.user.nodes.isFileShared(file2Id)).toBe(false, `${file2} is shared`); - // TODO: disable check cause api is slow to update - // await page.clickSharedFiles(); - // expect(await dataTable.isItemPresent(file2)).toBe(false, `${file2} is in the Shared files list`); - await browser.get(url); expect(await viewer.isViewerOpened()).toBe(true, 'viewer is not open'); expect(await viewer.getFileTitle()).not.toEqual(file2); @@ -173,10 +169,6 @@ describe('Unshare a file', () => { expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open'); expect(await apis.user.nodes.isFileShared(file4Id)).toBe(false, `${file4} is shared`); - // TODO: disable check cause api is slow to update - // await page.clickSharedFiles(); - // expect(await dataTable.isItemPresent(file4)).toBe(false, `${file4} is in the Shared files list`); - await browser.get(url); expect(await viewer.isViewerOpened()).toBe(true, 'viewer is not open'); expect(await viewer.getFileTitle()).not.toEqual(file4); @@ -213,7 +205,7 @@ describe('Unshare a file', () => { }); beforeEach(async (done) => { - await page.refresh(); + await page.closeOpenDialogs(); await page.goToMyLibrariesAndWait(); await dataTable.doubleClickOnRowByName(siteName); await dataTable.waitForHeader(); @@ -223,7 +215,7 @@ describe('Unshare a file', () => { }); afterEach(async (done) => { - await Utils.pressEscape(); + await page.closeOpenDialogs(); done(); }); @@ -261,10 +253,6 @@ describe('Unshare a file', () => { expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open'); expect(await apis.user.nodes.isFileShared(file2Id)).toBe(false, `${file2} is shared`); - // TODO: disable check cause api is slow to update - // await page.clickSharedFiles(); - // expect(await dataTable.isItemPresent(file2)).toBe(false, `${file2} is in the Shared files list`); - await browser.get(url); expect(await viewer.isViewerOpened()).toBe(true, 'viewer is not open'); expect(await viewer.getFileTitle()).not.toEqual(file2); @@ -302,10 +290,6 @@ describe('Unshare a file', () => { expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open'); expect(await apis.user.nodes.isFileShared(file4Id)).toBe(false, `${file4} is shared`); - // TODO: disable check cause api is slow to update - // await page.clickSharedFiles(); - // expect(await dataTable.isItemPresent(file4)).toBe(false, `${file4} is in the Shared files list`); - await browser.get(url); expect(await viewer.isViewerOpened()).toBe(true, 'viewer is not open'); expect(await viewer.getFileTitle()).not.toEqual(file4); @@ -335,13 +319,13 @@ describe('Unshare a file', () => { }); beforeEach(async (done) => { - await page.refresh(); + await page.closeOpenDialogs(); await page.clickRecentFilesAndWait(); done(); }); afterEach(async (done) => { - await Utils.pressEscape(); + await page.closeOpenDialogs(); done(); }); @@ -382,10 +366,6 @@ describe('Unshare a file', () => { expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open'); expect(await apis.user.nodes.isFileShared(file2Id)).toBe(false, `${file2} is shared`); - // TODO: disable check cause api is slow to update - // await page.clickSharedFiles(); - // expect(await dataTable.isItemPresent(file2)).toBe(false, `${file2} is in the Shared files list`); - await browser.get(url); expect(await viewer.isViewerOpened()).toBe(true, 'viewer is not open'); expect(await viewer.getFileTitle()).not.toEqual(file2); @@ -423,10 +403,6 @@ describe('Unshare a file', () => { expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open'); expect(await apis.user.nodes.isFileShared(file4Id)).toBe(false, `${file4} is shared`); - // TODO: disable check cause api is slow to update - // await page.clickSharedFiles(); - // expect(await dataTable.isItemPresent(file4)).toBe(false, `${file4} is in the Shared files list`); - await browser.get(url); expect(await viewer.isViewerOpened()).toBe(true, 'viewer is not open'); expect(await viewer.getFileTitle()).not.toEqual(file4); @@ -456,13 +432,13 @@ describe('Unshare a file', () => { }); beforeEach(async (done) => { - await page.refresh(); + await page.closeOpenDialogs(); await page.clickSharedFilesAndWait(); done(); }); afterEach(async (done) => { - await Utils.pressEscape(); + await page.closeOpenDialogs(); done(); }); @@ -582,13 +558,13 @@ describe('Unshare a file', () => { }); beforeEach(async (done) => { - await page.refresh(); + await page.closeOpenDialogs(); await page.clickFavoritesAndWait(); done(); }); afterEach(async (done) => { - await Utils.pressEscape(); + await page.closeOpenDialogs(); done(); }); @@ -633,10 +609,6 @@ describe('Unshare a file', () => { expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open'); expect(await apis.user.nodes.isFileShared(file2Id)).toBe(false, `${file2} is shared`); - // TODO: disable check cause api is slow to update - // await page.clickSharedFiles(); - // expect(await dataTable.isItemPresent(file2)).toBe(false, `${file2} is in the Shared files list`); - await browser.get(url); expect(await viewer.isViewerOpened()).toBe(true, 'viewer is not open'); expect(await viewer.getFileTitle()).not.toEqual(file2); @@ -678,10 +650,6 @@ describe('Unshare a file', () => { expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open'); expect(await apis.user.nodes.isFileShared(file4Id)).toBe(false, `${file4} is shared`); - // TODO: disable check cause api is slow to update - // await page.clickSharedFiles(); - // expect(await dataTable.isItemPresent(file4)).toBe(false, `${file4} is in the Shared files list`); - await browser.get(url); expect(await viewer.isViewerOpened()).toBe(true, 'viewer is not open'); expect(await viewer.getFileTitle()).not.toEqual(file4); @@ -694,25 +662,38 @@ describe('Unshare a file', () => { const sitePrivate = `site-private-${Utils.random()}`; - const file1 = `file1-${Utils.random()}.txt`; let file1Id; - const file2 = `file2-${Utils.random()}.txt`; let file2Id; + const file1FileLib = `file1-FL-${Utils.random()}.txt`; let file1FileLibId; + const file2FileLib = `file2-FL-${Utils.random()}.txt`; let file2FileLibId; + const file1Shared = `file1-Shared-${Utils.random()}.txt`; let file1SharedId; + const file2Shared = `file2-Shared-${Utils.random()}.txt`; let file2SharedId; + const file1Fav = `file1-Fav-${Utils.random()}.txt`; let file1FavId; + const file2Fav = `file2-Fav-${Utils.random()}.txt`; let file2FavId; beforeAll(async (done) => { await apis.admin.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE); const docLibId = await apis.admin.sites.getDocLibId(sitePrivate); - file1Id = (await apis.admin.nodes.createFile(file1, docLibId)).entry.id; - file2Id = (await apis.admin.nodes.createFile(file2, docLibId)).entry.id; + file1FileLibId = (await apis.admin.nodes.createFile(file1FileLib, docLibId)).entry.id; + file2FileLibId = (await apis.admin.nodes.createFile(file2FileLib, docLibId)).entry.id; + file1SharedId = (await apis.admin.nodes.createFile(file1Shared, docLibId)).entry.id; + file2SharedId = (await apis.admin.nodes.createFile(file2Shared, docLibId)).entry.id; + file1FavId = (await apis.admin.nodes.createFile(file1Fav, docLibId)).entry.id; + file2FavId = (await apis.admin.nodes.createFile(file2Fav, docLibId)).entry.id; await apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONSUMER.ROLE); - await apis.admin.shared.shareFileById(file1Id); - await apis.user.shared.shareFileById(file2Id); - await apis.user.shared.waitForApi({ expect: 2 }); + await apis.admin.shared.shareFileById(file1FileLibId); + await apis.user.shared.shareFileById(file2FileLibId); + await apis.admin.shared.shareFileById(file1SharedId); + await apis.user.shared.shareFileById(file2SharedId); + await apis.admin.shared.shareFileById(file1FavId); + await apis.user.shared.shareFileById(file2FavId); + + await apis.user.favorites.addFavoriteById('file', file1FavId); + await apis.user.favorites.addFavoriteById('file', file2FavId); - await apis.user.favorites.addFavoriteById('file', file1Id); - await apis.user.favorites.addFavoriteById('file', file2Id); await apis.user.favorites.waitForApi({ expect: 2 }); + await apis.user.shared.waitForApi({ expect: 6 }); done(); }); @@ -722,13 +703,9 @@ describe('Unshare a file', () => { done(); }); - beforeEach(async (done) => { - await page.refresh(); - done(); - }); - afterEach(async (done) => { - await Utils.pressEscape(); + await page.closeOpenDialogs(); + await page.clickPersonalFilesAndWait(); done(); }); @@ -736,62 +713,104 @@ describe('Unshare a file', () => { await page.goToMyLibrariesAndWait(); await dataTable.doubleClickOnRowByName(sitePrivate); await dataTable.waitForHeader(); - await dataTable.selectItem(file1); + await dataTable.selectItem(file1FileLib); await toolbar.clickSharedLinkSettings(); await shareDialog.waitForDialogToOpen(); - expect(await shareDialog.isShareToggleDisabled()).toBe(false, 'Share toggle enabled for consumer'); + expect(await shareDialog.isShareToggleDisabled()).toBe(false, 'Share toggle disabled for consumer'); + + await shareDialog.clickShareToggle(); + await confirmDialog.clickRemove(); + + const msg = await page.getSnackBarMessage(); + expect(msg).toContain(`You don't have permission to unshare this file`); }); it('on File Libraries - file shared by the user - [C286701]', async () => { await page.goToMyLibrariesAndWait(); await dataTable.doubleClickOnRowByName(sitePrivate); await dataTable.waitForHeader(); - await dataTable.selectItem(file2); + await dataTable.selectItem(file2FileLib); await toolbar.clickSharedLinkSettings(); await shareDialog.waitForDialogToOpen(); - expect(await shareDialog.isShareToggleDisabled()).toBe(false, 'Share toggle enabled for consumer'); + expect(await shareDialog.isShareToggleDisabled()).toBe(false, 'Share toggle disabled for consumer'); + + await shareDialog.clickShareToggle(); + await confirmDialog.clickRemove(); + await confirmDialog.waitForDialogToClose(); + await shareDialog.waitForDialogToClose(); + + expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open'); + expect(await apis.user.nodes.isFileShared(file2FileLibId)).toBe(false, `${file2FileLib} is shared`); }); it('on Shared Files - file shared by other user - [C286687]', async () => { await page.clickSharedFilesAndWait(); - await dataTable.selectItem(file1); + await dataTable.selectItem(file1Shared); await toolbar.clickSharedLinkSettings(); await shareDialog.waitForDialogToOpen(); - expect(await shareDialog.isShareToggleDisabled()).toBe(false, 'Share toggle enabled for consumer'); + expect(await shareDialog.isShareToggleDisabled()).toBe(false, 'Share toggle disabled for consumer'); + + await shareDialog.clickShareToggle(); + await confirmDialog.clickRemove(); + + const msg = await page.getSnackBarMessage(); + expect(msg).toContain(`You don't have permission to unshare this file`); }); it('on Shared Files - file shared by the user - [C286702]', async () => { await page.clickSharedFilesAndWait(); - await dataTable.selectItem(file1); + await dataTable.selectItem(file2Shared); await toolbar.clickSharedLinkSettings(); await shareDialog.waitForDialogToOpen(); - expect(await shareDialog.isShareToggleDisabled()).toBe(false, 'Share toggle enabled for consumer'); + expect(await shareDialog.isShareToggleDisabled()).toBe(false, 'Share toggle disabled for consumer'); + + await shareDialog.clickShareToggle(); + await confirmDialog.clickRemove(); + await confirmDialog.waitForDialogToClose(); + await shareDialog.waitForDialogToClose(); + + expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open'); + expect(await apis.user.nodes.isFileShared(file2SharedId)).toBe(false, `${file2Shared} is shared`); }); it('on Favorites - file shared by other user - [C286697]', async () => { await page.clickFavoritesAndWait(); - await dataTable.selectItem(file1); + await dataTable.selectItem(file1Fav); // TODO: remove workaround for favorites // await toolbar.clickSharedLinkSettings(); await toolbar.clickShare(); await shareDialog.waitForDialogToOpen(); - expect(await shareDialog.isShareToggleDisabled()).toBe(false, 'Share toggle enabled for consumer'); + expect(await shareDialog.isShareToggleDisabled()).toBe(false, 'Share toggle disabled for consumer'); + + await shareDialog.clickShareToggle(); + await confirmDialog.clickRemove(); + + const msg = await page.getSnackBarMessage(); + expect(msg).toContain(`You don't have permission to unshare this file`); }); it('on Favorites - file shared by the user - [C286703]', async () => { await page.clickFavoritesAndWait(); - await dataTable.selectItem(file1); + await dataTable.selectItem(file2Fav); // TODO: remove workaround for favorites // await toolbar.clickSharedLinkSettings(); await toolbar.clickShare(); await shareDialog.waitForDialogToOpen(); - expect(await shareDialog.isShareToggleDisabled()).toBe(false, 'Share toggle enabled for consumer'); + expect(await shareDialog.isShareToggleDisabled()).toBe(false, 'Share toggle disabled for consumer'); + + await shareDialog.clickShareToggle(); + await confirmDialog.clickRemove(); + await confirmDialog.waitForDialogToClose(); + await shareDialog.waitForDialogToClose(); + + expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open'); + expect(await apis.user.nodes.isFileShared(file2FavId)).toBe(false, `${file2Fav} is shared`); }); }); diff --git a/e2e/suites/actions/upload-new-version.test.ts b/e2e/suites/actions/upload-new-version.test.ts index 955005ee7..4391f8370 100755 --- a/e2e/suites/actions/upload-new-version.test.ts +++ b/e2e/suites/actions/upload-new-version.test.ts @@ -39,10 +39,18 @@ describe('Upload new version', () => { const fileLocked1 = `file-locked1-${Utils.random()}.docx`; let fileLocked1Id; const fileLocked2 = `file-locked2-${Utils.random()}.docx`; let fileLocked2Id; + const fileSearch1 = `search-file1-${Utils.random()}.docx`; let fileSearch1Id; + const fileSearch2 = `search-file2-${Utils.random()}.docx`; let fileSearch2Id; + const fileSearch3 = `search-file3-${Utils.random()}.docx`; let fileSearch3Id; + const fileSearch4 = `search-file4-${Utils.random()}.docx`; let fileSearch4Id; + const fileLockedSearch1 = `search-file-locked1-${Utils.random()}.docx`; let fileLockedSearch1Id; + const fileLockedSearch2 = `search-file-locked2-${Utils.random()}.docx`; let fileLockedSearch2Id; + const parentPF = `parentPersonal-${Utils.random()}`; let parentPFId; const parentSF = `parentShared-${Utils.random()}`; let parentSFId; const parentRF = `parentRecent-${Utils.random()}`; let parentRFId; const parentFav = `parentFav-${Utils.random()}`; let parentFavId; + const parentSearch = `parentSearch-${Utils.random()}`; let parentSearchId; const file = FILES.pdfFile; let fileId; const fileToUpload1 = FILES.docxFile; @@ -60,6 +68,7 @@ describe('Upload new version', () => { const page = new BrowsingPage(); const { dataTable, toolbar } = page; const uploadNewVersionDialog = new UploadNewVersionDialog(); + const { searchInput } = page.header; beforeAll(async (done) => { await apis.admin.people.createUser({ username }); @@ -68,6 +77,7 @@ describe('Upload new version', () => { parentSFId = (await apis.user.nodes.createFolder(parentSF)).entry.id; parentRFId = (await apis.user.nodes.createFolder(parentRF)).entry.id; parentFavId = (await apis.user.nodes.createFolder(parentFav)).entry.id; + parentSearchId = (await apis.user.nodes.createFolder(parentSearch)).entry.id; done(); }); @@ -77,6 +87,7 @@ describe('Upload new version', () => { await apis.user.nodes.deleteNodeById(parentSFId); await apis.user.nodes.deleteNodeById(parentRFId); await apis.user.nodes.deleteNodeById(parentFavId); + await apis.user.nodes.deleteNodeById(parentSearchId); done(); }); @@ -669,4 +680,178 @@ describe('Upload new version', () => { }); }); + describe('on Search Results', () => { + beforeAll(async (done) => { + fileId = (await apis.user.upload.uploadFile(file, parentSearchId)).entry.id; + fileSearch1Id = (await apis.user.nodes.createFile(fileSearch1, parentSearchId)).entry.id; + fileSearch2Id = (await apis.user.nodes.createFile(fileSearch2, parentSearchId)).entry.id; + fileSearch3Id = (await apis.user.nodes.createFile(fileSearch3, parentSearchId)).entry.id; + fileSearch4Id = (await apis.user.nodes.createFile(fileSearch4, parentSearchId)).entry.id; + + fileLockedSearch1Id = (await apis.user.nodes.createFile(fileLockedSearch1, parentSearchId)).entry.id; + fileLockedSearch2Id = (await apis.user.nodes.createFile(fileLockedSearch2, parentSearchId)).entry.id; + + await apis.user.nodes.lockFile(fileLockedSearch1Id); + await apis.user.nodes.lockFile(fileLockedSearch2Id); + + await apis.user.search.waitForNodes('search-f', { expect: 6 }) + + await loginPage.loginWith(username); + done(); + }); + + afterEach(async (done) => { + await Utils.pressEscape(); + await page.header.expandSideNav(); + await page.clickPersonalFilesAndWait(); + done(); + }); + + it('dialog UI defaults - [C307003]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(file); + await dataTable.waitForBody(); + await dataTable.selectItem(file, parentSearch); + await toolbar.clickMoreActionsUploadNewVersion(); + + await Utils.uploadFileNewVersion(fileToUpload1); + await page.waitForDialog(); + + expect(await uploadNewVersionDialog.getTitle()).toEqual('Upload New Version'); + expect(await uploadNewVersionDialog.getText()).toContain('What level of changes were made to this version?'); + expect(await uploadNewVersionDialog.isDescriptionDisplayed()).toBe(true, 'Description not displayed'); + expect(await uploadNewVersionDialog.isMinorOptionDisplayed()).toBe(true, 'Minor option not displayed'); + expect(await uploadNewVersionDialog.isMajorOptionDisplayed()).toBe(true, 'Major option not displayed'); + expect(await uploadNewVersionDialog.isCancelButtonEnabled()).toBe(true, 'Cancel button not enabled'); + expect(await uploadNewVersionDialog.isUploadButtonEnabled()).toBe(true, 'Update button not enabled'); + }); + + it('file is updated after uploading a new version - major - [C307004]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor('search-f'); + await dataTable.waitForBody(); + await dataTable.selectItem(fileSearch1, parentSearch); + await toolbar.clickMoreActionsUploadNewVersion(); + + await Utils.uploadFileNewVersion(fileToUpload1); + await page.waitForDialog(); + + await uploadNewVersionDialog.clickMajor(); + await uploadNewVersionDialog.enterDescription('new major version description'); + await uploadNewVersionDialog.clickUpload(); + + // TODO: enable when ACA-2329 is fixed + // expect(await dataTable.isItemPresent(fileToUpload1, parentSearch)).toBe(true, 'File not updated'); + expect(await apis.user.nodes.getFileVersionType(fileSearch1Id)).toEqual('MAJOR', 'File has incorrect version type'); + expect(await apis.user.nodes.getFileVersionLabel(fileSearch1Id)).toEqual('1.0', 'File has incorrect version label'); + }); + + it('file is updated after uploading a new version - minor - [C307005]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor('search-f'); + await dataTable.waitForBody(); + await dataTable.selectItem(fileSearch2, parentSearch); + await toolbar.clickMoreActionsUploadNewVersion(); + + await Utils.uploadFileNewVersion(fileToUpload2); + await page.waitForDialog(); + + await uploadNewVersionDialog.clickMinor(); + await uploadNewVersionDialog.enterDescription('new minor version description'); + await uploadNewVersionDialog.clickUpload(); + + // TODO: enable when ACA-2329 is fixed + // expect(await dataTable.isItemPresent(fileToUpload2, parentSearch)).toBe(true, 'File not updated'); + expect(await apis.user.nodes.getFileVersionType(fileSearch2Id)).toEqual('MINOR', 'File has incorrect version type'); + expect(await apis.user.nodes.getFileVersionLabel(fileSearch2Id)).toEqual('0.1', 'File has incorrect version label'); + }); + + it('file is not updated when clicking Cancel - [C307006]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor('search-f'); + await dataTable.waitForBody(); + await dataTable.selectItem(fileSearch3, parentSearch); + await toolbar.clickMoreActionsUploadNewVersion(); + + await Utils.uploadFileNewVersion(fileToUpload3); + await page.waitForDialog(); + + await uploadNewVersionDialog.clickMinor(); + await uploadNewVersionDialog.enterDescription('new version description'); + await uploadNewVersionDialog.clickCancel(); + + expect(await dataTable.isItemPresent(fileSearch3, parentSearch)).toBe(true, 'File was updated'); + expect(await apis.user.nodes.getFileVersionType(fileSearch3Id)).toEqual('', 'File has incorrect version type'); + expect(await apis.user.nodes.getFileVersionLabel(fileSearch3Id)).toEqual('', 'File has incorrect version label'); + }); + + it('upload new version fails when new file name already exists - [C307007]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor('search-f'); + await dataTable.waitForBody(); + await dataTable.selectItem(fileSearch4, parentSearch); + await toolbar.clickMoreActionsUploadNewVersion(); + + await Utils.uploadFileNewVersion(file); + await page.waitForDialog(); + + await uploadNewVersionDialog.clickMinor(); + await uploadNewVersionDialog.enterDescription('new version description'); + await uploadNewVersionDialog.clickUpload(); + + await page.refresh(); + + expect(await dataTable.isItemPresent(fileSearch4, parentSearch)).toBe(true, 'File was updated'); + expect(await apis.user.nodes.getFileVersionType(fileSearch4Id)).toEqual('', 'File has incorrect version type'); + expect(await apis.user.nodes.getFileVersionLabel(fileSearch4Id)).toEqual('', 'File has incorrect version label'); + }); + + it('file is unlocked after uploading a new version - [C307008]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor('search-f'); + await dataTable.waitForBody(); + await dataTable.selectItem(fileLockedSearch1, parentSearch); + await toolbar.clickMoreActionsUploadNewVersion(); + + await Utils.uploadFileNewVersion(fileToUpload4); + await page.waitForDialog(); + + await uploadNewVersionDialog.clickMinor(); + await uploadNewVersionDialog.enterDescription('new version description'); + await uploadNewVersionDialog.clickUpload(); + + // TODO: enable when ACA-2329 is fixed + // expect(await dataTable.isItemPresent(fileToUpload4, parentSearch)).toBe(true, 'File name was not changed'); + expect(await apis.user.nodes.isFileLockedWrite(fileLockedSearch1Id)).toBe(false, `${fileLockedSearch1} is still locked`); + expect(await apis.user.nodes.getFileVersionType(fileLockedSearch1Id)).toEqual('MINOR', 'File has incorrect version type'); + expect(await apis.user.nodes.getFileVersionLabel(fileLockedSearch1Id)).toEqual('0.1', 'File has incorrect version label'); + }); + + it('file remains locked after canceling of uploading a new version - [C307009]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor('search-f'); + await dataTable.waitForBody(); + await dataTable.selectItem(fileLockedSearch2, parentSearch); + await toolbar.clickMoreActionsUploadNewVersion(); + + await Utils.uploadFileNewVersion(fileToUpload5); + await page.waitForDialog(); + + await uploadNewVersionDialog.clickMinor(); + await uploadNewVersionDialog.enterDescription('new version description'); + await uploadNewVersionDialog.clickCancel(); + + expect(await dataTable.isItemPresent(fileToUpload5, parentSearch)).toBe(false, 'File was updated'); + expect(await dataTable.isItemPresent(fileLockedSearch2, parentSearch)).toBe(true, 'File not displayed'); + expect(await apis.user.nodes.isFileLockedWrite(fileLockedSearch2Id)).toBe(true, `${fileLockedSearch2} was unlocked`); + }); + }); + }); diff --git a/e2e/suites/list-views/empty-list.test.ts b/e2e/suites/list-views/empty-list.test.ts index b8fa7e43e..93ecafd09 100755 --- a/e2e/suites/list-views/empty-list.test.ts +++ b/e2e/suites/list-views/empty-list.test.ts @@ -180,4 +180,26 @@ describe('Empty list views', () => { expect(await pagination.isPreviousButtonPresent()).toBe(false, 'Previous button is present'); expect(await pagination.isNextButtonPresent()).toBe(false, 'Next button is present'); }); + + it('Empty Search results - Libraries - [C290020]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkLibraries(); + /* cspell:disable-next-line */ + await searchInput.searchFor('qwertyuiop'); + await dataTable.waitForBody(); + + expect(await dataTable.isEmptyList()).toBe(true, 'list is not empty'); + expect(await dataTable.getEmptySearchResultsText()).toContain('Your search returned 0 results'); + }); + + it('Empty Search results - Files / Folders - [C290031]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + /* cspell:disable-next-line */ + await searchInput.searchFor('qwertyuiop'); + await dataTable.waitForBody(); + + expect(await dataTable.isEmptyList()).toBe(true, 'list is not empty'); + expect(await dataTable.getEmptySearchResultsText()).toContain('Your search returned 0 results'); + }); }); diff --git a/e2e/suites/list-views/permissions.test.ts b/e2e/suites/list-views/permissions.test.ts index 081f4286c..0e42c6efd 100755 --- a/e2e/suites/list-views/permissions.test.ts +++ b/e2e/suites/list-views/permissions.test.ts @@ -40,6 +40,7 @@ describe('Special permissions', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable } = page; + const { searchInput } = page.header; beforeAll(async (done) => { await apis.admin.people.createUser({ username }); @@ -100,6 +101,24 @@ describe('Special permissions', () => { await page.refresh(); expect(await dataTable.isEmptyList()).toBe(true, 'Items are still displayed'); }); + + it('on Search Results - [C290122]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(fileName); + await dataTable.waitForBody(); + + expect(await dataTable.isItemPresent(fileName)).toBe(true, `${fileName} is not displayed`); + + await apis.admin.sites.deleteSiteMember(sitePrivate, username); + + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(fileName); + await dataTable.waitForBody(); + + expect(await dataTable.isItemPresent(fileName)).toBe(false, `${fileName} is displayed`); + }); }); describe(`Location column is empty if user doesn't have permissions on the file's parent folder`, () => { @@ -143,5 +162,15 @@ describe('Special permissions', () => { expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items'); expect(await dataTable.getItemLocation(fileName)).toEqual('Unknown'); }); + + it('on Search results - [C306868]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(fileName); + await dataTable.waitForBody(); + + expect(await dataTable.isItemPresent(fileName)).toBe(true, `${fileName} is not displayed`); + expect(await dataTable.getItemLocation(fileName)).toEqual('Unknown'); + }); }); }); diff --git a/e2e/suites/navigation/sidebar.test.ts b/e2e/suites/navigation/sidebar.test.ts index 83a47645a..6db34fa14 100755 --- a/e2e/suites/navigation/sidebar.test.ts +++ b/e2e/suites/navigation/sidebar.test.ts @@ -209,7 +209,7 @@ describe('Sidebar', () => { it('sidebar is collapsed automatically when Search Results opens - [C277223]', async () => { await searchInput.clickSearchButton(); /* cspell:disable-next-line */ - await searchInput.searchForTextAndCloseSearchOptions('qwertyuiop'); + await searchInput.searchFor('qwertyuiop'); await searchResultsPage.waitForResults(); expect(await header.isExpandedSidenav()).toBe(false, 'Sidebar not collapsed'); @@ -218,7 +218,7 @@ describe('Sidebar', () => { it('sidenav returns to the default state when navigating away from the Search Results page - [C277224]', async () => { await searchInput.clickSearchButton(); /* cspell:disable-next-line */ - await searchInput.searchForTextAndCloseSearchOptions('qwertyuiop'); + await searchInput.searchFor('qwertyuiop'); await searchResultsPage.waitForResults(); await page.clickFavorites(); @@ -228,7 +228,7 @@ describe('Sidebar', () => { it('sidenav can be expanded when search results page is displayed - [C277230]', async () => { await searchInput.clickSearchButton(); /* cspell:disable-next-line */ - await searchInput.searchForTextAndCloseSearchOptions('qwertyuiop'); + await searchInput.searchFor('qwertyuiop'); await searchResultsPage.waitForResults(); await header.expandSideNav(); diff --git a/e2e/suites/search/search-results-files-folders.test.ts b/e2e/suites/search/search-results-files-folders.test.ts new file mode 100644 index 000000000..a1d2cd440 --- /dev/null +++ b/e2e/suites/search/search-results-files-folders.test.ts @@ -0,0 +1,158 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2019 Alfresco Software Limited + * + * This file is part of the Alfresco Example Content Application. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * The Alfresco Example Content Application is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Alfresco Example Content Application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +import { LoginPage, SearchResultsPage } from '../../pages/pages'; +import { RepoClient } from '../../utilities/repo-client/repo-client'; +import { Utils } from '../../utilities/utils'; +import * as moment from 'moment'; + +describe('Search results - files and folders', () => { + const username = `user-${Utils.random()}`; + + const file = `test-file-${Utils.random()}.txt`; let fileId; + const fileTitle = 'file title'; + const fileDescription = 'file description'; + + /* cspell:disable-next-line */ + const fileRussian = `любимый-сайт-${Utils.random()}`; let fileRussianId; + + const folder = `test-folder-${Utils.random()}`; let folderId; + const folderTitle = 'folder title'; + const folderDescription = 'folder description'; + + const site = `test-site-${Utils.random()}`; + + const apis = { + admin: new RepoClient(), + user: new RepoClient(username, username) + }; + + const loginPage = new LoginPage(); + const page = new SearchResultsPage(); + const { searchInput } = page.header; + const { dataTable, breadcrumb } = page; + + beforeAll(async (done) => { + await apis.admin.people.createUser({ username }); + + fileId = (await apis.user.nodes.createFile(file, '-my-', fileTitle, fileDescription)).entry.id; + await apis.user.nodes.editNodeContent(fileId, 'edited by user'); + folderId = (await apis.user.nodes.createFolder(folder, '-my-', folderTitle, folderDescription)).entry.id; + fileRussianId = (await apis.user.nodes.createFile(fileRussian)).entry.id; + await apis.user.sites.createSite(site); + + await apis.user.search.waitForApi(username, { expect: 2 }); + await apis.user.queries.waitForSites(site, { expect: 1 }); + + await loginPage.loginWith(username); + done(); + }); + + afterAll(async (done) => { + await Promise.all([ + apis.user.nodes.deleteNodeById(fileId), + apis.user.nodes.deleteNodeById(fileRussianId), + apis.user.nodes.deleteNodeById(folderId), + apis.user.sites.deleteSite(site) + ]); + done(); + }); + + beforeEach(async (done) => { + await page.refresh(); + done(); + }); + + it('Results page title - [C307002]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor('test-'); + await dataTable.waitForBody(); + + expect(await page.breadcrumb.getCurrentItemName()).toEqual('Search Results'); + }); + + it('File information - [C279183]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor('test-'); + await dataTable.waitForBody(); + + const fileEntry = await apis.user.nodes.getNodeById(fileId); + const modifiedDate = moment(fileEntry.entry.modifiedAt).format("MMM D, YYYY, h:mm:ss A"); + const modifiedBy = fileEntry.entry.modifiedByUser.displayName; + const size = fileEntry.entry.content.sizeInBytes; + + expect(await dataTable.isItemPresent(file)).toBe(true, `${file} is not displayed`); + + expect(await dataTable.getRowCellsCount(file)).toEqual(2, 'incorrect number of columns'); + + expect(await dataTable.getSearchResultLinesCount(file)).toEqual(4, 'incorrect number of lines for search result'); + expect(await dataTable.getSearchResultNameAndTitle(file)).toBe(`${file} ( ${fileTitle} )`); + expect(await dataTable.getSearchResultDescription(file)).toBe(fileDescription); + expect(await dataTable.getSearchResultModified(file)).toBe(`Modified: ${modifiedDate} by ${modifiedBy} | Size: ${size} Bytes`); + expect(await dataTable.getSearchResultLocation(file)).toBe('Location: Personal Files'); + }); + + it('Folder information - [C306867]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor('test-'); + await dataTable.waitForBody(); + + const folderEntry = await apis.user.nodes.getNodeById(folderId); + const modifiedDate = moment(folderEntry.entry.modifiedAt).format("MMM D, YYYY, h:mm:ss A"); + const modifiedBy = folderEntry.entry.modifiedByUser.displayName; + + expect(await dataTable.isItemPresent(folder)).toBe(true, `${folder} is not displayed`); + + expect(await dataTable.getRowCellsCount(folder)).toEqual(2, 'incorrect number of columns'); + + expect(await dataTable.getSearchResultLinesCount(folder)).toEqual(4, 'incorrect number of lines for search result'); + expect(await dataTable.getSearchResultNameAndTitle(folder)).toBe(`${folder} ( ${folderTitle} )`); + expect(await dataTable.getSearchResultDescription(folder)).toBe(folderDescription); + expect(await dataTable.getSearchResultModified(folder)).toBe(`Modified: ${modifiedDate} by ${modifiedBy}`); + expect(await dataTable.getSearchResultLocation(folder)).toBe('Location: Personal Files'); + }); + + it('Search file with special characters - [C290029]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(fileRussian); + await dataTable.waitForBody(); + + expect(await dataTable.isItemPresent(fileRussian)).toBe(true, `${fileRussian} is not displayed`); + }); + + it('Location column redirect - file in user Home - [C279177]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(file); + await dataTable.waitForBody(); + + await dataTable.clickItemLocation(file); + expect(await breadcrumb.getAllItems()).toEqual([ 'Personal Files' ]); + }); +}); diff --git a/e2e/suites/search/search-results.test.ts b/e2e/suites/search/search-results-general.test.ts similarity index 77% rename from e2e/suites/search/search-results.test.ts rename to e2e/suites/search/search-results-general.test.ts index 9c9d26df9..cc21b4ef5 100644 --- a/e2e/suites/search/search-results.test.ts +++ b/e2e/suites/search/search-results-general.test.ts @@ -26,8 +26,9 @@ import { LoginPage, SearchResultsPage } from '../../pages/pages'; import { RepoClient } from '../../utilities/repo-client/repo-client'; import { Utils } from '../../utilities/utils'; +import { browser } from 'protractor'; -describe('Search results', () => { +describe('Search results general', () => { const username = `user-${Utils.random()}`; const file = `test-file-${Utils.random()}.txt`; let fileId; @@ -116,4 +117,36 @@ describe('Search results', () => { expect(await dataTable.isItemPresent(site)).toBe(true, `${site} not displayed`); }); + it('Results are updated automatically when changing the search term - [C279162]', async () => { + await searchInput.clickSearchButton(); + await searchInput.searchFor(file); + await page.waitForResults(); + + expect(await dataTable.isItemPresent(file)).toBe(true, `${file} is not displayed`); + expect(await dataTable.isItemPresent(folder)).toBe(false, `${folder} is displayed`); + + await searchInput.clickSearchButton(); + await searchInput.searchFor(folder); + + expect(await dataTable.isItemPresent(file)).toBe(false, `${file} is displayed`); + expect(await dataTable.isItemPresent(folder)).toBe(true, `${folder} is not displayed`); + }); + + it('Results are returned when accessing an URL containing a search query - [C279178]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkLibraries(); + await searchInput.searchFor(site); + await page.waitForResults(); + + expect(await dataTable.isItemPresent(site)).toBe(true, `${site} not displayed`); + + const url = await browser.getCurrentUrl(); + + await page.clickPersonalFiles(); + await browser.get(url); + await page.waitForResults(); + + expect(await dataTable.isItemPresent(site)).toBe(true, `${site} not displayed`); + }); + }); diff --git a/e2e/suites/viewer/viewer-general.test.ts b/e2e/suites/viewer/viewer-general.test.ts index 334140223..d53652495 100755 --- a/e2e/suites/viewer/viewer-general.test.ts +++ b/e2e/suites/viewer/viewer-general.test.ts @@ -49,8 +49,9 @@ describe('Viewer general', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); - const dataTable = page.dataTable; + const { dataTable } = page; const viewer = new Viewer(); + const { searchInput } = page.header; beforeAll(async (done) => { await apis.admin.people.createUser({ username }); @@ -75,6 +76,7 @@ describe('Viewer general', () => { }); beforeEach(async (done) => { + await page.header.expandSideNav(); await page.clickPersonalFilesAndWait(); await dataTable.doubleClickOnRowByName(parent); await dataTable.waitForHeader(); @@ -83,6 +85,7 @@ describe('Viewer general', () => { afterEach(async (done) => { await Utils.pressEscape(); + await page.header.expandSideNav(); done(); }); @@ -175,4 +178,17 @@ describe('Viewer general', () => { expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); }); + it('Viewer opens for a file from Search Results - [C279175]', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(xlsxFile); + await dataTable.waitForBody(); + + await dataTable.doubleClickOnRowByName(xlsxFile); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); + expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); + expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); + }); + }); diff --git a/e2e/utilities/repo-client/apis/nodes/nodes-api.ts b/e2e/utilities/repo-client/apis/nodes/nodes-api.ts index 52e3c9746..d60bcd661 100755 --- a/e2e/utilities/repo-client/apis/nodes/nodes-api.ts +++ b/e2e/utilities/repo-client/apis/nodes/nodes-api.ts @@ -150,7 +150,7 @@ export class NodesApi extends RepoApi { } await this.apiAuth(); - return await this.nodesApi.createNode(parentId, nodeBody, { majorVersion: true }); + return await this.nodesApi.createNode(parentId, nodeBody, { majorVersion }); } async createFile(name: string, parentId: string = '-my-', title: string = '', description: string = '', majorVersion: boolean = true) {