From 7667c98196dc43a9e30cfe1c48e234448c0b542c Mon Sep 17 00:00:00 2001 From: Rafal Szmit <40626242+rafalszmit@users.noreply.github.com> Date: Thu, 24 Nov 2022 10:28:45 +0100 Subject: [PATCH] [AAE-11437] Remove snackbar duplications (#8003) * [AAE-11437] Remove snackbar duplications * trigger travis * extend timeout --- .../components/permissions-component.e2e.ts | 30 +++++++++++-------- .../components/site-permissions.e2e.ts | 11 ++++--- e2e/core/notifications-component.e2e.ts | 20 ++++++------- e2e/core/pages/notification.page.ts | 12 -------- .../protractor/core/pages/snackbar.page.ts | 2 +- 5 files changed, 35 insertions(+), 40 deletions(-) diff --git a/e2e/content-services/components/permissions-component.e2e.ts b/e2e/content-services/components/permissions-component.e2e.ts index a215a2e038..efc0700a78 100644 --- a/e2e/content-services/components/permissions-component.e2e.ts +++ b/e2e/content-services/components/permissions-component.e2e.ts @@ -88,7 +88,11 @@ describe('Permissions Component', () => { const roleContributorFolderModel = new FolderModel({ name: 'roleContributor' + StringUtil.generateRandomString() }); const roleEditorFolderModel = new FolderModel({ name: 'roleEditor' + StringUtil.generateRandomString() }); - let roleConsumerFolder, roleCoordinatorFolder, roleContributorFolder, roleCollaboratorFolder, roleEditorFolder; + let roleConsumerFolder; + let roleCoordinatorFolder; + let roleContributorFolder; + let roleCollaboratorFolder; + let roleEditorFolder; beforeAll(async () => { try { @@ -173,7 +177,7 @@ describe('Permissions Component', () => { await permissionsPage.addPermissionsDialog.selectRole(groupBody.displayName, 'Consumer'); await expect(await permissionsPage.addPermissionsDialog.addButtonIsEnabled()).toBe(true, 'button should be enabled'); await permissionsPage.addPermissionsDialog.clickAddButton(); - await expect(await notificationPage.getSnackBarMessage()).toEqual('Added 0 user(s) 1 group(s)'); + await expect(await notificationPage.snackbarPage.getSnackBarMessage()).toEqual('Added 0 user(s) 1 group(s)'); await permissionsPage.checkUserIsAdded(groupBody.id); }); @@ -194,8 +198,8 @@ describe('Permissions Component', () => { await permissionsPage.checkPermissionListDisplayed(); await expect(await permissionsPage.isInherited()).toBe(true, 'Inherited permission should be on'); await permissionsPage.toggleInheritPermission(); - await expect(await notificationPage.getSnackBarMessage()).toContain('Disabled inherited permission', 'Disabled notification not shown'); - await notificationPage.waitForSnackBarToClose(); + await expect(await notificationPage.snackbarPage.getSnackBarMessage()).toContain('Disabled inherited permission', 'Disabled notification not shown'); + await notificationPage.snackbarPage.waitForSnackBarToClose(); await expect(await permissionsPage.isInherited()).toBe(false, 'Inherited permission should be off'); }); }); @@ -222,8 +226,8 @@ describe('Permissions Component', () => { await permissionsPage.addPermissionsDialog.selectRole(filePermissionUser.fullName, 'Contributor'); await expect(await permissionsPage.addPermissionsDialog.addButtonIsEnabled()).toBe(true, 'button should be enabled'); await permissionsPage.addPermissionsDialog.clickAddButton(); - await expect(await notificationPage.getSnackBarMessage()).toEqual('Added 1 user(s) 0 group(s)'); - await notificationPage.waitForSnackBarToClose(); + await expect(await notificationPage.snackbarPage.getSnackBarMessage()).toEqual('Added 1 user(s) 0 group(s)'); + await notificationPage.snackbarPage.waitForSnackBarToClose(); await permissionsPage.checkUserIsAdded(filePermissionUser.username); }); @@ -246,19 +250,19 @@ describe('Permissions Component', () => { await BrowserActions.closeMenuAndDialogs(); await permissionsPage.changePermission(filePermissionUser.username, 'Collaborator'); - await notificationPage.waitForSnackBarToClose(); + await notificationPage.snackbarPage.waitForSnackBarToClose(); await expect(await permissionsPage.getRoleCellValue(filePermissionUser.username)).toEqual('Collaborator'); await permissionsPage.changePermission(filePermissionUser.username, 'Coordinator'); - await notificationPage.waitForSnackBarToClose(); + await notificationPage.snackbarPage.waitForSnackBarToClose(); await expect(await permissionsPage.getRoleCellValue(filePermissionUser.username)).toEqual('Coordinator'); await permissionsPage.changePermission(filePermissionUser.username, 'Editor'); - await notificationPage.waitForSnackBarToClose(); + await notificationPage.snackbarPage.waitForSnackBarToClose(); await expect(await permissionsPage.getRoleCellValue(filePermissionUser.username)).toEqual('Editor'); await permissionsPage.changePermission(filePermissionUser.username, 'Consumer'); - await notificationPage.waitForSnackBarToClose(); + await notificationPage.snackbarPage.waitForSnackBarToClose(); await expect(await permissionsPage.getRoleCellValue(filePermissionUser.username)).toEqual('Consumer'); }); @@ -277,7 +281,7 @@ describe('Permissions Component', () => { await expect(await permissionsPage.getRoleCellValue(filePermissionUser.username)).toEqual('Contributor'); await permissionsPage.clickDeletePermissionButton(filePermissionUser.username); await permissionsPage.checkUserIsDeleted(filePermissionUser.username); - await expect(await notificationPage.getSnackBarMessage()).toEqual('User/Group deleted'); + await expect(await notificationPage.snackbarPage.getSnackBarMessage()).toEqual('User/Group deleted'); }); }); @@ -299,11 +303,11 @@ describe('Permissions Component', () => { await BrowserActions.closeMenuAndDialogs(); await contentList.checkActionMenuIsNotDisplayed(); await contentServicesPage.metadataContent('RoleConsumer' + fileModel.name); - await expect(await notificationPage.getSnackBarMessage()).toEqual('You don\'t have access to do this.'); + await expect(await notificationPage.snackbarPage.getSnackBarMessage()).toEqual('You don\'t have access to do this.'); await notificationHistoryPage.checkNotifyContains('You don\'t have access to do this.'); await browser.sleep(3000); await contentServicesPage.uploadFile(fileLocation); - await expect(await notificationPage.getSnackBarMessage()).toEqual('You don\'t have the create permission to upload the content'); + await expect(await notificationPage.snackbarPage.getSnackBarMessage()).toEqual('You don\'t have the create permission to upload the content'); await notificationHistoryPage.checkNotifyContains('You don\'t have the create permission to upload the content'); }); diff --git a/e2e/content-services/components/site-permissions.e2e.ts b/e2e/content-services/components/site-permissions.e2e.ts index dffaf25b92..3049fc287d 100644 --- a/e2e/content-services/components/site-permissions.e2e.ts +++ b/e2e/content-services/components/site-permissions.e2e.ts @@ -57,7 +57,9 @@ describe('Permissions Component', () => { const contentList = contentServicesPage.getDocumentList(); - let publicSite, privateSite, folderName; + let publicSite; + let privateSite; + let folderName; const fileModel = new FileModel({ name: browser.params.resources.Files.ADF_DOCUMENTS.TXT_0B.file_name, @@ -79,7 +81,8 @@ describe('Permissions Component', () => { location: browser.params.resources.Files.ADF_DOCUMENTS.PNG_B.file_location }); - let siteFolder, privateSiteFile; + let siteFolder; + let privateSiteFile; const folderOwnerUser = new UserModel(); const consumerUser: UserModel = new UserModel(); @@ -210,8 +213,8 @@ describe('Permissions Component', () => { await expect(await permissionsPage.addPermissionsDialog.getRoleCellValue(consumerUser.fullName)).toEqual('Site Collaborator'); await expect(await permissionsPage.addPermissionsDialog.addButtonIsEnabled()).toBe(true, 'Add button should be enabled'); await permissionsPage.addPermissionsDialog.clickAddButton(); - await expect(await notificationPage.getSnackBarMessage()).toEqual('Added 1 user(s) 0 group(s)'); - await notificationPage.waitForSnackBarToClose(); + await expect(await notificationPage.snackbarPage.getSnackBarMessage()).toEqual('Added 1 user(s) 0 group(s)'); + await notificationPage.snackbarPage.waitForSnackBarToClose(); await permissionsPage.checkUserIsAdded(consumerUser.username); diff --git a/e2e/core/notifications-component.e2e.ts b/e2e/core/notifications-component.e2e.ts index bc67966345..8db548da4a 100644 --- a/e2e/core/notifications-component.e2e.ts +++ b/e2e/core/notifications-component.e2e.ts @@ -51,27 +51,27 @@ describe('Notifications Component', () => { }); afterEach(async () => { - await notificationPage.waitForSnackBarToClose(); + await notificationPage.snackbarPage.waitForSnackBarToClose(); await browser.executeScript(`document.querySelector('button[data-automation-id="notification-custom-dismiss-button"]').click();`); }); it('[C279979] Should not show notification when the message is empty and button is clicked', async () => { await notificationPage.clearMessage(); await notificationPage.clickNotificationButton(); - await expect(await notificationPage.isNotificationSnackBarDisplayed()).toEqual(false); + await expect(await notificationPage.snackbarPage.isNotificationSnackBarDisplayed()).toEqual(false); }); it('[C279977] Should show notification when the message is not empty and button is clicked', async () => { await notificationPage.enterMessageField('test'); await notificationPage.clickNotificationButton(); - await expect(await notificationPage.getSnackBarMessage()).toEqual('test'); + await expect(await notificationPage.snackbarPage.getSnackBarMessage()).toEqual('test'); }); it('[C279978] Should show notification with action when the message is not empty and button is clicked', async () => { await notificationPage.enterMessageField('test'); await notificationPage.clickActionToggle(); await notificationPage.clickNotificationButton(); - await expect(await notificationPage.getSnackBarMessage()).toEqual('test'); + await expect(await notificationPage.snackbarPage.getSnackBarMessage()).toEqual('test'); await notificationPage.clickActionButton(); await notificationPage.checkActionEvent(); await notificationPage.clickActionToggle(); @@ -80,16 +80,16 @@ describe('Notifications Component', () => { it('[C279981] Should show notification with action when the message is not empty and custom configuration button is clicked', async () => { await notificationPage.enterMessageField('test'); await notificationPage.clickNotificationButton(); - await expect(await notificationPage.isNotificationSnackBarDisplayed()).toEqual(true); + await expect(await notificationPage.snackbarPage.isNotificationSnackBarDisplayed()).toEqual(true); }); it('[C280000] Should show notification with action when the message is not empty and custom button is clicked', async () => { await notificationPage.enterMessageField('test'); await notificationPage.clickActionToggle(); await notificationPage.clickNotificationButton(); - await expect(await notificationPage.isNotificationSnackBarDisplayed()).toEqual(true); - await expect(await notificationPage.getSnackBarMessage()).toEqual('test'); - await notificationPage.waitForSnackBarToClose(); + await expect(await notificationPage.snackbarPage.isNotificationSnackBarDisplayed()).toEqual(true); + await expect(await notificationPage.snackbarPage.getSnackBarMessage()).toEqual('test'); + await notificationPage.snackbarPage.waitForSnackBarToClose(); await notificationPage.clickNotificationButton(); await notificationPage.clickActionButton(); await notificationPage.checkActionEvent(); @@ -100,9 +100,9 @@ describe('Notifications Component', () => { await notificationPage.enterMessageField('test'); await notificationPage.enterDurationField(1000); await notificationPage.clickNotificationButton(); - await expect(await notificationPage.isNotificationSnackBarDisplayed()).toEqual(true); + await expect(await notificationPage.snackbarPage.isNotificationSnackBarDisplayed()).toEqual(true); await browser.sleep(2000); - await expect(await notificationPage.isNotificationSnackBarDisplayed()).toEqual(false); + await expect(await notificationPage.snackbarPage.isNotificationSnackBarDisplayed()).toEqual(false); }); it('[C280001] Should meet configuration when a custom notification is set', async () => { diff --git a/e2e/core/pages/notification.page.ts b/e2e/core/pages/notification.page.ts index a247cbc078..785573e1d1 100644 --- a/e2e/core/pages/notification.page.ts +++ b/e2e/core/pages/notification.page.ts @@ -46,18 +46,6 @@ export class NotificationDemoPage { return BrowserActions.getText(this.notificationConfig); } - async isNotificationSnackBarDisplayed(): Promise { - return this.snackbarPage.isNotificationSnackBarDisplayed(); - } - - async getSnackBarMessage(): Promise { - return this.snackbarPage.getSnackBarMessage(); - } - - async waitForSnackBarToClose(): Promise { - await this.snackbarPage.waitForSnackBarToClose(15000); - } - async enterMessageField(text: string): Promise { await BrowserActions.clearSendKeys(this.messageField, text); } diff --git a/lib/testing/src/lib/protractor/core/pages/snackbar.page.ts b/lib/testing/src/lib/protractor/core/pages/snackbar.page.ts index 64e35d5cea..4a86178e6c 100644 --- a/lib/testing/src/lib/protractor/core/pages/snackbar.page.ts +++ b/lib/testing/src/lib/protractor/core/pages/snackbar.page.ts @@ -31,7 +31,7 @@ export class SnackbarPage { ); } - async waitForSnackBarToClose(timeout = 5000) { + async waitForSnackBarToClose(timeout = 15000) { return BrowserVisibility.waitUntilElementIsNotVisible(this.snackBarContainerCss.first(), timeout); }