/*! * @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 { BrowserActions, BrowserVisibility, DropdownPage, TabsPage } from '@alfresco/adf-testing'; import { browser, by, element, Key } from 'protractor'; import { AppSettingsTogglesPage } from './dialog/app-settings-toggles.page'; export class TaskDetailsPage { appSettingsTogglesClass = new AppSettingsTogglesPage(); formContent = element(by.css('adf-form')); formNameField = element(by.css('[data-automation-id="card-textitem-value-formName"]')); formNameButton = element(by.css('[data-automation-id="card-textitem-toggle-formName"]')); assigneeField = element(by.css('[data-automation-id="card-textitem-value-assignee"]')); assigneeButton = element(by.css('[data-automation-id="card-textitem-toggle-assignee"]')); statusField = element(by.css('[data-automation-id="card-textitem-value-status"]')); categoryField = element(by.css('[data-automation-id="card-textitem-value-category"] ')); parentNameField = element(by.css('span[data-automation-id*="parentName"] span')); parentTaskIdField = element(by.css('[data-automation-id="card-textitem-value-parentTaskId"] ')); durationField = element(by.css('[data-automation-id="card-textitem-value-duration"] ')); endDateField = element.all(by.css('span[data-automation-id*="endDate"] span')).first(); createdField = element(by.css('span[data-automation-id="card-dateitem-created"]')); idField = element.all(by.css('[data-automation-id="card-textitem-value-id"]')).first(); descriptionField = element(by.css('[data-automation-id="card-textitem-value-description"]')); dueDateField = element.all(by.css('span[data-automation-id*="dueDate"] span')).first(); activitiesTitle = element(by.css('div[class*="adf-info-drawer-layout-header-title"] div')); commentField = element(by.id('comment-input')); addCommentButton = element(by.css('[data-automation-id="comments-input-add"]')); involvePeopleButton = element(by.css('div[class*="add-people"]')); addPeopleField = element(by.css('input[data-automation-id="adf-people-search-input"]')); addInvolvedUserButton = element(by.css('button[id="add-people"]')); taskDetailsInfoDrawer = element(by.tagName('adf-info-drawer')); taskDetailsSection = element(by.css('div[data-automation-id="app-tasks-details"]')); taskDetailsEmptySection = element(by.css('div[data-automation-id="adf-tasks-details--empty"]')); completeTask = element(by.css('button[id="adf-no-form-complete-button"]')); completeFormTask = element(by.css('button[id="adf-form-complete"]')); taskDetailsTitle = element(by.css('.adf-activiti-task-details__header span')); auditLogButton = element(by.css('button[adf-task-audit]')); noPeopleInvolved = element(by.id('no-people-label')); cancelInvolvePeopleButton = element(by.id('close-people-search')); involvePeopleHeader = element(by.css('.adf-search-text-header')); removeInvolvedPeople = element(by.css('button[data-automation-id="Remove"]')); peopleTitle = element(by.id('people-title')); noFormMessage = element(by.css('span[id*="no-form-message"]')); cancelAttachForm = element(by.id('adf-no-form-cancel-button')); attachFormButton = element(by.id('adf-no-form-attach-form-button')); disabledAttachFormButton = element(by.css('button[id="adf-no-form-attach-form-button"][disabled]')); removeAttachForm = element(by.id('adf-attach-form-remove-button')); attachFormName = element(by.css('.adf-form-title')); emptyTaskDetails = element(by.css('adf-task-details > div > div')); priority = element(by.css('[data-automation-id*="card-textitem-value-priority"]')); editableAssignee = element(by.css('[data-automation-id="card-textitem-value-assignee"][class*="clickable"]')); claimElement = element(by.css('[data-automation-id="header-claim-button"]')); releaseElement = element(by.css('[data-automation-id="header-unclaim-button"]')); saveFormButton = element(by.css('button[id="adf-form-save"]')); attachFormDropdown = new DropdownPage(element(by.css('.adf-attach-form-row'))); async checkEditableAssigneeIsNotDisplayed(): Promise { await BrowserVisibility.waitUntilElementIsNotVisible(this.editableAssignee); } async checkEditableFormIsNotDisplayed(): Promise { const editableForm = element(by.css('[data-automation-id="card-textitem-value-formName"][class*="clickable"]')); await BrowserVisibility.waitUntilElementIsNotVisible(editableForm); } async checkDueDatePickerButtonIsNotDisplayed(): Promise { const dueDatePickerButton = element(by.css('mat-datetimepicker-toggle[data-automation-id="datepickertoggle-dueDate"]')); await BrowserVisibility.waitUntilElementIsNotVisible(dueDatePickerButton); } getTaskDetailsTitle(): Promise { return BrowserActions.getText(this.taskDetailsTitle); } async checkSelectedForm(formName): Promise { await this.attachFormDropdown.checkOptionIsSelected(formName); } async checkAttachFormButtonIsDisabled(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.disabledAttachFormButton); } async checkAttachFormButtonIsEnabled(): Promise { await BrowserVisibility.waitUntilElementIsClickable(this.attachFormButton); } async checkAttachFormDropdownIsDisplayed(): Promise { await this.attachFormDropdown.checkDropdownIsVisible(); } async selectAttachFormOption(option): Promise { await this.attachFormDropdown.selectDropdownOption(option); } async noFormIsDisplayed(): Promise { await BrowserVisibility.waitUntilElementIsNotVisible(this.formContent); } async checkRemoveAttachFormIsDisplayed() { await BrowserVisibility.waitUntilElementIsVisible(this.removeAttachForm); } async clickRemoveAttachForm(): Promise { await BrowserActions.click(this.removeAttachForm); await browser.sleep(2000); } async checkAttachFormButtonIsDisplayed(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.attachFormButton); } async checkAttachFormButtonIsNotDisplayed(): Promise { await BrowserVisibility.waitUntilElementIsNotVisible(this.attachFormButton); } async clickAttachFormButton(): Promise { return BrowserActions.click(this.attachFormButton); } async checkFormIsAttached(formName: string): Promise { await BrowserVisibility.waitUntilElementHasValue(this.formNameField, formName); } getFormName(): Promise { return BrowserActions.getInputValue(this.formNameField); } async waitFormNameEqual(formName: string): Promise { await BrowserVisibility.waitUntilElementHasValue(this.formNameField, formName); } async clickForm(): Promise { await BrowserActions.closeMenuAndDialogs(); await BrowserActions.click(this.formNameButton); } async checkStandaloneNoFormMessageIsDisplayed(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.noFormMessage); } async getNoFormMessage(): Promise { return BrowserActions.getText(this.noFormMessage); } getAssignee(): Promise { return BrowserActions.getInputValue(this.assigneeField); } isAssigneeClickable(): Promise { return BrowserVisibility.waitUntilElementIsVisible(this.editableAssignee); } getStatus(): Promise { return BrowserActions.getInputValue(this.statusField); } getCategory(): Promise { return BrowserActions.getInputValue(this.categoryField); } getParentName(): Promise { return BrowserActions.getText(this.parentNameField); } getParentTaskId(): Promise { return BrowserActions.getInputValue(this.parentTaskIdField); } getDuration(): Promise { return BrowserActions.getInputValue(this.durationField); } getEndDate(): Promise { return BrowserActions.getText(this.endDateField); } getCreated(): Promise { return BrowserActions.getText(this.createdField); } getId(): Promise { return BrowserActions.getInputValue(this.idField); } getDescription(): Promise { return BrowserActions.getInputValue(this.descriptionField); } async getDescriptionPlaceholder(): Promise { return BrowserActions.getAttribute(this.descriptionField, 'data-placeholder'); } getDueDate(): Promise { return BrowserActions.getText(this.dueDateField); } getPriority(): Promise { return BrowserActions.getInputValue(this.priority); } async updatePriority(priority?: string): Promise { await BrowserActions.click(this.priority); await BrowserActions.clearWithBackSpace(this.priority); await BrowserActions.clearSendKeys(element(by.css('input[data-automation-id="card-textitem-value-priority"]')), priority, 500); await this.priority.sendKeys(Key.TAB); await browser.sleep(1000); } async updateDueDate(): Promise { await BrowserActions.click(this.dueDateField); await BrowserActions.click(element.all(by.css('.mat-datetimepicker-calendar-body-cell')).first()); await browser.sleep(1000); } async updateDescription(description?: string): Promise { await BrowserActions.click(this.descriptionField); await BrowserActions.clearWithBackSpace(this.descriptionField); await BrowserActions.clearSendKeys(element(by.css('[data-automation-id="card-textitem-value-description"]')), description ? description : ''); await this.descriptionField.sendKeys(Key.TAB); await browser.sleep(1000); } async updateAssignee(fullName: string): Promise { await BrowserActions.click(this.assigneeButton); await BrowserActions.clearSendKeys(element(by.css('[id="userSearchText"]')), fullName); await BrowserActions.click(element(by.cssContainingText('.adf-people-full-name', fullName))); await BrowserVisibility.waitUntilElementIsVisible(element(by.css(`adf-datatable-row[class*='is-selected']`))); await browser.sleep(2000); await BrowserActions.click(element(by.css('button[id="add-people"]'))); } getTitle(): Promise { return BrowserActions.getText(this.activitiesTitle); } async selectActivityTab(): Promise { const tabsPage: TabsPage = new TabsPage; await tabsPage.clickTabByTitle('Activity'); } async selectDetailsTab(): Promise { const tabsPage: TabsPage = new TabsPage; await tabsPage.clickTabByTitle('Details'); } async addComment(comment: string): Promise { await BrowserActions.clearSendKeys(this.commentField, comment); await BrowserActions.click(this.addCommentButton); } async checkCommentIsDisplayed(comment: string): Promise { const row = element(by.cssContainingText('div[id="comment-message"]', comment)); await BrowserVisibility.waitUntilElementIsVisible(row); } async checkIsEmptyCommentListDisplayed(): Promise { const emptyList = element(by.cssContainingText('div[id="comment-header"]', '(0)')); await BrowserVisibility.waitUntilElementIsVisible(emptyList); } async clickInvolvePeopleButton(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.involvePeopleButton); await BrowserVisibility.waitUntilElementIsClickable(this.involvePeopleButton); await browser.actions().mouseMove(this.involvePeopleButton).perform(); await BrowserActions.click(this.involvePeopleButton); } async typeUser(user: string): Promise { await BrowserActions.clearSendKeys(this.addPeopleField, user); } async selectUserToInvolve(user): Promise { const row = this.getRowsUser(user); await BrowserActions.click(row); } async checkUserIsSelected(user: string): Promise { const row = this.getRowsUser(user); await BrowserVisibility.waitUntilElementIsVisible(row); await browser.sleep(2000); } async clickAddInvolvedUserButton(): Promise { await BrowserActions.click(this.addInvolvedUserButton); } getRowsUser(user: string) { return element(by.css(`div[data-automation-id="adf-people-full-name-${user.replace(' ', '-')}"]`)); } async removeInvolvedUser(user): Promise { const row = this.getRowsUser(user).element(by.xpath('ancestor::adf-datatable-row[contains(@class, "adf-datatable-row")]')); await BrowserActions.click(row.element(by.css('button[data-automation-id="action_menu_0"]'))); await BrowserVisibility.waitUntilElementIsVisible(this.removeInvolvedPeople); await BrowserActions.click(this.removeInvolvedPeople); } async getInvolvedUserEmail(user): Promise { return BrowserActions.getText(element(by.css(`div[data-automation-id="adf-people-email-${user.replace(' ', '-')}"]`))); } async clickAuditLogButton(): Promise { await BrowserActions.click(this.auditLogButton); } appSettingsToggles(): AppSettingsTogglesPage { return this.appSettingsTogglesClass; } async taskInfoDrawerIsDisplayed(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.taskDetailsInfoDrawer); } async taskInfoDrawerIsNotDisplayed(): Promise { await BrowserVisibility.waitUntilElementIsNotVisible(this.taskDetailsInfoDrawer); } async checkNoPeopleIsInvolved(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.noPeopleInvolved); } async clickCancelInvolvePeopleButton(): Promise { await BrowserActions.click(this.cancelInvolvePeopleButton); } getInvolvePeopleHeader(): Promise { return BrowserActions.getText(this.involvePeopleHeader); } async getInvolvePeoplePlaceholder(): Promise { return BrowserActions.getAttribute(this.addPeopleField, 'data-placeholder'); } async checkCancelButtonIsEnabled(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.cancelInvolvePeopleButton); await BrowserVisibility.waitUntilElementIsClickable(this.cancelInvolvePeopleButton); } async checkAddPeopleButtonIsEnabled(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.addInvolvedUserButton); await BrowserVisibility.waitUntilElementIsClickable(this.addInvolvedUserButton); } async noUserIsDisplayedInSearchInvolvePeople(user): Promise { await BrowserVisibility.waitUntilElementIsNotVisible(element(by.cssContainingText('div[class*="people-full-name"]', user))); } getInvolvedPeopleTitle(): Promise { return BrowserActions.getText(this.peopleTitle); } checkTaskDetailsEmpty(): Promise { return BrowserActions.getText(this.taskDetailsEmptySection); } async checkTaskDetailsDisplayed(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.taskDetailsSection); await BrowserVisibility.waitUntilElementIsVisible(this.formNameField); await BrowserVisibility.waitUntilElementIsVisible(this.assigneeField); await BrowserVisibility.waitUntilElementIsVisible(this.statusField); await BrowserVisibility.waitUntilElementIsVisible(this.categoryField); await BrowserVisibility.waitUntilElementIsVisible(this.parentNameField); await BrowserVisibility.waitUntilElementIsVisible(this.createdField); await BrowserVisibility.waitUntilElementIsVisible(this.idField); await BrowserVisibility.waitUntilElementIsVisible(this.descriptionField); await BrowserVisibility.waitUntilElementIsVisible(this.dueDateField); await BrowserVisibility.waitUntilElementIsVisible(this.priority); await BrowserVisibility.waitUntilElementIsVisible(this.activitiesTitle); return BrowserActions.getText(this.taskDetailsSection); } async clickCompleteTask(): Promise { await BrowserActions.click(this.completeTask); } async checkCompleteFormButtonIsDisplayed(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.completeFormTask); } async checkCompleteTaskButtonIsEnabled(): Promise { await BrowserVisibility.waitUntilElementIsClickable(this.completeTask); } async checkCompleteTaskButtonIsDisplayed(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.completeTask); } async clickCompleteFormTask(): Promise { await BrowserActions.click(this.completeFormTask); } async getEmptyTaskDetailsMessage(): Promise { return BrowserActions.getText(this.emptyTaskDetails); } async isCompleteButtonWithFormEnabled(): Promise { return this.completeFormTask.isEnabled(); } async checkClaimEnabled(): Promise { await BrowserVisibility.waitUntilElementIsPresent(this.claimElement); } async checkReleaseEnabled(): Promise { await BrowserVisibility.waitUntilElementIsPresent(this.releaseElement); } async claimTask(): Promise { await BrowserActions.click(this.claimElement); } async releaseTask(): Promise { await BrowserActions.click(this.releaseElement); } async saveTaskForm(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.saveFormButton); await BrowserActions.click(this.saveFormButton); } }