From 809f4c06d3fc0d80df7658841c44993995de98d2 Mon Sep 17 00:00:00 2001 From: jdosti Date: Tue, 10 Jul 2018 17:26:01 +0100 Subject: [PATCH] [ADF-3022] Create automated test for attachment list - processes (#3575) --- e2e/attachment-list-process.e2e.ts | 5 +- .../process_services/attachmentListPage.js | 42 ---- .../process_services/attachmentListPage.ts | 101 ++++++++++ e2e/process_attachmentList_actionMenu.e2e.ts | 190 ++++++++++++++++++ e2e/start_process_component.e2e.ts | 2 +- e2e/start_task_custom_app.e2e.ts | 2 +- e2e/start_task_task_app.e2e.ts | 2 +- 7 files changed, 297 insertions(+), 47 deletions(-) delete mode 100644 e2e/pages/adf/process_services/attachmentListPage.js create mode 100644 e2e/pages/adf/process_services/attachmentListPage.ts create mode 100644 e2e/process_attachmentList_actionMenu.e2e.ts diff --git a/e2e/attachment-list-process.e2e.ts b/e2e/attachment-list-process.e2e.ts index f4f2c08dd2..75e539b7d8 100644 --- a/e2e/attachment-list-process.e2e.ts +++ b/e2e/attachment-list-process.e2e.ts @@ -18,8 +18,9 @@ import LoginPage = require('./pages/adf/loginPage'); import ProcessServicesPage = require('./pages/adf/process_services/processServicesPage'); import ProcessFiltersPage = require('./pages/adf/process_services/processFiltersPage'); -import AttachmentListPage = require('./pages/adf/process_services/attachmentListPage'); import FileModel = require('./models/ACS/fileModel'); +import { AttachmentListPage } from './pages/adf/process_services/attachmentListPage'; + import TestConfig = require('./test.config'); import resources = require('./util/resources'); @@ -43,7 +44,7 @@ describe('Attachment list', () => { }); let pdfFile = new FileModel({ 'name': resources.Files.ADF_DOCUMENTS.PDF.file_name }); - beforeAll(async (done) => { + beforeAll(async(done) => { let users = new UsersActions(); let apps = new AppsActions(); diff --git a/e2e/pages/adf/process_services/attachmentListPage.js b/e2e/pages/adf/process_services/attachmentListPage.js deleted file mode 100644 index d7a7dd5ff6..0000000000 --- a/e2e/pages/adf/process_services/attachmentListPage.js +++ /dev/null @@ -1,42 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var Util = require('../../../util/util'); -var TestConfig = require('../../../test.config'); -var path = require('path'); - -var AttachmentListPage = function () { - - var attachFileButton = element(by.css("input[type='file']")); - - this.clickAttachFileButton = function (fileLocation) { - Util.waitUntilElementIsVisible(attachFileButton); - attachFileButton.sendKeys(path.resolve(path.join(TestConfig.main.rootPath, fileLocation))); - }; - - this.checkFileIsAttached = function (name) { - var fileAttached = element.all(by.css('div[filename="'+name+'"]')).first(); - Util.waitUntilElementIsVisible(fileAttached); - - }; - - this.checkAttachFileButtonIsNotDisplayed = function () { - Util.waitUntilElementIsNotVisible(attachFileButton); - }; - -}; -module.exports = AttachmentListPage; diff --git a/e2e/pages/adf/process_services/attachmentListPage.ts b/e2e/pages/adf/process_services/attachmentListPage.ts new file mode 100644 index 0000000000..ef0aafe72b --- /dev/null +++ b/e2e/pages/adf/process_services/attachmentListPage.ts @@ -0,0 +1,101 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Util = require('../../../util/util'); +import TestConfig = require('../../../test.config'); +import path = require('path'); + +export class AttachmentListPage { + + attachFileButton = element(by.css("input[type='file']")); + buttonMenu = element(by.css("button[data-automation-id='action_menu_0']")); + menuPanel = element(by.css("div[class*='mat-menu-panel'] div[class*='mat-menu-content']")); + viewButton = element(by.css("button[data-automation-id*='MENU_ACTIONS.VIEW_CONTENT']")); + removeButton = element(by.css("button[data-automation-id*='MENU_ACTIONS.REMOVE_CONTENT']")); + downloadButton = element(by.css("button[data-automation-id*='MENU_ACTIONS.DOWNLOAD_CONTENT']")); + noContentContainer = element(by.css("div[class*='adf-no-content-container']")); + + checkEmptyAttachmentList() { + Util.waitUntilElementIsVisible(this.noContentContainer); + } + + clickAttachFileButton(fileLocation) { + Util.waitUntilElementIsVisible(this.attachFileButton); + this.attachFileButton.sendKeys(path.resolve(path.join(TestConfig.main.rootPath, fileLocation))); + } + + checkFileIsAttached(name) { + let fileAttached = element(by.css('div[filename="' + name + '"]')); + Util.waitUntilElementIsVisible(fileAttached); + } + + checkAttachFileButtonIsNotDisplayed() { + Util.waitUntilElementIsNotVisible(this.attachFileButton); + } + + viewFile(name) { + let fileAttached = element(by.css('div[filename="' + name + '"]')); + Util.waitUntilElementIsVisible(fileAttached); + fileAttached.click(); + Util.waitUntilElementIsVisible(this.buttonMenu); + Util.waitUntilElementIsClickable(this.buttonMenu); + this.buttonMenu.click(); + Util.waitUntilElementIsVisible(this.menuPanel); + Util.waitUntilElementIsVisible(this.viewButton); + this.viewButton.click(); + return this; + } + + removeFile(name) { + let fileAttached = element(by.css('div[filename="' + name + '"]')); + fileAttached.click(); + Util.waitUntilElementIsVisible(this.buttonMenu); + Util.waitUntilElementIsClickable(this.buttonMenu); + this.buttonMenu.click(); + Util.waitUntilElementIsVisible(this.menuPanel); + Util.waitUntilElementIsVisible(this.removeButton); + this.removeButton.click(); + return this; + } + + downloadFile(name) { + let fileAttached = element(by.css('div[filename="' + name + '"]')); + fileAttached.click(); + Util.waitUntilElementIsVisible(this.buttonMenu); + Util.waitUntilElementIsClickable(this.buttonMenu); + this.buttonMenu.click(); + Util.waitUntilElementIsVisible(this.menuPanel); + Util.waitUntilElementIsVisible(this.downloadButton); + this.downloadButton.click(); + return this; + } + + doubleClickFile(name) { + let fileAttached = element(by.css('div[filename="' + name + '"]')); + Util.waitUntilElementIsVisible(fileAttached); + Util.waitUntilElementIsClickable(fileAttached); + fileAttached.click(); + browser.actions().sendKeys(protractor.Key.ENTER).perform(); + } + + checkFileIsRemoved(name) { + let fileAttached = element(by.css('div[filename="' + name + '"]')); + Util.waitUntilElementIsNotVisible(fileAttached); + return this; + } + +} diff --git a/e2e/process_attachmentList_actionMenu.e2e.ts b/e2e/process_attachmentList_actionMenu.e2e.ts new file mode 100644 index 0000000000..83c4cbf2b8 --- /dev/null +++ b/e2e/process_attachmentList_actionMenu.e2e.ts @@ -0,0 +1,190 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import LoginPage = require('./pages/adf/loginPage'); +import ProcessServicesPage = require('./pages/adf/process_services/processServicesPage'); +import ProcessFiltersPage = require('./pages/adf/process_services/processFiltersPage.js'); +import ProcessDetailsPage = require('./pages/adf/process_services/processDetailsPage.js'); +import { AttachmentListPage } from './pages/adf/process_services/attachmentListPage'; +import ViewerPage = require('./pages/adf/viewerPage.js'); + +import CONSTANTS = require('./util/constants'); + +import TestConfig = require('./test.config'); +import resources = require('./util/resources'); +import Util = require('./util/util.js'); + +import path = require('path'); + +import AlfrescoApi = require('alfresco-js-api-node'); +import {UsersActions} from './actions/users.actions'; +import {AppsActions} from './actions/APS/apps.actions'; +import FileModel = require('./models/ACS/fileModel'); + +describe('Attachment list action menu for processes', () => { + + let loginPage = new LoginPage(); + let processServicesPage = new ProcessServicesPage(); + let processFiltersPage = new ProcessFiltersPage(); + let processDetailsPage = new ProcessDetailsPage(); + let attachmentListPage = new AttachmentListPage(); + let viewerPage = new ViewerPage(); + let app = resources.Files.SIMPLE_APP_WITH_USER_FORM; + let jpgFile = new FileModel({ + location: resources.Files.ADF_DOCUMENTS.JPG.file_location, + name: resources.Files.ADF_DOCUMENTS.JPG.file_name + }); + + let downloadedJpgFile = path.join(__dirname, 'downloads', jpgFile.name); + let tenantId, appId; + let processName = { + active: 'Active Process', + completed: 'Completed Process', + taskApp: 'Task App Name', + emptyList: 'Empty List', + dragDrop: 'Drag and Drop' + }; + + beforeAll(async(done) => { + let apps = new AppsActions(); + let users = new UsersActions(); + + this.alfrescoJsApi = new AlfrescoApi({ + provider: 'BPM', + hostBpm: TestConfig.adf.url + }); + + await this.alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword); + + let user = await users.createTenantAndUser(this.alfrescoJsApi); + + tenantId = user.tenantId; + + await this.alfrescoJsApi.login(user.email, user.password); + + let importedApp = await apps.importPublishDeployApp(this.alfrescoJsApi, app.file_location); + appId = importedApp.id; + + await apps.startProcess(this.alfrescoJsApi, importedApp, processName.completed); + await apps.startProcess(this.alfrescoJsApi, importedApp, processName.active); + await apps.startProcess(this.alfrescoJsApi, 'Task App', processName.taskApp); + await apps.startProcess(this.alfrescoJsApi, 'Task App', processName.emptyList); + await apps.startProcess(this.alfrescoJsApi, 'Task App', processName.dragDrop); + + await loginPage.loginToProcessServicesUsingUserModel(user); + + done(); + }); + + afterAll(async(done) => { + await this.alfrescoJsApi.activiti.modelsApi.deleteModel(appId); + await this.alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword); + await this.alfrescoJsApi.activiti.adminTenantsApi.deleteTenant(tenantId); + done(); + }); + + it('[C260228] Option menu functionality - Active Process', () => { + processServicesPage.goToProcessServices().goToApp(app.title).clickProcessButton(); + + processFiltersPage.selectFromProcessList(processName.active); + + processDetailsPage.checkProcessTitleIsDisplayed(); + + attachmentListPage.clickAttachFileButton(jpgFile.location); + attachmentListPage.viewFile(jpgFile.name); + + viewerPage.checkFileNameIsDisplayed(jpgFile.name); + viewerPage.clickCloseButton(); + + processFiltersPage.clickRunningFilterButton(); + processFiltersPage.selectFromProcessList(processName.active); + + attachmentListPage.doubleClickFile(jpgFile.name); + + viewerPage.checkFileNameIsDisplayed(jpgFile.name); + viewerPage.clickCloseButton(); + + processFiltersPage.clickRunningFilterButton(); + processFiltersPage.selectFromProcessList(processName.active); + + attachmentListPage.downloadFile(jpgFile.name); + + expect(Util.fileExists(downloadedJpgFile, 20)).toBe(true); + + attachmentListPage.removeFile(jpgFile.name); + attachmentListPage.checkFileIsRemoved(jpgFile.name); + }); + + it('[C279886Edit] Option menu functionality - Completed Process', () => { + processServicesPage.goToProcessServices().goToApp(app.title).clickProcessButton(); + + processFiltersPage.clickRunningFilterButton(); + processFiltersPage.selectFromProcessList(processName.completed); + + processDetailsPage.checkProcessTitleIsDisplayed(); + + attachmentListPage.clickAttachFileButton(jpgFile.location); + + processDetailsPage.clickCancelProcessButton(); + + processFiltersPage.clickCompletedFilterButton(); + + processDetailsPage.checkProcessTitleIsDisplayed(); + + attachmentListPage.checkAttachFileButtonIsNotDisplayed(); + attachmentListPage.viewFile(jpgFile.name); + + viewerPage.checkFileNameIsDisplayed(jpgFile.name); + viewerPage.clickCloseButton(); + + processFiltersPage.clickCompletedFilterButton(); + + attachmentListPage.downloadFile(jpgFile.name); + + expect(Util.fileExists(downloadedJpgFile, 20)).toBe(true); + + attachmentListPage.removeFile(jpgFile.name); + attachmentListPage.checkFileIsRemoved(jpgFile.name); + }); + + it('[C277296] Upload file - ProcessList - Task APP', () => { + processServicesPage.goToProcessServices().goToTaskApp().clickProcessButton(); + + processFiltersPage.clickRunningFilterButton(); + processFiltersPage.selectFromProcessList(processName.taskApp); + + processDetailsPage.checkProcessTitleIsDisplayed(); + + attachmentListPage.clickAttachFileButton(jpgFile.location); + attachmentListPage.checkFileIsAttached(jpgFile.name); + }); + + it('[C260235] Empty list component', () => { + processServicesPage.goToProcessServices().goToTaskApp().clickProcessButton(); + + processFiltersPage.clickRunningFilterButton(); + processFiltersPage.selectFromProcessList(processName.emptyList); + + attachmentListPage.checkEmptyAttachmentList(); + attachmentListPage.clickAttachFileButton(jpgFile.location); + attachmentListPage.checkFileIsAttached(jpgFile.name); + attachmentListPage.removeFile(jpgFile.name); + attachmentListPage.checkFileIsRemoved(jpgFile.name); + attachmentListPage.checkEmptyAttachmentList(); + }); + +}); diff --git a/e2e/start_process_component.e2e.ts b/e2e/start_process_component.e2e.ts index b094fb52e7..b06eb613c0 100644 --- a/e2e/start_process_component.e2e.ts +++ b/e2e/start_process_component.e2e.ts @@ -26,7 +26,7 @@ import StartProcessPage = require('./pages/adf/process_services/startProcessPage import ProcessFiltersPage = require('./pages/adf/process_services/processFiltersPage'); import AppNavigationBarPage = require('./pages/adf/process_services/appNavigationBarPage'); import ProcessDetailsPage = require('./pages/adf/process_services/processDetailsPage'); -import AttachmentListPage = require('./pages/adf/process_services/attachmentListPage'); +import {AttachmentListPage} from './pages/adf/process_services/attachmentListPage'; import User = require('./models/APS/User'); import AppPublish = require('./models/APS/AppPublish'); diff --git a/e2e/start_task_custom_app.e2e.ts b/e2e/start_task_custom_app.e2e.ts index ae68e4fdbb..11dccb1f03 100644 --- a/e2e/start_task_custom_app.e2e.ts +++ b/e2e/start_task_custom_app.e2e.ts @@ -18,7 +18,7 @@ import LoginPage = require('./pages/adf/loginPage'); import ProcessServicesPage = require('./pages/adf/process_services/processServicesPage'); import TasksPage = require('./pages/adf/process_services/tasksPage'); -import AttachmentListPage = require('./pages/adf/process_services/attachmentListPage'); +import {AttachmentListPage} from './pages/adf/process_services/attachmentListPage'; import CONSTANTS = require('./util/constants'); import Task = require('./models/APS/Task'); diff --git a/e2e/start_task_task_app.e2e.ts b/e2e/start_task_task_app.e2e.ts index 071954ae68..0b13b98e6f 100644 --- a/e2e/start_task_task_app.e2e.ts +++ b/e2e/start_task_task_app.e2e.ts @@ -18,7 +18,7 @@ import LoginPage = require('./pages/adf/loginPage'); import ProcessServicesPage = require('./pages/adf/process_services/processServicesPage'); import TasksPage = require('./pages/adf/process_services/tasksPage'); -import AttachmentListPage = require('./pages/adf/process_services/attachmentListPage'); +import {AttachmentListPage} from './pages/adf/process_services/attachmentListPage'; import CONSTANTS = require('./util/constants');