From 9e0e2bdfa6f3b3369d217197e855bd5c9e1d0ba2 Mon Sep 17 00:00:00 2001 From: arditdomi <32884230+arditdomi@users.noreply.github.com> Date: Sun, 23 Feb 2020 14:02:15 +0000 Subject: [PATCH] [AAE-1933] Add dropdown testing page (#5491) * [AAE-1933] Add process and task filters testing methods - check option is visible in dropdown * [AAE-1933] Add dropdown page * [AAE-1933] Remove methods replaced by dropdown page * [AAE-1933] Fix dropdown methods not working * [AAE-1933] Fix e2e * [AAE-1933] Fix task-form-cloud e2e --- e2e/pages/adf/content-services.page.ts | 5 +- .../task-form-cloud-component.e2e.ts | 12 +++-- .../src/lib/core/utils/browser-actions.ts | 13 ----- .../src/lib/material/pages/dropdown.page.ts | 50 +++++++++++++++++++ .../src/lib/material/pages/public-api.ts | 1 + 5 files changed, 63 insertions(+), 18 deletions(-) create mode 100644 lib/testing/src/lib/material/pages/dropdown.page.ts diff --git a/e2e/pages/adf/content-services.page.ts b/e2e/pages/adf/content-services.page.ts index af5d8e6462..5888e00ee6 100644 --- a/e2e/pages/adf/content-services.page.ts +++ b/e2e/pages/adf/content-services.page.ts @@ -23,6 +23,7 @@ import { FolderDialogPage } from './dialog/folder-dialog.page'; import { NavigationBarPage } from './navigation-bar.page'; import path = require('path'); +import { DropdownPage } from '../../../lib/testing/src/lib/material/pages/dropdown.page'; export class ContentServicesPage { @@ -593,7 +594,9 @@ export class ContentServicesPage { } async selectSite(siteName: string): Promise { - await BrowserActions.clickOnSelectDropdownOption(siteName, this.siteListDropdown); + const dropdownPage = new DropdownPage(this.siteListDropdown); + await dropdownPage.clickDropdown(); + await dropdownPage.selectOption(siteName); } async clickDownloadButton(): Promise { diff --git a/e2e/process-services-cloud/task-form-cloud-component.e2e.ts b/e2e/process-services-cloud/task-form-cloud-component.e2e.ts index 7509a7198d..468fb4d86f 100644 --- a/e2e/process-services-cloud/task-form-cloud-component.e2e.ts +++ b/e2e/process-services-cloud/task-form-cloud-component.e2e.ts @@ -46,7 +46,7 @@ describe('Task form cloud component', () => { let processDefinitionService: ProcessDefinitionsService; let processInstancesService: ProcessInstancesService; - let completedTask, createdTask, assigneeTask, toBeCompletedTask, formValidationsTask, formTaskId, assigneeTaskId, assigneeReleaseTask; + let completedTask, createdTask, assigneeTask, toBeCompletedTask, formValidationsTask, formTaskId, assigneeTaskId, assigneeReleaseTask, candidateUsersTask ; const candidateBaseApp = browser.params.resources.ACTIVITI_CLOUD_APPS.CANDIDATE_BASE_APP.name; const simpleApp = browser.params.resources.ACTIVITI_CLOUD_APPS.SIMPLE_APP.name; const completedTaskName = StringUtil.generateRandomString(), assignedTaskName = StringUtil.generateRandomString(); @@ -82,7 +82,11 @@ describe('Task form cloud component', () => { .getProcessDefinitionByName(browser.params.resources.ACTIVITI_CLOUD_APPS.CANDIDATE_BASE_APP.processes.candidateUserProcess, candidateBaseApp); processInstancesService = new ProcessInstancesService(apiServiceHrUser); - await processInstancesService.createProcessInstance(processDefinition.entry.key, candidateBaseApp); + const candidateUsersProcessInstance = await processInstancesService.createProcessInstance(processDefinition.entry.key, candidateBaseApp); + + const processInstanceTasks = await queryService.getProcessInstanceTasks(candidateUsersProcessInstance.entry.id, candidateBaseApp); + candidateUsersTask = processInstanceTasks.list.entries[0]; + await tasksService.claimTask(candidateUsersTask.entry.id, candidateBaseApp); processDefinition = await processDefinitionService .getProcessDefinitionByName(browser.params.resources.ACTIVITI_CLOUD_APPS.SIMPLE_APP.processes.dropdownrestprocess, simpleApp); @@ -168,8 +172,8 @@ describe('Task form cloud component', () => { it('[C307032] Should display the appropriate title for the unclaim option of a Task', async () => { await tasksCloudDemoPage.myTasksFilter().clickTaskFilter(); - await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedByName(assigneeTask.entry.name); - await tasksCloudDemoPage.taskListCloudComponent().selectRow(assigneeTask.entry.name); + await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedById(candidateUsersTask.entry.id); + await tasksCloudDemoPage.taskListCloudComponent().selectRowByTaskId(candidateUsersTask.entry.id); await expect(await taskFormCloudComponent.getReleaseButtonText()).toBe('RELEASE'); }); diff --git a/lib/testing/src/lib/core/utils/browser-actions.ts b/lib/testing/src/lib/core/utils/browser-actions.ts index 7d29fac9e1..34e56b4b64 100644 --- a/lib/testing/src/lib/core/utils/browser-actions.ts +++ b/lib/testing/src/lib/core/utils/browser-actions.ts @@ -112,17 +112,4 @@ export class BrowserActions { // if the opened menu has only disabled items, pressing escape to close it won't work await browser.actions().sendKeys(protractor.Key.ENTER).perform(); } - - static async clickOnDropdownOption(option: string, dropDownElement: ElementFinder): Promise { - await this.click(dropDownElement); - await BrowserVisibility.waitUntilElementIsVisible(element('div[class*="mat-menu-content"] button')); - const optionElement = element(by.cssContainingText('div[class*="mat-menu-content"] button', option)); - await this.click(optionElement); - } - - static async clickOnSelectDropdownOption(option: string, dropDownElement: ElementFinder): Promise { - await this.click(dropDownElement); - const optionElement = element(by.cssContainingText('mat-option span.mat-option-text', option)); - await this.click(optionElement); - } } diff --git a/lib/testing/src/lib/material/pages/dropdown.page.ts b/lib/testing/src/lib/material/pages/dropdown.page.ts new file mode 100644 index 0000000000..c2ed1459bb --- /dev/null +++ b/lib/testing/src/lib/material/pages/dropdown.page.ts @@ -0,0 +1,50 @@ +/*! + * @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 { element, by, ElementFinder } from 'protractor'; +import { BrowserVisibility } from '../../core/utils/browser-visibility'; +import { BrowserActions } from '../../core/utils/browser-actions'; + +export class DropdownPage { + + dropDownElement: ElementFinder; + + constructor(dropDownElement: ElementFinder = element.all(by.css('div[class="mat-select-arrow-wrapper"]')).first()) { + this.dropDownElement = dropDownElement; + } + + async checkOptionIsVisibleInDropdown(option: string): Promise { + await BrowserVisibility.waitUntilElementIsVisible(element(by.cssContainingText('mat-option span', option)), 5000); + } + + async checkOptionIsNotVisible(option: string): Promise { + await BrowserVisibility.waitUntilElementIsNotVisible(element(by.cssContainingText('mat-option span', option)), 5000); + } + + async clickDropdown(): Promise { + await BrowserActions.click(this.dropDownElement); + } + + async selectOption(option: string): Promise { + const optionElement = element(by.cssContainingText('mat-option span.mat-option-text', option)); + await BrowserActions.click(optionElement); + } + + async getValue(): Promise { + return BrowserActions.getText(element(by.css('mat-form-field span'))); + } +} diff --git a/lib/testing/src/lib/material/pages/public-api.ts b/lib/testing/src/lib/material/pages/public-api.ts index 6b0cbd1f47..b7bf6cb828 100644 --- a/lib/testing/src/lib/material/pages/public-api.ts +++ b/lib/testing/src/lib/material/pages/public-api.ts @@ -17,3 +17,4 @@ export * from './tabs.page'; export * from './date-picker.page'; +export * from './dropdown.page';