diff --git a/e2e/pages/adf/demo-shell/process-services/tasksCloudDemoPage.ts b/e2e/pages/adf/demo-shell/process-services/tasksCloudDemoPage.ts index 9b01db694d..e3dd36c012 100644 --- a/e2e/pages/adf/demo-shell/process-services/tasksCloudDemoPage.ts +++ b/e2e/pages/adf/demo-shell/process-services/tasksCloudDemoPage.ts @@ -52,6 +52,7 @@ export class TasksCloudDemoPage { titleInputField: ElementFinder = element(by.css('input[placeholder="Title"]')); iconInputField: ElementFinder = element(by.css('input[placeholder="Icon"]')); addActionButton: ElementFinder = element(by.cssContainingText('button span', 'Add')); + disableCheckbox: ElementFinder = element(by.css(`mat-checkbox[formcontrolname='disabled']`)); formControllersPage: FormControllersPage = new FormControllersPage(); @@ -164,8 +165,23 @@ export class TasksCloudDemoPage { await BrowserActions.click(this.addActionButton); } + async addDisabledAction(text: string): Promise { + await BrowserActions.clearSendKeys(this.keyInputField, text); + await BrowserActions.clearSendKeys(this.titleInputField, text); + await BrowserActions.clearSendKeys(this.iconInputField, text); + await BrowserActions.click(this.disableCheckbox); + await BrowserActions.click(this.addActionButton); + } + async actionAdded(action: string): Promise { await BrowserVisibility.waitUntilElementIsVisible(element(by.cssContainingText(`mat-chip`, action))); } + async checkActionExecuted(taskId: string, action: string): Promise { + await BrowserVisibility.waitUntilElementIsVisible(element(by.cssContainingText(`span`, 'Action Menu:'))); + await BrowserVisibility.waitUntilElementIsVisible(element(by.cssContainingText(`span`, 'Context Menu:'))); + await BrowserVisibility.waitUntilElementIsVisible(element(by.cssContainingText(`span`, 'Task Id: ' + taskId))); + await BrowserVisibility.waitUntilElementIsVisible(element(by.cssContainingText(`span`, 'Action Type: ' + action))); + } + } diff --git a/e2e/process-services-cloud/process-list-cloud-action-menu.e2e.ts b/e2e/process-services-cloud/process-list-cloud-action-menu.e2e.ts index 25d679b811..33cce8b60d 100644 --- a/e2e/process-services-cloud/process-list-cloud-action-menu.e2e.ts +++ b/e2e/process-services-cloud/process-list-cloud-action-menu.e2e.ts @@ -90,6 +90,8 @@ describe('Process list cloud', () => { await tasksCloudDemoPage.actionAdded('edit'); await tasksCloudDemoPage.addAction('delete'); await tasksCloudDemoPage.actionAdded('delete'); + await tasksCloudDemoPage.addDisabledAction('disabledaction'); + await tasksCloudDemoPage.actionAdded('disabledaction'); await tasksCloudDemoPage.clickAppButton(); await processCloudDemoPage.clickOnProcessFilters(); await processCloudDemoPage.runningProcessesFilter().clickProcessFilter(); @@ -99,9 +101,12 @@ describe('Process list cloud', () => { await expect(await processCloudDemoPage.getActiveFilterName()).toBe('Running Processes'); await processCloudDemoPage.processListCloudComponent().checkProcessListIsLoaded(); await processCloudDemoPage.processListCloudComponent().checkContentIsDisplayedById(editProcess.entry.id); - await processCloudDemoPage.processListCloudComponent().clickOnCustomActionMenu(editProcess.entry.id, 'edit'); + await processCloudDemoPage.processListCloudComponent().clickOptionsButton(editProcess.entry.id); + await expect(await processCloudDemoPage.processListCloudComponent().isCustomActionEnabled('disabledaction')).toBe(false); + await processCloudDemoPage.processListCloudComponent().clickOnCustomActionMenu('edit'); await processCloudDemoPage.checkActionExecuted(editProcess.entry.id, 'edit'); await processCloudDemoPage.processListCloudComponent().rightClickOnRow(deleteProcess.entry.id); + await expect(await processCloudDemoPage.processListCloudComponent().isCustomActionEnabled('disabledaction')).toBe(false); await processCloudDemoPage.processListCloudComponent().clickContextMenuActionNamed('delete'); await processCloudDemoPage.checkActionExecuted(deleteProcess.entry.id, 'delete'); }); diff --git a/e2e/process-services-cloud/task-list-cloud-action-menu.e2e.ts b/e2e/process-services-cloud/task-list-cloud-action-menu.e2e.ts new file mode 100644 index 0000000000..1a305e0c1f --- /dev/null +++ b/e2e/process-services-cloud/task-list-cloud-action-menu.e2e.ts @@ -0,0 +1,123 @@ +/*! + * @license + * Copyright 2019 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 { browser } from 'protractor'; +import { GroupIdentityService, IdentityService, LoginSSOPage, QueryService, SettingsPage, TasksService } from '@alfresco/adf-testing'; +import { AppListCloudPage } from '@alfresco/adf-testing'; +import { NavigationBarPage } from '../pages/adf/navigationBarPage'; +import { TasksCloudDemoPage } from '../pages/adf/demo-shell/process-services/tasksCloudDemoPage'; + +import { ProcessDefinitionsService, ApiService } from '@alfresco/adf-testing'; +import { ProcessInstancesService } from '@alfresco/adf-testing'; +import resources = require('../util/resources'); + +describe('Process list cloud', () => { + + describe('Process List - Custom Action Menu', () => { + const loginSSOPage = new LoginSSOPage(); + const navigationBarPage = new NavigationBarPage(); + const appListCloudComponent = new AppListCloudPage(); + const tasksCloudDemoPage = new TasksCloudDemoPage(); + const settingsPage = new SettingsPage(); + + let processDefinitionService: ProcessDefinitionsService; + let processInstancesService: ProcessInstancesService; + let identityService: IdentityService; + let groupIdentityService: GroupIdentityService; + let queryService: QueryService; + let tasksService: TasksService; + let testUser, groupInfo, editProcess, deleteProcess, editTask, deleteTask; + + const simpleApp = resources.ACTIVITI7_APPS.SIMPLE_APP.name; + const apiService = new ApiService(browser.params.config.oauth2.clientId, browser.params.config.bpmHost, browser.params.config.oauth2.host, 'BPM'); + + beforeAll(async () => { + + await apiService.login(browser.params.identityAdmin.email, browser.params.identityAdmin.password); + identityService = new IdentityService(apiService); + groupIdentityService = new GroupIdentityService(apiService); + testUser = await identityService.createIdentityUserWithRole(apiService, [identityService.ROLES.APS_USER]); + groupInfo = await groupIdentityService.getGroupInfoByGroupName('hr'); + await identityService.addUserToGroup(testUser.idIdentityService, groupInfo.id); + + await apiService.login(testUser.email, testUser.password); + processDefinitionService = new ProcessDefinitionsService(apiService); + const processDefinition = await processDefinitionService + .getProcessDefinitionByName(resources.ACTIVITI7_APPS.SIMPLE_APP.processes.dropdownrestprocess, simpleApp); + + processInstancesService = new ProcessInstancesService(apiService); + editProcess = await processInstancesService.createProcessInstance(processDefinition.entry.key, simpleApp); + deleteProcess = await processInstancesService.createProcessInstance(processDefinition.entry.key, simpleApp); + queryService = new QueryService(apiService); + + editTask = await queryService.getProcessInstanceTasks(editProcess.entry.id, simpleApp); + deleteTask = await queryService.getProcessInstanceTasks(deleteProcess.entry.id, simpleApp); + tasksService = new TasksService(apiService); + await tasksService.claimTask(editTask.list.entries[0].entry.id, simpleApp); + await tasksService.claimTask(deleteTask.list.entries[0].entry.id, simpleApp); + + await settingsPage.setProviderBpmSso( + browser.params.config.bpmHost, + browser.params.config.oauth2.host, + browser.params.config.identityHost); + await loginSSOPage.loginSSOIdentityService(testUser.email, testUser.password); + + }); + + afterAll(async() => { + await apiService.login(browser.params.identityAdmin.email, browser.params.identityAdmin.password); + await identityService.deleteIdentityUser(testUser.idIdentityService); + + }); + + beforeAll(async () => { + await navigationBarPage.navigateToProcessServicesCloudPage(); + await appListCloudComponent.checkApsContainer(); + await appListCloudComponent.goToApp(simpleApp); + await tasksCloudDemoPage.clickSettingsButton(); + await tasksCloudDemoPage.enableTestingMode(); + await tasksCloudDemoPage.enableActionMenu(); + await tasksCloudDemoPage.enableContextMenu(); + await tasksCloudDemoPage.addActionIsDisplayed(); + await tasksCloudDemoPage.addAction('edit'); + await tasksCloudDemoPage.actionAdded('edit'); + await tasksCloudDemoPage.addAction('delete'); + await tasksCloudDemoPage.actionAdded('delete'); + await tasksCloudDemoPage.addDisabledAction('disabledaction'); + await tasksCloudDemoPage.actionAdded('disabledaction'); + await tasksCloudDemoPage.clickAppButton(); + await tasksCloudDemoPage.editTaskFilterCloudComponent().openFilter(); + await tasksCloudDemoPage.myTasksFilter().checkTaskFilterIsDisplayed(); + }); + + it('[C315723] Should be able to see and execute custom action menu', async () => { + await expect(await tasksCloudDemoPage.getActiveFilterName()).toBe('My Tasks'); + await tasksCloudDemoPage.taskListCloudComponent().checkTaskListIsLoaded(); + await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedById(editTask.list.entries[0].entry.id); + await tasksCloudDemoPage.taskListCloudComponent().clickOptionsButton(editTask.list.entries[0].entry.id); + await expect(await tasksCloudDemoPage.taskListCloudComponent().isCustomActionEnabled('disabledaction')).toBe(false); + await tasksCloudDemoPage.taskListCloudComponent().clickOnCustomActionMenu('edit'); + await tasksCloudDemoPage.checkActionExecuted(editTask.list.entries[0].entry.id, 'edit'); + await tasksCloudDemoPage.taskListCloudComponent().rightClickOnRow(deleteTask.list.entries[0].entry.id); + await expect(await tasksCloudDemoPage.taskListCloudComponent().isCustomActionEnabled('disabledaction')).toBe(false); + await tasksCloudDemoPage.taskListCloudComponent().clickContextMenuActionNamed('delete'); + await tasksCloudDemoPage.checkActionExecuted(deleteTask.list.entries[0].entry.id, 'delete'); + }); + + }); + +}); diff --git a/lib/testing/src/lib/process-services-cloud/pages/process-list-cloud-component.page.ts b/lib/testing/src/lib/process-services-cloud/pages/process-list-cloud-component.page.ts index 68f4c0ea31..a01b7cf9ce 100644 --- a/lib/testing/src/lib/process-services-cloud/pages/process-list-cloud-component.page.ts +++ b/lib/testing/src/lib/process-services-cloud/pages/process-list-cloud-component.page.ts @@ -102,15 +102,23 @@ export class ProcessListCloudComponentPage { return this.dataTable.getAllRowsColumnValues(column); } - async clickOnCustomActionMenu(content: string, action: string): Promise { + async clickOptionsButton(content: string) { await BrowserActions.closeMenuAndDialogs(); const row: ElementFinder = this.dataTable.getRow('Id', content); await BrowserActions.click(row.element(this.optionButton)); await BrowserVisibility.waitUntilElementIsVisible(this.actionMenu); + } + + async clickOnCustomActionMenu(action: string): Promise { const actionButton = element(by.css(`button[data-automation-id*="${action}"]`)); await BrowserActions.click(actionButton); } + async isCustomActionEnabled(action: string): Promise { + const actionButton = element(by.css(`button[data-automation-id*="${action}"]`)); + return actionButton.isEnabled(); + } + async rightClickOnRow(processInstance: string): Promise { await this.dataTable.rightClickOnRow('Id', processInstance); } diff --git a/lib/testing/src/lib/process-services-cloud/pages/task-list-cloud-component.page.ts b/lib/testing/src/lib/process-services-cloud/pages/task-list-cloud-component.page.ts index 57c3879e2c..c7521c11a2 100644 --- a/lib/testing/src/lib/process-services-cloud/pages/task-list-cloud-component.page.ts +++ b/lib/testing/src/lib/process-services-cloud/pages/task-list-cloud-component.page.ts @@ -17,7 +17,7 @@ import { BrowserVisibility } from '../../core/utils/browser-visibility'; import { DataTableComponentPage } from '../../core/pages/data-table-component.page'; -import { element, by, ElementFinder } from 'protractor'; +import { element, by, ElementFinder, Locator } from 'protractor'; import { BrowserActions } from '../../core/utils/browser-actions'; const column = { @@ -36,6 +36,8 @@ export class TaskListCloudComponentPage { taskList = element(by.css('adf-cloud-task-list')); noTasksFound = element.all(by.css("div[class='adf-empty-content__title']")).first(); + actionMenu: ElementFinder = element(by.css('div[role="menu"]')); + optionButton: Locator = by.css('button[data-automation-id*="action_menu_"]'); dataTable = new DataTableComponentPage(this.taskList); @@ -156,4 +158,29 @@ export class TaskListCloudComponentPage { return BrowserActions.getText(locator); } + async clickOptionsButton(content: string) { + await BrowserActions.closeMenuAndDialogs(); + const row: ElementFinder = this.dataTable.getRow('Id', content); + await BrowserActions.click(row.element(this.optionButton)); + await BrowserVisibility.waitUntilElementIsVisible(this.actionMenu); + } + + async clickOnCustomActionMenu(action: string): Promise { + const actionButton = element(by.css(`button[data-automation-id*="${action}"]`)); + await BrowserActions.click(actionButton); + } + + async isCustomActionEnabled(action: string): Promise { + const actionButton = element(by.css(`button[data-automation-id*="${action}"]`)); + return actionButton.isEnabled(); + } + + async rightClickOnRow(taskId: string): Promise { + await this.dataTable.rightClickOnRow('Id', taskId); + } + + async clickContextMenuActionNamed(actionName): Promise { + await BrowserActions.clickExecuteScript(`button[data-automation-id="context-${actionName}"]`); + } + }