From f918d9ee268ce5d7fa9987f69b96655eaa4ff389 Mon Sep 17 00:00:00 2001 From: Roxana Diacenco Date: Fri, 6 Nov 2020 11:49:31 +0200 Subject: [PATCH] [ACA-3373] Add e2e multi item select method in DataTable component (#6129) * [ACA-3373] Update data-table component page object methods * Remove one line methods * Fix datatable-component and e2e test * Fix standalone-task-e2e test * Remove browser.sleep call --- .../pages/attachment-list.page.ts | 6 +-- ...process-attachment-list-action-menu.e2e.ts | 1 + e2e/process-services/standalone-task.e2e.ts | 4 +- .../core/pages/data-table-component.page.ts | 39 +++++++++++++++---- .../src/lib/core/utils/browser-actions.ts | 1 - 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/e2e/process-services/pages/attachment-list.page.ts b/e2e/process-services/pages/attachment-list.page.ts index 4268d14f8f..1bcf484d37 100644 --- a/e2e/process-services/pages/attachment-list.page.ts +++ b/e2e/process-services/pages/attachment-list.page.ts @@ -75,14 +75,14 @@ export class AttachmentListPage { async doubleClickFile(name: string): Promise { await BrowserActions.closeMenuAndDialogs(); - await BrowserVisibility.waitUntilElementIsVisible(element.all(by.css('div[data-automation-id="' + name + '"]')).first()); - const fileAttached = element.all(by.css('div[data-automation-id="' + name + '"]')).first(); + await BrowserVisibility.waitUntilElementIsVisible(element.all(by.css(`div[data-automation-id="${name}"]`)).first()); + const fileAttached = element.all(by.css(`div[data-automation-id="${name}"]`)).first(); await BrowserActions.click(fileAttached); await browser.actions().sendKeys(protractor.Key.ENTER).perform(); } async checkFileIsRemoved(name: string): Promise { - const fileAttached = element.all(by.css('div[data-automation-id="' + name + '"]')).first(); + const fileAttached = element.all(by.css(`div[data-automation-id="${name}"]`)).first(); await BrowserVisibility.waitUntilElementIsNotVisible(fileAttached); } diff --git a/e2e/process-services/process-attachment-list-action-menu.e2e.ts b/e2e/process-services/process-attachment-list-action-menu.e2e.ts index 2a8446e912..fc9fe55b34 100644 --- a/e2e/process-services/process-attachment-list-action-menu.e2e.ts +++ b/e2e/process-services/process-attachment-list-action-menu.e2e.ts @@ -132,6 +132,7 @@ describe('Attachment list action menu for processes', () => { await processFiltersPage.selectFromProcessList(processName.completed); await processDetailsPage.checkProcessTitleIsDisplayed(); + await processFiltersPage.waitForTableBody(); await attachmentListPage.clickAttachFileButton(pngFile.location); await attachmentListPage.checkFileIsAttached(pngFile.name); diff --git a/e2e/process-services/standalone-task.e2e.ts b/e2e/process-services/standalone-task.e2e.ts index b3a78a2c86..363927bea8 100644 --- a/e2e/process-services/standalone-task.e2e.ts +++ b/e2e/process-services/standalone-task.e2e.ts @@ -54,12 +54,12 @@ describe('Start Task - Task App', () => { await apiService.getInstance().activiti.appsApi.importAppDefinition(file); await loginPage.login(processUserModel.email, processUserModel.password); - }); + }); beforeEach(async () => { await (await (await navigationBarPage.navigateToProcessServicesPage()).goToTaskApp()).clickTasksButton(); await taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.MY_TASKS); - }); + }); it('[C260421] Should a standalone task be displayed when creating a new task without form', async () => { const task = await taskPage.createNewTask(); diff --git a/lib/testing/src/lib/core/pages/data-table-component.page.ts b/lib/testing/src/lib/core/pages/data-table-component.page.ts index bcfae645e4..41e680bb23 100644 --- a/lib/testing/src/lib/core/pages/data-table-component.page.ts +++ b/lib/testing/src/lib/core/pages/data-table-component.page.ts @@ -105,6 +105,28 @@ export class DataTableComponentPage { await browser.actions().sendKeys(protractor.Key.NULL).perform(); } + async selectMultipleRows(columnName: string, items: string[]): Promise { + await browser.actions().sendKeys(protractor.Key.ESCAPE).perform(); + await this.clearRowsSelection(); + await browser.actions().sendKeys(protractor.Key.COMMAND).perform(); + for (const item of items) { + await this.selectRow(columnName, item); + } + await browser.actions().sendKeys(protractor.Key.NULL).perform(); + } + + async clearRowsSelection(): Promise { + try { + const count = await this.getNumberOfSelectedRows(); + if (count !== 0) { + await browser.refresh(); + await BrowserVisibility.waitUntilElementIsVisible(this.rootElement); + } + } catch (error) { + Logger.error('------ clearSelection catch : ', error); + } + } + async checkRowIsSelected(columnName: string, columnValue: string): Promise { const selectedRow = this.getCellElementByValue(columnName, columnValue).element(by.xpath(`ancestor::adf-datatable-row[contains(@class, 'is-selected')]`)); await BrowserVisibility.waitUntilElementIsVisible(selectedRow); @@ -159,11 +181,7 @@ export class DataTableComponentPage { } async rightClickOnRow(columnName: string, columnValue: string): Promise { - Logger.log(`Right Click On Row ${columnName} ${columnValue}`); - - const row = this.getRow(columnName, columnValue); - await BrowserActions.rightClick(row); - + await this.rightClickOnItem(columnName, columnValue); await BrowserVisibility.waitUntilElementIsVisible(element(by.id('adf-context-menu-content'))); } @@ -177,6 +195,11 @@ export class DataTableComponentPage { await BrowserVisibility.waitUntilElementIsVisible(element(by.id('adf-context-menu-content'))); } + async rightClickOnItem(columnName: string, columnValue: string): Promise { + const row = this.getRow(columnName, columnValue); + await BrowserActions.rightClick(row); + } + getFileHyperlink(filename: string): ElementFinder { return element(by.cssContainingText('adf-name-column[class*="adf-datatable-link"] span', filename)); } @@ -292,7 +315,7 @@ export class DataTableComponentPage { } getRow(columnName: string, columnValue: string): ElementFinder { - return this.rootElement.all(by.xpath(`//div[@title="${columnName}"]//div[@data-automation-id="text_${columnValue}"]//ancestor::adf-datatable-row[contains(@class, 'adf-datatable-row')]`)).first(); + return this.rootElement.all(by.xpath(`//div[@title='${columnName}']//div[contains(@data-automation-id, '${columnValue}')]//ancestor::adf-datatable-row[contains(@class, 'adf-datatable-row')]`)).first(); } getRowByIndex(index: number): ElementFinder { @@ -304,8 +327,8 @@ export class DataTableComponentPage { return BrowserActions.getText(this.contents.get(position - 1)); } - getCellElementByValue(columnName: string, columnValue: string): ElementFinder { - return this.rootElement.all(by.css(`div[title="${columnName}"] div[data-automation-id="text_${columnValue}"] span`)).first(); + getCellElementByValue(columnName: string, columnValue: string, columnPrefix = 'text_'): ElementFinder { + return this.rootElement.all(by.css(`div[title="${columnName}"] div[data-automation-id="${columnPrefix}${columnValue}"] span`)).first(); } async tableIsLoaded(): Promise { diff --git a/lib/testing/src/lib/core/utils/browser-actions.ts b/lib/testing/src/lib/core/utils/browser-actions.ts index 94686f6c53..4038c956e8 100644 --- a/lib/testing/src/lib/core/utils/browser-actions.ts +++ b/lib/testing/src/lib/core/utils/browser-actions.ts @@ -215,5 +215,4 @@ export class BrowserActions { stream.write(Buffer.from(pngData, 'base64')); stream.end(); } - }