diff --git a/e2e/components/dialog/confirm-dialog.ts b/e2e/components/dialog/confirm-dialog.ts index 44ee8180d..5f2e44616 100755 --- a/e2e/components/dialog/confirm-dialog.ts +++ b/e2e/components/dialog/confirm-dialog.ts @@ -33,14 +33,16 @@ export class ConfirmDialog extends Component { title: '.mat-dialog-title', content: '.mat-dialog-content', - delete: 'adf-confirm-accept', - keep: 'adf-confirm-cancel' + accept: 'adf-confirm-accept', + cancel: 'adf-confirm-cancel', + actionButton: 'adf-confirm' }; title: ElementFinder = this.component.element(by.css(ConfirmDialog.selectors.title)); content: ElementFinder = this.component.element(by.css(ConfirmDialog.selectors.content)); - deleteButton: ElementFinder = this.component.element(by.id(ConfirmDialog.selectors.delete)); - keepButton: ElementFinder = this.component.element(by.id(ConfirmDialog.selectors.keep)); + acceptButton: ElementFinder = this.component.element(by.id(ConfirmDialog.selectors.accept)); + cancelButton: ElementFinder = this.component.element(by.id(ConfirmDialog.selectors.cancel)); + actionButton: ElementFinder = this.component.element(by.id(ConfirmDialog.selectors.actionButton)); constructor(ancestor?: ElementFinder) { super(ConfirmDialog.selectors.root, ancestor); @@ -50,6 +52,14 @@ export class ConfirmDialog extends Component { await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT); } + async waitForDialogToOpen() { + await browser.wait(EC.presenceOf(this.title), BROWSER_WAIT_TIMEOUT); + } + + async isDialogOpen() { + return await browser.isElementPresent(by.css(ConfirmDialog.selectors.root)); + } + async getTitle() { return await this.title.getText(); } @@ -58,12 +68,17 @@ export class ConfirmDialog extends Component { return await this.content.getText(); } - async clickDelete() { - await this.deleteButton.click(); + getButtonByName(name: string) { + return this.component.element(by.buttonText(name)); } - async clickKeep() { - await this.keepButton.click(); - await this.waitForDialogToClose(); + async clickButton(name: string) { + const button = this.getButtonByName(name); + await button.click(); + } + + async isButtonEnabled(name: string) { + const button = this.getButtonByName(name); + return await button.isEnabled(); } } diff --git a/e2e/components/dialog/share-dialog.ts b/e2e/components/dialog/share-dialog.ts index 5cf145320..824dd5c83 100755 --- a/e2e/components/dialog/share-dialog.ts +++ b/e2e/components/dialog/share-dialog.ts @@ -111,11 +111,16 @@ export class ShareDialog extends Component { return this.expireInput; } - async isShareToggleEnabled() { + async isShareToggleChecked() { const toggleClass = await this.getShareToggle().getAttribute('class'); return toggleClass.includes('checked'); } + async isShareToggleEnabled() { + const toggleClass = await this.getShareToggle().getAttribute('class'); + return toggleClass.includes('mat-disabled'); + } + async isExpireToggleEnabled() { const toggleClass = await this.getExpireToggle().getAttribute('class'); return toggleClass.includes('checked'); @@ -143,4 +148,7 @@ export class ShareDialog extends Component { await this.expireToggle.click(); } + async clickShareToggle() { + await this.shareToggle.click(); + } } diff --git a/e2e/pages/page.ts b/e2e/pages/page.ts index 506f5a28e..4697185e7 100755 --- a/e2e/pages/page.ts +++ b/e2e/pages/page.ts @@ -105,7 +105,7 @@ export abstract class Page { } async getSnackBarMessage() { - // await this.waitForSnackBarToAppear(); + await this.waitForSnackBarToAppear(); return await this.snackBar.getAttribute('innerText'); } diff --git a/e2e/suites/actions/permanently-delete.test.ts b/e2e/suites/actions/permanently-delete.test.ts index 520a0d7bd..9cf21b4a4 100755 --- a/e2e/suites/actions/permanently-delete.test.ts +++ b/e2e/suites/actions/permanently-delete.test.ts @@ -23,7 +23,6 @@ * along with Alfresco. If not, see . */ -import { browser, protractor } from 'protractor'; import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages'; import { ConfirmDialog } from './../../components/components'; import { SIDEBAR_LABELS } from '../../configs'; @@ -83,8 +82,9 @@ describe('Permanently delete from Trash', () => { await dataTable.selectItem(file1); await toolbar.getButtonByTitleAttribute('Permanently delete').click(); await trashPage.waitForDialog(); - await trashPage.getDialogActionByLabel('Delete').click(); - await trashPage.waitForDialogToClose(); + // await trashPage.getDialogActionByLabel('Delete').click(); + // await trashPage.waitForDialogToClose(); + await confirmDialog.clickButton('Delete'); const text = await trashPage.getSnackBarMessage(); expect(text).toEqual(`${file1} deleted`); @@ -95,8 +95,9 @@ describe('Permanently delete from Trash', () => { await dataTable.selectItem(folder1); await toolbar.getButtonByTitleAttribute('Permanently delete').click(); await trashPage.waitForDialog(); - await trashPage.getDialogActionByLabel('Delete').click(); - await trashPage.waitForDialogToClose(); + // await trashPage.getDialogActionByLabel('Delete').click(); + // await trashPage.waitForDialogToClose(); + await confirmDialog.clickButton('Delete'); const text = await trashPage.getSnackBarMessage(); expect(text).toEqual(`${folder1} deleted`); @@ -107,8 +108,9 @@ describe('Permanently delete from Trash', () => { await dataTable.selectMultipleItems([ file2, folder2 ]); await toolbar.getButtonByTitleAttribute('Permanently delete').click(); await trashPage.waitForDialog(); - await trashPage.getDialogActionByLabel('Delete').click(); - await trashPage.waitForDialogToClose(); + // await trashPage.getDialogActionByLabel('Delete').click(); + // await trashPage.waitForDialogToClose(); + await confirmDialog.clickButton('Delete'); const text = await trashPage.getSnackBarMessage(); expect(text).toEqual(`2 items deleted`); @@ -121,22 +123,23 @@ describe('Permanently delete from Trash', () => { await toolbar.getButtonByTitleAttribute('Permanently delete').click(); await trashPage.waitForDialog(); + expect(await confirmDialog.isDialogOpen()).toBe(true, 'Confirm delete dialog not open'); expect(await confirmDialog.getTitle()).toContain('Delete from trash'); expect(await confirmDialog.getText()).toContain('This will permanently remove the selected item(s)'); - expect(await confirmDialog.deleteButton.isEnabled()).toBe(true, 'DELETE button is not enabled'); - expect(await confirmDialog.keepButton.isEnabled()).toBe(true, 'KEEP button is not enabled'); + expect(await confirmDialog.isButtonEnabled('Delete')).toBe(true, 'DELETE button is not enabled'); + expect(await confirmDialog.isButtonEnabled('Keep')).toBe(true, 'KEEP button is not enabled'); - await browser.actions().sendKeys(protractor.Key.ESCAPE).perform(); + await Utils.pressEscape(); await dataTable.clearSelection(); }); - it('"Keep" action cancels the deletion - [C269115]', async () => { + it('Keep action cancels the deletion - [C269115]', async () => { await dataTable.selectItem(file3); await toolbar.getButtonByTitleAttribute('Permanently delete').click(); await trashPage.waitForDialog(); - expect(await confirmDialog.keepButton.isEnabled()).toBe(true, 'KEEP button is not enabled'); - await confirmDialog.clickKeep(); + expect(await confirmDialog.isButtonEnabled('Keep')).toBe(true, 'KEEP button is not enabled'); + await confirmDialog.clickButton('Keep'); expect(await dataTable.getRowByName(file3).isPresent()).toBe(true, 'Item was deleted'); }); }); diff --git a/e2e/suites/actions/share-file.test.ts b/e2e/suites/actions/share-file.test.ts index d994a212f..7237149f1 100755 --- a/e2e/suites/actions/share-file.test.ts +++ b/e2e/suites/actions/share-file.test.ts @@ -70,15 +70,15 @@ describe('Share a file', () => { describe('from Personal Files', () => { - const file1 = `file1PF-${Utils.random()}.txt`; let file1Id; - const file2 = `file2PF-${Utils.random()}.txt`; let file2Id; - const file3 = `file3PF-${Utils.random()}.txt`; let file3Id; - const file4 = `file4PF-${Utils.random()}.txt`; let file4Id; - const file5 = `file5PF-${Utils.random()}.txt`; let file5Id; - const file6 = `file6PF-${Utils.random()}.txt`; let file6Id; - const file7 = `file7PF-${Utils.random()}.txt`; let file7Id; - const file8 = `file8PF-${Utils.random()}.txt`; let file8Id; - const file9 = `file9PF-${Utils.random()}.txt`; let file9Id; + const file1 = `file1-${Utils.random()}.txt`; let file1Id; + const file2 = `file2-${Utils.random()}.txt`; let file2Id; + const file3 = `file3-${Utils.random()}.txt`; let file3Id; + const file4 = `file4-${Utils.random()}.txt`; let file4Id; + const file5 = `file5-${Utils.random()}.txt`; let file5Id; + const file6 = `file6-${Utils.random()}.txt`; let file6Id; + const file7 = `file7-${Utils.random()}.txt`; let file7Id; + const file8 = `file8-${Utils.random()}.txt`; let file8Id; + const file9 = `file9-${Utils.random()}.txt`; let file9Id; beforeAll(async (done) => { file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; @@ -134,7 +134,7 @@ describe('Share a file', () => { expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share'); expect(await shareDialog.getLinkUrl()).toContain('/preview/s/'); expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly'); - expect(await shareDialog.isShareToggleEnabled()).toBe(true, 'Share toggle not checked'); + expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked'); expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on'); expect(await shareDialog.isExpireToggleEnabled()).toBe(false, 'Expire toggle is checked'); expect(await shareDialog.closeButton.isEnabled()).toBe(true, 'Close button is not enabled'); @@ -160,12 +160,10 @@ describe('Share a file', () => { const url = await shareDialog.getLinkUrl(); await Utils.pressEscape(); const sharedId = await apis.user.nodes.getNodeProperty(file3Id, 'qshare:sharedId'); - - expect(sharedId).not.toBe(undefined, `${file3} is not shared`); + 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 apis.user.shared.waitForApi({ expect: 5 }); // await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); // expect(await dataTable.getRowByName(file3).isPresent()).toBe(true, `${file3} is not in the Shared files list`); }); @@ -266,28 +264,26 @@ describe('Share a file', () => { const url = await shareDialog.getLinkUrl(); await Utils.pressEscape(); const sharedId = await apis.user.nodes.getNodeProperty(file9Id, 'qshare:sharedId'); - - expect(sharedId).not.toBe(undefined, `${file9} is not shared`); + 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 apis.user.shared.waitForApi({ expect: 5 }); // await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); - // expect(await dataTable.getRowByName(file3).isPresent()).toBe(true, `${file3} is not in the Shared files list`); + // expect(await dataTable.getRowByName(file9).isPresent()).toBe(true, `${file9} is not in the Shared files list`); }); }); describe('from File Libraries', () => { - const file1 = `file1PF-${Utils.random()}.txt`; let file1Id; - const file2 = `file2PF-${Utils.random()}.txt`; let file2Id; - const file3 = `file2PF-${Utils.random()}.txt`; let file3Id; - const file4 = `file2PF-${Utils.random()}.txt`; let file4Id; - const file5 = `file2PF-${Utils.random()}.txt`; let file5Id; - const file6 = `file2PF-${Utils.random()}.txt`; let file6Id; - const file7 = `file2PF-${Utils.random()}.txt`; let file7Id; - const file8 = `file2PF-${Utils.random()}.txt`; let file8Id; - const file9 = `file2PF-${Utils.random()}.txt`; let file9Id; + const file1 = `file1-${Utils.random()}.txt`; let file1Id; + const file2 = `file2-${Utils.random()}.txt`; let file2Id; + const file3 = `file3-${Utils.random()}.txt`; let file3Id; + const file4 = `file4-${Utils.random()}.txt`; let file4Id; + const file5 = `file5-${Utils.random()}.txt`; let file5Id; + const file6 = `file6-${Utils.random()}.txt`; let file6Id; + const file7 = `file7-${Utils.random()}.txt`; let file7Id; + const file8 = `file8-${Utils.random()}.txt`; let file8Id; + const file9 = `file9-${Utils.random()}.txt`; let file9Id; const siteName = `site-${Utils.random()}`; const parentInSite = `parent-site-${Utils.random()}`; let parentInSiteId; @@ -344,7 +340,7 @@ describe('Share a file', () => { expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share'); expect(await shareDialog.getLinkUrl()).toContain('/preview/s/'); expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly'); - expect(await shareDialog.isShareToggleEnabled()).toBe(true, 'Share toggle not checked'); + expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked'); expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on'); expect(await shareDialog.isExpireToggleEnabled()).toBe(false, 'Expire toggle is checked'); expect(await shareDialog.closeButton.isEnabled()).toBe(true, 'Close button is not enabled'); @@ -370,12 +366,10 @@ describe('Share a file', () => { const url = await shareDialog.getLinkUrl(); await Utils.pressEscape(); const sharedId = await apis.user.nodes.getNodeProperty(file3Id, 'qshare:sharedId'); - - expect(sharedId).not.toBe(undefined, `${file3} is not shared`); + 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 apis.user.shared.waitForApi({ expect: 5 }); // await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); // expect(await dataTable.getRowByName(file3).isPresent()).toBe(true, `${file3} is not in the Shared files list`); }); @@ -476,12 +470,10 @@ describe('Share a file', () => { const url = await shareDialog.getLinkUrl(); await Utils.pressEscape(); const sharedId = await apis.user.nodes.getNodeProperty(file9Id, 'qshare:sharedId'); - - expect(sharedId).not.toBe(undefined, `${file9} is not shared`); + 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 apis.user.shared.waitForApi({ expect: 5 }); // await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); // expect(await dataTable.getRowByName(file9).isPresent()).toBe(true, `${file9} is not in the Shared files list`); }); @@ -489,15 +481,15 @@ describe('Share a file', () => { describe('from Recent Files', () => { - const file1 = `file1PF-${Utils.random()}.txt`; let file1Id; - const file2 = `file2PF-${Utils.random()}.txt`; let file2Id; - const file3 = `file2PF-${Utils.random()}.txt`; let file3Id; - const file4 = `file2PF-${Utils.random()}.txt`; let file4Id; - const file5 = `file2PF-${Utils.random()}.txt`; let file5Id; - const file6 = `file2PF-${Utils.random()}.txt`; let file6Id; - const file7 = `file2PF-${Utils.random()}.txt`; let file7Id; - const file8 = `file2PF-${Utils.random()}.txt`; let file8Id; - const file9 = `file2PF-${Utils.random()}.txt`; let file9Id; + const file1 = `file1-${Utils.random()}.txt`; let file1Id; + const file2 = `file2-${Utils.random()}.txt`; let file2Id; + const file3 = `file3-${Utils.random()}.txt`; let file3Id; + const file4 = `file4-${Utils.random()}.txt`; let file4Id; + const file5 = `file5-${Utils.random()}.txt`; let file5Id; + const file6 = `file6-${Utils.random()}.txt`; let file6Id; + const file7 = `file7-${Utils.random()}.txt`; let file7Id; + const file8 = `file8-${Utils.random()}.txt`; let file8Id; + const file9 = `file9-${Utils.random()}.txt`; let file9Id; beforeAll(async (done) => { file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; @@ -552,7 +544,7 @@ describe('Share a file', () => { expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share'); expect(await shareDialog.getLinkUrl()).toContain('/preview/s/'); expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly'); - expect(await shareDialog.isShareToggleEnabled()).toBe(true, 'Share toggle not checked'); + expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked'); expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on'); expect(await shareDialog.isExpireToggleEnabled()).toBe(false, 'Expire toggle is checked'); expect(await shareDialog.closeButton.isEnabled()).toBe(true, 'Close button is not enabled'); @@ -578,12 +570,10 @@ describe('Share a file', () => { const url = await shareDialog.getLinkUrl(); await Utils.pressEscape(); const sharedId = await apis.user.nodes.getNodeProperty(file3Id, 'qshare:sharedId'); - - expect(sharedId).not.toBe(undefined, `${file3} is not shared`); + 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 apis.user.shared.waitForApi({ expect: 5 }); // await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); // expect(await dataTable.getRowByName(file3).isPresent()).toBe(true, `${file3} is not in the Shared files list`); }); @@ -684,12 +674,10 @@ describe('Share a file', () => { const url = await shareDialog.getLinkUrl(); await Utils.pressEscape(); const sharedId = await apis.user.nodes.getNodeProperty(file9Id, 'qshare:sharedId'); - - expect(sharedId).not.toBe(undefined, `${file9} is not shared`); + 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 apis.user.shared.waitForApi({ expect: 5 }); // await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); // expect(await dataTable.getRowByName(file9).isPresent()).toBe(true, `${file9} is not in the Shared files list`); }); @@ -697,13 +685,13 @@ describe('Share a file', () => { describe('from Shared Files', () => { - const file1 = `file1PF-${Utils.random()}.txt`; let file1Id; - const file2 = `file2PF-${Utils.random()}.txt`; let file2Id; - const file3 = `file2PF-${Utils.random()}.txt`; let file3Id; - const file4 = `file2PF-${Utils.random()}.txt`; let file4Id; - const file5 = `file2PF-${Utils.random()}.txt`; let file5Id; - const file6 = `file2PF-${Utils.random()}.txt`; let file6Id; - const file7 = `file2PF-${Utils.random()}.txt`; let file7Id; + const file1 = `file1-${Utils.random()}.txt`; let file1Id; + const file2 = `file2-${Utils.random()}.txt`; let file2Id; + const file3 = `file3-${Utils.random()}.txt`; let file3Id; + const file4 = `file4-${Utils.random()}.txt`; let file4Id; + const file5 = `file5-${Utils.random()}.txt`; let file5Id; + const file6 = `file6-${Utils.random()}.txt`; let file6Id; + const file7 = `file7-${Utils.random()}.txt`; let file7Id; beforeAll(async (done) => { file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; @@ -760,7 +748,7 @@ describe('Share a file', () => { expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share'); expect(await shareDialog.getLinkUrl()).toContain('/preview/s/'); expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly'); - expect(await shareDialog.isShareToggleEnabled()).toBe(true, 'Share toggle not checked'); + expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked'); expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on'); expect(await shareDialog.isExpireToggleEnabled()).toBe(false, 'Expire toggle is checked'); expect(await shareDialog.closeButton.isEnabled()).toBe(true, 'Close button is not enabled'); @@ -853,7 +841,7 @@ describe('Share a file', () => { expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share'); expect(await shareDialog.getLinkUrl()).toContain('/preview/s/'); expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly'); - expect(await shareDialog.isShareToggleEnabled()).toBe(true, 'Share toggle not checked'); + expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked'); expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on'); expect(await shareDialog.isExpireToggleEnabled()).toBe(false, 'Expire toggle is checked'); expect(await shareDialog.closeButton.isEnabled()).toBe(true, 'Close button is not enabled'); @@ -861,17 +849,17 @@ describe('Share a file', () => { }); // TODO: enable when ACA-1886 is done - xdescribe('from Favorites', () => { + describe('from Favorites', () => { - const file1 = `file1PF-${Utils.random()}.txt`; let file1Id; - const file2 = `file2PF-${Utils.random()}.txt`; let file2Id; - const file3 = `file2PF-${Utils.random()}.txt`; let file3Id; - const file4 = `file2PF-${Utils.random()}.txt`; let file4Id; - const file5 = `file2PF-${Utils.random()}.txt`; let file5Id; - const file6 = `file2PF-${Utils.random()}.txt`; let file6Id; - const file7 = `file2PF-${Utils.random()}.txt`; let file7Id; - const file8 = `file2PF-${Utils.random()}.txt`; let file8Id; - const file9 = `file2PF-${Utils.random()}.txt`; let file9Id; + const file1 = `file1-${Utils.random()}.txt`; let file1Id; + const file2 = `file2-${Utils.random()}.txt`; let file2Id; + const file3 = `file3-${Utils.random()}.txt`; let file3Id; + const file4 = `file4-${Utils.random()}.txt`; let file4Id; + const file5 = `file5-${Utils.random()}.txt`; let file5Id; + const file6 = `file6-${Utils.random()}.txt`; let file6Id; + const file7 = `file7-${Utils.random()}.txt`; let file7Id; + const file8 = `file8-${Utils.random()}.txt`; let file8Id; + const file9 = `file9-${Utils.random()}.txt`; let file9Id; beforeAll(async (done) => { file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; @@ -926,7 +914,7 @@ describe('Share a file', () => { done(); }); - xit('Share dialog default values - [C286666]', async () => { + it('Share dialog default values - [C286666]', async () => { await dataTable.selectItem(file1); await toolbar.openMoreMenu(); await toolbar.menu.clickMenuItem('Share'); @@ -937,13 +925,13 @@ describe('Share a file', () => { expect(await shareDialog.getLabels().get(0).getText()).toEqual('Link to share'); expect(await shareDialog.getLinkUrl()).toContain('/preview/s/'); expect(await shareDialog.isUrlReadOnly()).toBe('true', 'url is not readonly'); - expect(await shareDialog.isShareToggleEnabled()).toBe(true, 'Share toggle not checked'); + expect(await shareDialog.isShareToggleChecked()).toBe(true, 'Share toggle not checked'); expect(await shareDialog.getLabels().get(1).getText()).toEqual('Expires on'); expect(await shareDialog.isExpireToggleEnabled()).toBe(false, 'Expire toggle is checked'); expect(await shareDialog.closeButton.isEnabled()).toBe(true, 'Close button is not enabled'); }); - xit('Close dialog - [C286667]', async () => { + it('Close dialog - [C286667]', async () => { await dataTable.selectItem(file2); await toolbar.openMoreMenu(); await toolbar.menu.clickMenuItem('Share'); @@ -954,7 +942,7 @@ describe('Share a file', () => { expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog is open'); }); - xit('Share a file - [C286668]', async () => { + it('Share a file - [C286668]', async () => { await dataTable.selectItem(file3); await toolbar.openMoreMenu(); await toolbar.menu.clickMenuItem('Share'); @@ -963,17 +951,15 @@ describe('Share a file', () => { const url = await shareDialog.getLinkUrl(); await Utils.pressEscape(); const sharedId = await apis.user.nodes.getNodeProperty(file3Id, 'qshare:sharedId'); - - expect(sharedId).not.toBe(undefined, `${file3} is not shared`); + 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 apis.user.shared.waitForApi({ expect: 5 }); // await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); // expect(await dataTable.getRowByName(file3).isPresent()).toBe(true, `${file3} is not in the Shared files list`); }); - xit('Copy shared file URL - [C286669]', async () => { + it('Copy shared file URL - [C286669]', async () => { await dataTable.selectItem(file4); await toolbar.openMoreMenu(); await toolbar.menu.clickMenuItem('Share'); @@ -991,7 +977,7 @@ describe('Share a file', () => { await page.load(); }); - xit('Share a file with expiration date - [C286670]', async () => { + it('Share a file with expiration date - [C286670]', async () => { await dataTable.selectItem(file5); await toolbar.openMoreMenu(); await toolbar.menu.clickMenuItem('Share'); @@ -1013,10 +999,10 @@ describe('Share a file', () => { expect(Utils.formatDate(expireDateProperty)).toEqual(Utils.formatDate(inputDate)); }); - xit('Expire date is displayed correctly - [C286671]', async () => { + it('Expire date is displayed correctly - [C286671]', async () => { await dataTable.selectItem(file6); await toolbar.openMoreMenu(); - await toolbar.menu.clickMenuItem('Shared link settings'); + await toolbar.menu.clickMenuItem('Share'); await shareDialog.waitForDialogToOpen(); const expireProperty = await apis.user.nodes.getNodeProperty(file6Id, 'qshare:expiryDate'); @@ -1025,10 +1011,10 @@ describe('Share a file', () => { expect(Utils.formatDate(await shareDialog.getExpireDate())).toEqual(Utils.formatDate(expiryDate)); }); - xit('Disable the share link expiration - [C286672]', async () => { + it('Disable the share link expiration - [C286672]', async () => { await dataTable.selectItem(file7); await toolbar.openMoreMenu(); - await toolbar.menu.clickMenuItem('Shared link settings'); + await toolbar.menu.clickMenuItem('Share'); await shareDialog.waitForDialogToOpen(); expect(await shareDialog.isExpireToggleEnabled()).toBe(true, 'Expiration is not checked'); @@ -1042,7 +1028,7 @@ describe('Share a file', () => { expect(await apis.user.nodes.getNodeProperty(file7Id, 'qshare:expiryDate')).toBe(undefined, `${file7} link still has expiration`); }); - xit('Shared file URL is not changed when Share dialog is closed and opened again - [C286673]', async () => { + it('Shared file URL is not changed when Share dialog is closed and opened again - [C286673]', async () => { await dataTable.selectItem(file8); await toolbar.openMoreMenu(); await toolbar.menu.clickMenuItem('Share'); @@ -1054,14 +1040,14 @@ describe('Share a file', () => { await page.dataTable.clearSelection(); await dataTable.selectItem(file8); await toolbar.openMoreMenu(); - await toolbar.menu.clickMenuItem('Shared link settings'); + await toolbar.menu.clickMenuItem('Share'); await shareDialog.waitForDialogToOpen(); const url2 = await shareDialog.getLinkUrl(); expect(url1).toEqual(url2); }); - xit('Share a file from the context menu - [C286674]', async () => { + it('Share a file from the context menu - [C286674]', async () => { await dataTable.rightClickOnItem(file9); await contextMenu.clickMenuItem('Share'); await shareDialog.waitForDialogToOpen(); @@ -1069,12 +1055,10 @@ describe('Share a file', () => { const url = await shareDialog.getLinkUrl(); await Utils.pressEscape(); const sharedId = await apis.user.nodes.getNodeProperty(file9Id, 'qshare:sharedId'); - - expect(sharedId).not.toBe(undefined, `${file9} is not shared`); + 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 apis.user.shared.waitForApi({ expect: 5 }); // await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); // expect(await dataTable.getRowByName(file9).isPresent()).toBe(true, `${file9} is not in the Shared files list`); }); diff --git a/e2e/suites/actions/unshare-file.test.ts b/e2e/suites/actions/unshare-file.test.ts new file mode 100755 index 000000000..eaf3201b4 --- /dev/null +++ b/e2e/suites/actions/unshare-file.test.ts @@ -0,0 +1,816 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2018 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, LogoutPage, BrowsingPage } from '../../pages/pages'; +import { SIDEBAR_LABELS, 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', () => { + const username = `user-${Utils.random()}`; + + const parent = `parent-${Utils.random()}`; let parentId; + + const apis = { + admin: new RepoClient(), + user: new RepoClient(username, username) + }; + + const loginPage = new LoginPage(); + const logoutPage = new LogoutPage(); + const page = new BrowsingPage(); + const { dataTable, toolbar } = page; + const shareDialog = new ShareDialog(); + const confirmDialog = new ConfirmDialog(); + const contextMenu = dataTable.menu; + const viewer = new Viewer(); + + beforeAll(async (done) => { + await apis.admin.people.createUser({ username }); + parentId = (await apis.user.nodes.createFolder(parent)).entry.id; + await loginPage.loginWith(username); + done(); + }); + + afterAll(async (done) => { + await Promise.all([ + apis.user.nodes.deleteNodeById(parentId), + logoutPage.load() + ]); + done(); + }); + + describe('from Personal Files', () => { + + const file1 = `file1-${Utils.random()}.txt`; let file1Id; + const file2 = `file2-${Utils.random()}.txt`; let file2Id; + const file3 = `file3-${Utils.random()}.txt`; let file3Id; + const file4 = `file4-${Utils.random()}.txt`; let file4Id; + + beforeAll(async (done) => { + 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.user.shared.waitForApi({ expect: 4 }); + done(); + }); + + beforeEach(async (done) => { + await page.refresh(); + await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES); + await dataTable.waitForHeader(); + await dataTable.doubleClickOnRowByName(parent); + await dataTable.waitForHeader(); + done(); + }); + + afterEach(async (done) => { + await Utils.pressEscape(); + done(); + }); + + afterAll(async (done) => { + await apis.user.nodes.deleteNodeById(file1Id); + await apis.user.nodes.deleteNodeById(file2Id); + await apis.user.nodes.deleteNodeById(file3Id); + await apis.user.nodes.deleteNodeById(file4Id); + await apis.user.shared.waitForApi({ expect: 0 }); + done(); + }); + + it('Unshare dialog UI - [C286339]', async () => { + await dataTable.selectItem(file1); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Shared link settings'); + 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.isButtonEnabled('Remove')).toBe(true, 'REMOVE button is not enabled'); + expect(await confirmDialog.isButtonEnabled('Cancel')).toBe(true, 'CANCEL button is not enabled'); + }); + + it('Unshare a file - [C286340]', async () => { + await dataTable.selectItem(file2); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Shared link settings'); + await shareDialog.waitForDialogToOpen(); + await shareDialog.clickShareToggle(); + + const url = await shareDialog.getLinkUrl(); + await confirmDialog.clickButton('Remove'); + await confirmDialog.waitForDialogToClose(); + 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.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); + // expect(await dataTable.getRowByName(file2).isPresent()).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); + + await page.load(); + }); + + it('Cancel the Unshare action - [C286341]', async () => { + await dataTable.selectItem(file3); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Shared link settings'); + await shareDialog.waitForDialogToOpen(); + + const urlBefore = await shareDialog.getLinkUrl(); + await shareDialog.clickShareToggle(); + + await confirmDialog.clickButton('Cancel'); + 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 - [C286359]', async () => { + await dataTable.rightClickOnItem(file4); + await contextMenu.clickMenuItem('Shared link settings'); + await shareDialog.waitForDialogToOpen(); + await shareDialog.clickShareToggle(); + + const url = await shareDialog.getLinkUrl(); + await confirmDialog.clickButton('Remove'); + await confirmDialog.waitForDialogToClose(); + 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.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); + // expect(await dataTable.getRowByName(file4).isPresent()).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); + + await page.load(); + }); + }); + + describe('from File Libraries', () => { + + const file1 = `file1-${Utils.random()}.txt`; let file1Id; + const file2 = `file2-${Utils.random()}.txt`; let file2Id; + const file3 = `file3-${Utils.random()}.txt`; let file3Id; + const file4 = `file4-${Utils.random()}.txt`; let file4Id; + + const siteName = `site-${Utils.random()}`; + const parentInSite = `parent-site-${Utils.random()}`; let parentInSiteId; + + beforeAll(async (done) => { + await apis.user.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC); + const docLibId = await apis.user.sites.getDocLibId(siteName); + parentInSiteId = (await apis.user.nodes.createFolder(parentInSite, docLibId)).entry.id; + + file1Id = (await apis.user.nodes.createFile(file1, parentInSiteId)).entry.id; + file2Id = (await apis.user.nodes.createFile(file2, parentInSiteId)).entry.id; + file3Id = (await apis.user.nodes.createFile(file3, parentInSiteId)).entry.id; + file4Id = (await apis.user.nodes.createFile(file4, parentInSiteId)).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.user.shared.waitForApi({ expect: 4 }); + done(); + }); + + beforeEach(async (done) => { + await page.refresh(); + await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES); + await dataTable.waitForHeader(); + await dataTable.doubleClickOnRowByName(siteName); + await dataTable.waitForHeader(); + await dataTable.doubleClickOnRowByName(parentInSite); + await dataTable.waitForHeader(); + done(); + }); + + afterEach(async (done) => { + await Utils.pressEscape(); + done(); + }); + + afterAll(async (done) => { + await apis.admin.sites.deleteSite(siteName); + await apis.user.shared.waitForApi({ expect: 0 }); + done(); + }); + + it('Unshare dialog UI - [C286679]', async () => { + await dataTable.selectItem(file1); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Shared link settings'); + 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.isButtonEnabled('Remove')).toBe(true, 'REMOVE button is not enabled'); + expect(await confirmDialog.isButtonEnabled('Cancel')).toBe(true, 'CANCEL button is not enabled'); + }); + + it('Unshare a file - [C286680]', async () => { + await dataTable.selectItem(file2); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Shared link settings'); + await shareDialog.waitForDialogToOpen(); + await shareDialog.clickShareToggle(); + + const url = await shareDialog.getLinkUrl(); + await confirmDialog.clickButton('Remove'); + await confirmDialog.waitForDialogToClose(); + 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.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); + // expect(await dataTable.getRowByName(file2).isPresent()).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); + + await page.load(); + }); + + it('Cancel the Unshare action - [C286681]', async () => { + await dataTable.selectItem(file3); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Shared link settings'); + await shareDialog.waitForDialogToOpen(); + + const urlBefore = await shareDialog.getLinkUrl(); + await shareDialog.clickShareToggle(); + + await confirmDialog.clickButton('Cancel'); + 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 - [C286683]', async () => { + await dataTable.rightClickOnItem(file4); + await contextMenu.clickMenuItem('Shared link settings'); + await shareDialog.waitForDialogToOpen(); + await shareDialog.clickShareToggle(); + + const url = await shareDialog.getLinkUrl(); + await confirmDialog.clickButton('Remove'); + await confirmDialog.waitForDialogToClose(); + 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.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); + // expect(await dataTable.getRowByName(file4).isPresent()).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); + + await page.load(); + }); + }); + + describe('from Recent Files', () => { + + const file1 = `file1-${Utils.random()}.txt`; let file1Id; + const file2 = `file2-${Utils.random()}.txt`; let file2Id; + const file3 = `file3-${Utils.random()}.txt`; let file3Id; + const file4 = `file4-${Utils.random()}.txt`; let file4Id; + + beforeAll(async (done) => { + 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.user.shared.waitForApi({ expect: 4 }); + done(); + }); + + beforeEach(async (done) => { + await page.refresh(); + await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES); + await dataTable.waitForHeader(); + done(); + }); + + afterEach(async (done) => { + await Utils.pressEscape(); + done(); + }); + + afterAll(async (done) => { + await apis.user.nodes.deleteNodeById(file1Id); + await apis.user.nodes.deleteNodeById(file2Id); + await apis.user.nodes.deleteNodeById(file3Id); + await apis.user.nodes.deleteNodeById(file4Id); + await apis.user.shared.waitForApi({ expect: 0 }); + done(); + }); + + it('Unshare dialog UI - [C286689]', async () => { + await dataTable.selectItem(file1); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Shared link settings'); + 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.isButtonEnabled('Remove')).toBe(true, 'REMOVE button is not enabled'); + expect(await confirmDialog.isButtonEnabled('Cancel')).toBe(true, 'CANCEL button is not enabled'); + }); + + it('Unshare a file - [C286690]', async () => { + await dataTable.selectItem(file2); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Shared link settings'); + await shareDialog.waitForDialogToOpen(); + await shareDialog.clickShareToggle(); + + const url = await shareDialog.getLinkUrl(); + await confirmDialog.clickButton('Remove'); + await confirmDialog.waitForDialogToClose(); + 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.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); + // expect(await dataTable.getRowByName(file2).isPresent()).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); + + await page.load(); + }); + + it('Cancel the Unshare action - [C286691]', async () => { + await dataTable.selectItem(file3); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Shared link settings'); + await shareDialog.waitForDialogToOpen(); + + const urlBefore = await shareDialog.getLinkUrl(); + await shareDialog.clickShareToggle(); + + await confirmDialog.clickButton('Cancel'); + 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 - [C286693]', async () => { + await dataTable.rightClickOnItem(file4); + await contextMenu.clickMenuItem('Shared link settings'); + await shareDialog.waitForDialogToOpen(); + await shareDialog.clickShareToggle(); + + const url = await shareDialog.getLinkUrl(); + await confirmDialog.clickButton('Remove'); + await confirmDialog.waitForDialogToClose(); + 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.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); + // expect(await dataTable.getRowByName(file4).isPresent()).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); + + await page.load(); + }); + }); + + describe('from Shared Files', () => { + + const file1 = `file1-${Utils.random()}.txt`; let file1Id; + const file2 = `file2-${Utils.random()}.txt`; let file2Id; + const file3 = `file3-${Utils.random()}.txt`; let file3Id; + const file4 = `file4-${Utils.random()}.txt`; let file4Id; + + beforeAll(async (done) => { + 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.user.shared.waitForApi({ expect: 4 }); + done(); + }); + + beforeEach(async (done) => { + await page.refresh(); + await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); + await dataTable.waitForHeader(); + done(); + }); + + afterEach(async (done) => { + await Utils.pressEscape(); + done(); + }); + + afterAll(async (done) => { + await apis.user.nodes.deleteNodeById(file1Id); + await apis.user.nodes.deleteNodeById(file2Id); + await apis.user.nodes.deleteNodeById(file3Id); + await apis.user.nodes.deleteNodeById(file4Id); + await apis.user.shared.waitForApi({ expect: 0 }); + done(); + }); + + it('Unshare dialog UI - [C286684]', async () => { + await dataTable.selectItem(file1); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Shared link settings'); + 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.isButtonEnabled('Remove')).toBe(true, 'REMOVE button is not enabled'); + expect(await confirmDialog.isButtonEnabled('Cancel')).toBe(true, 'CANCEL button is not enabled'); + }); + + it('Unshare a file - [C286685]', async () => { + await dataTable.selectItem(file2); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Shared link settings'); + await shareDialog.waitForDialogToOpen(); + await shareDialog.clickShareToggle(); + + const url = await shareDialog.getLinkUrl(); + await confirmDialog.clickButton('Remove'); + await confirmDialog.waitForDialogToClose(); + 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 + // expect(await dataTable.getRowByName(file2).isPresent()).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); + + await page.load(); + }); + + it('Cancel the Unshare action - [C286686]', async () => { + await dataTable.selectItem(file3); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Shared link settings'); + await shareDialog.waitForDialogToOpen(); + + const urlBefore = await shareDialog.getLinkUrl(); + await shareDialog.clickShareToggle(); + + await confirmDialog.clickButton('Cancel'); + 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 - [C286688]', async () => { + await dataTable.rightClickOnItem(file4); + await contextMenu.clickMenuItem('Shared link settings'); + await shareDialog.waitForDialogToOpen(); + await shareDialog.clickShareToggle(); + + const url = await shareDialog.getLinkUrl(); + await confirmDialog.clickButton('Remove'); + await confirmDialog.waitForDialogToClose(); + 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 + // expect(await dataTable.getRowByName(file4).isPresent()).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); + + await page.load(); + }); + }); + + describe('from Favorites', () => { + + const file1 = `file1-${Utils.random()}.txt`; let file1Id; + const file2 = `file2-${Utils.random()}.txt`; let file2Id; + const file3 = `file3-${Utils.random()}.txt`; let file3Id; + const file4 = `file4-${Utils.random()}.txt`; let file4Id; + + beforeAll(async (done) => { + 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.user.favorites.addFavoriteById('file', file1Id); + await apis.user.favorites.addFavoriteById('file', file2Id); + await apis.user.favorites.addFavoriteById('file', file3Id); + await apis.user.favorites.addFavoriteById('file', file4Id); + + await apis.user.favorites.waitForApi({ expect: 4 }); + await apis.user.shared.waitForApi({ expect: 4 }); + done(); + }); + + beforeEach(async (done) => { + await page.refresh(); + await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES); + await dataTable.waitForHeader(); + done(); + }); + + afterEach(async (done) => { + await Utils.pressEscape(); + done(); + }); + + afterAll(async (done) => { + await apis.user.nodes.deleteNodeById(file1Id); + await apis.user.nodes.deleteNodeById(file2Id); + await apis.user.nodes.deleteNodeById(file3Id); + await apis.user.nodes.deleteNodeById(file4Id); + await apis.user.shared.waitForApi({ expect: 0 }); + done(); + }); + + it('Unshare dialog UI - [C286694]', async () => { + await dataTable.selectItem(file1); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Share'); + 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.isButtonEnabled('Remove')).toBe(true, 'REMOVE button is not enabled'); + expect(await confirmDialog.isButtonEnabled('Cancel')).toBe(true, 'CANCEL button is not enabled'); + }); + + it('Unshare a file - [C286695]', async () => { + await dataTable.selectItem(file2); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Share'); + await shareDialog.waitForDialogToOpen(); + await shareDialog.clickShareToggle(); + + const url = await shareDialog.getLinkUrl(); + await confirmDialog.clickButton('Remove'); + await confirmDialog.waitForDialogToClose(); + 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.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); + // expect(await dataTable.getRowByName(file2).isPresent()).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); + + await page.load(); + }); + + it('Cancel the Unshare action - [C286696]', async () => { + await dataTable.selectItem(file3); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Share'); + await shareDialog.waitForDialogToOpen(); + + const urlBefore = await shareDialog.getLinkUrl(); + await shareDialog.clickShareToggle(); + + await confirmDialog.clickButton('Cancel'); + 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 - [C286698]', async () => { + await dataTable.rightClickOnItem(file4); + await contextMenu.clickMenuItem('Share'); + await shareDialog.waitForDialogToOpen(); + await shareDialog.clickShareToggle(); + + const url = await shareDialog.getLinkUrl(); + await confirmDialog.clickButton('Remove'); + await confirmDialog.waitForDialogToClose(); + 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.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); + // expect(await dataTable.getRowByName(file4).isPresent()).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); + + await page.load(); + }); + }); + + describe('as Consumer', () => { + + const sitePrivate = `site-private-${Utils.random()}`; + + const file1 = `file1-${Utils.random()}.txt`; let file1Id; + const file2 = `file2-${Utils.random()}.txt`; let file2Id; + + 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; + + await apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONSUMER); + + await apis.admin.shared.shareFileById(file1Id); + await apis.user.shared.shareFileById(file2Id); + await apis.user.shared.waitForApi({ expect: 2 }); + + await apis.user.favorites.addFavoriteById('file', file1Id); + await apis.user.favorites.addFavoriteById('file', file2Id); + await apis.user.favorites.waitForApi({ expect: 2 }); + + done(); + }); + + afterAll(async (done) => { + await apis.admin.sites.deleteSite(sitePrivate); + done(); + }); + + beforeEach(async (done) => { + await page.refresh(); + done(); + }); + + afterEach(async (done) => { + await Utils.pressEscape(); + done(); + }); + + // TODO: ACA-1911 + xit('on File Libraries - file shared by other user - [C286682]', async () => { + await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES); + await dataTable.waitForHeader(); + await dataTable.doubleClickOnRowByName(sitePrivate); + await dataTable.waitForHeader(); + await dataTable.selectItem(file1); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Shared link settings'); + await shareDialog.waitForDialogToOpen(); + + expect(await shareDialog.isShareToggleEnabled()).toBe(false, 'Share toggle enabled for consumer'); + }); + + it('on File Libraries - file shared by the user - [C286701]', async () => { + await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES); + await dataTable.waitForHeader(); + await dataTable.doubleClickOnRowByName(sitePrivate); + await dataTable.waitForHeader(); + await dataTable.selectItem(file2); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Shared link settings'); + await shareDialog.waitForDialogToOpen(); + + expect(await shareDialog.isShareToggleEnabled()).toBe(true, 'Share toggle disabled for consumer'); + }); + + // TODO: ACA-1911 + xit('on Shared Files - file shared by other user - [C286687]', async () => { + await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); + await dataTable.waitForHeader(); + await dataTable.selectItem(file1); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Shared link settings'); + await shareDialog.waitForDialogToOpen(); + + expect(await shareDialog.isShareToggleEnabled()).toBe(false, 'Share toggle enabled for consumer'); + }); + + it('on Shared Files - file shared by the user - [C286702]', async () => { + await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES); + await dataTable.waitForHeader(); + await dataTable.selectItem(file1); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Shared link settings'); + await shareDialog.waitForDialogToOpen(); + + expect(await shareDialog.isShareToggleEnabled()).toBe(true, 'Share toggle disabled for consumer'); + }); + + // TODO: ACA-1911 + xit('on Favorites - file shared by other user - [C286697]', async () => { + await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES); + await dataTable.waitForHeader(); + await dataTable.selectItem(file1); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Share'); + await shareDialog.waitForDialogToOpen(); + + expect(await shareDialog.isShareToggleEnabled()).toBe(false, 'Share toggle enabled for consumer'); + }); + + it('on Favorites - file shared by the user - [C286703]', async () => { + await page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES); + await dataTable.waitForHeader(); + await dataTable.selectItem(file1); + await toolbar.openMoreMenu(); + await toolbar.menu.clickMenuItem('Share'); + await shareDialog.waitForDialogToOpen(); + + expect(await shareDialog.isShareToggleEnabled()).toBe(true, 'Share toggle disabled for consumer'); + }); + }); + + xit(''); +}); diff --git a/e2e/utilities/repo-client/apis/nodes/nodes-api.ts b/e2e/utilities/repo-client/apis/nodes/nodes-api.ts index 234a0472c..58a7934ac 100755 --- a/e2e/utilities/repo-client/apis/nodes/nodes-api.ts +++ b/e2e/utilities/repo-client/apis/nodes/nodes-api.ts @@ -55,7 +55,15 @@ export class NodesApi extends RepoApi { } async getNodeProperty(nodeId: string, property: string) { - return (await this.getNodeById(nodeId)).entry.properties[property]; + const node = await this.getNodeById(nodeId); + if (node.entry.properties) { + return node.entry.properties[property]; + } + return ''; + } + + async isFileShared(nodeId: string) { + return (await this.getNodeProperty(nodeId, 'qshare:sharedId')) !== ''; } async deleteNodeById(id: string, permanent: boolean = true) {