From c11237a2ffeec0e8b86a0220ad0748e8814de0fd Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Sun, 6 Sep 2020 22:11:52 +0300 Subject: [PATCH] [ACA-3441] Add method to attach file widget PO (#6085) * Add methods and locator for uploadButton of attach file widget of type local * Add method to attach-file-widget * Modify the right click --- .../core/pages/data-table/data-table-item.ts | 3 +- .../form/widgets/attach-file-widget.page.ts | 44 +++++++++++++++++-- .../pages/start-process.page.ts | 6 +++ 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/lib/testing/src/lib/core/pages/data-table/data-table-item.ts b/lib/testing/src/lib/core/pages/data-table/data-table-item.ts index cf818a3791..4d34f25e5c 100644 --- a/lib/testing/src/lib/core/pages/data-table/data-table-item.ts +++ b/lib/testing/src/lib/core/pages/data-table/data-table-item.ts @@ -53,7 +53,8 @@ export class DataTableItem { async rightClickOnRow(columnName: string, columnValue: string): Promise { const row = await this.getRow(columnName, columnValue); - await BrowserActions.rightClick(row); + await browser.actions().mouseMove(row).perform(); + await browser.actions().click(row, protractor.Button.RIGHT).perform(); } async waitForFirstRow(): Promise { diff --git a/lib/testing/src/lib/core/pages/form/widgets/attach-file-widget.page.ts b/lib/testing/src/lib/core/pages/form/widgets/attach-file-widget.page.ts index 6f5f01184f..d7c87adc91 100644 --- a/lib/testing/src/lib/core/pages/form/widgets/attach-file-widget.page.ts +++ b/lib/testing/src/lib/core/pages/form/widgets/attach-file-widget.page.ts @@ -22,7 +22,7 @@ import { Locator, element, by, browser } from 'protractor'; export class AttachFileWidgetPage { formFields = new FormFields(); - uploadLocator: Locator = by.css('button[id="attachfile"]'); + alfrescoTypeUploadLocator: Locator = by.css('button[id="attachfile"]'); localStorageButton = element(by.css('input[id="attachfile"]')); filesListLocator: Locator = by.css('div[id="adf-attach-widget-readonly-list"]'); attachFileWidget = element(by.css('#attachfile')); @@ -34,18 +34,36 @@ export class AttachFileWidgetPage { async attachFile(fieldId, fileLocation): Promise { const widget = await this.formFields.getWidget(fieldId); - const uploadButton = await widget.element(this.uploadLocator); + const uploadButton = await widget.element(this.alfrescoTypeUploadLocator); await BrowserActions.click(uploadButton); await BrowserVisibility.waitUntilElementIsPresent(this.localStorageButton); await this.localStorageButton.sendKeys(fileLocation); } + async checkNoFileIsAttached(fieldId): Promise { + const widget = await this.formFields.getWidget(fieldId); + const fileItem = widget.element(this.filesListLocator).element(by.css('mat-list-item')); + await BrowserVisibility.waitUntilElementIsNotVisible(fileItem); + } + async checkFileIsAttached(fieldId, name): Promise { const widget = await this.formFields.getWidget(fieldId); const fileAttached = widget.element(this.filesListLocator).element(by.cssContainingText('mat-list-item span ', name)); await BrowserVisibility.waitUntilElementIsVisible(fileAttached); } + async checkFilesAreAttachedToWidget(fieldId, name): Promise { + await name.forEach(async fileName => { + await this.checkFileIsAttached(fieldId, fileName); + }); + } + + async checkFileIsNotAttached(fieldId, name): Promise { + const widget = await this.formFields.getWidget(fieldId); + const fileNotAttached = widget.element(this.filesListLocator).element(by.cssContainingText('mat-list-item span ', name)); + await BrowserVisibility.waitUntilElementIsNotVisible(fileNotAttached); + } + async viewFile(name: string): Promise { const fileView = element(this.filesListLocator).element(by.cssContainingText('mat-list-item span ', name)); await BrowserActions.click(fileView); @@ -105,11 +123,29 @@ export class AttachFileWidgetPage { } async checkUploadIsNotVisible(fieldId): Promise { + const alfrescoTypeUploadLocator = by.css(`button[id="${fieldId}"]`); const widget = await this.formFields.getWidget(fieldId); - const uploadButton = await widget.element(this.uploadLocator); + const uploadButton = await widget.element(alfrescoTypeUploadLocator); await BrowserVisibility.waitUntilElementIsNotPresent(uploadButton); } + async checkUploadIsVisible(fieldId): Promise { + const alfrescoTypeUploadLocator = by.css(`button[id="${fieldId}"]`); + const widget = await this.formFields.getWidget(fieldId); + const uploadButton = await widget.element(alfrescoTypeUploadLocator); + await BrowserVisibility.waitUntilElementIsPresent(uploadButton); + } + + async checkLocalTypeUploadIsPresent(fieldId): Promise { + const localTypeUpload = element(by.css(`input[id="${fieldId}"]`)); + await BrowserVisibility.waitUntilElementIsPresent(localTypeUpload); + } + + async checkLocalTypeUploadIsNotPresent(fieldId): Promise { + const localTypeUpload = element(by.css(`input[id="${fieldId}"]`)); + await BrowserVisibility.waitUntilElementIsNotPresent(localTypeUpload); + } + async selectUploadSource(name: string): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.attachedFileOptions); await BrowserActions.click(element(by.css(`button[id="attach-${name}"]`))); @@ -118,7 +154,7 @@ export class AttachFileWidgetPage { async clickUploadButton(fieldId): Promise { await BrowserActions.closeMenuAndDialogs(); const widget = await this.formFields.getWidget(fieldId); - const uploadButton = await widget.element(this.uploadLocator); + const uploadButton = await widget.element(this.alfrescoTypeUploadLocator); await BrowserActions.click(uploadButton); } } diff --git a/lib/testing/src/lib/process-services/pages/start-process.page.ts b/lib/testing/src/lib/process-services/pages/start-process.page.ts index 4f83401fae..7230954660 100644 --- a/lib/testing/src/lib/process-services/pages/start-process.page.ts +++ b/lib/testing/src/lib/process-services/pages/start-process.page.ts @@ -170,4 +170,10 @@ export class StartProcessPage { await this.selectFromProcessDropdown(processName); await this.clickStartProcessButton(); } + + async selectApplicationAndProcess(applicationName: string, processName: string) { + await this.selectFromApplicationDropdown(applicationName); + await this.checkProcessDefinitionDropdownIsEnabled(); + await this.selectFromProcessDropdown(processName); + } }