From 609ae3a3ffd32b8839e94e0c20fa680ea4eb920d Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Wed, 28 Aug 2019 23:25:06 +0100 Subject: [PATCH] fix content service document list action test (#5027) * fix content service document list action test * restore build.sh * perform twice movement mosue for right click for avoid bug in non headless chrome * change sso ref element present * change sso ref element present --- .../document-list-actions.e2e.ts | 7 ++- .../breadcrumb/breadCrumbDropdownPage.ts | 3 +- e2e/pages/adf/demo-shell/dataTablePage.ts | 32 +++++----- lib/testing/ng-package.json | 7 ++- .../pages/document-list.page.ts | 16 ++--- .../core/pages/data-table-component.page.ts | 61 +++++++++---------- .../src/lib/core/pages/login-sso.page.ts | 2 +- .../src/lib/core/utils/browser-actions.ts | 3 +- scripts/travis/build/build.sh | 12 +++- 9 files changed, 77 insertions(+), 66 deletions(-) diff --git a/e2e/content-services/document-list/document-list-actions.e2e.ts b/e2e/content-services/document-list/document-list-actions.e2e.ts index a7132b0cee..7a13ff530e 100644 --- a/e2e/content-services/document-list/document-list-actions.e2e.ts +++ b/e2e/content-services/document-list/document-list-actions.e2e.ts @@ -101,7 +101,6 @@ describe('Document List Component - Actions', () => { beforeEach(async () => { await navigationBarPage.clickContentServicesButton(); - }); describe('File Actions', () => { @@ -288,21 +287,26 @@ describe('Document List Component - Actions', () => { }); it('[C260132] Move action on folder with - Load more', async () => { + await expect(await paginationPage.getCurrentItemsPerPage()).toEqual('5'); await expect(await paginationPage.getPaginationRange()).toEqual('Showing 1-' + 5 + ' of ' + 6); + await contentServicesPage.getDocumentList().rightClickOnRow('A' + folderModel1.name); await contentServicesPage.checkContextActionIsVisible('Move'); await contentServicesPage.pressContextMenuActionNamed('Move'); await contentNodeSelector.checkDialogIsDisplayed(); + await expect(await contentNodeSelector.getDialogHeaderText()).toBe('Move \'' + 'A' + folderModel1.name + '\' to...'); await contentNodeSelector.checkSearchInputIsDisplayed(); await expect(await contentNodeSelector.getSearchLabel()).toBe('Search'); await contentNodeSelector.checkSelectedSiteIsDisplayed('My files'); await contentNodeSelector.checkCancelButtonIsDisplayed(); await contentNodeSelector.checkMoveCopyButtonIsDisplayed(); + await expect(await contentNodeSelector.getMoveCopyButtonText()).toBe('MOVE'); await expect(await contentNodeSelector.numberOfResultsDisplayed()).toBe(5); await infinitePaginationPage.clickLoadMoreButton(); + await expect(await contentNodeSelector.numberOfResultsDisplayed()).toBe(6); await infinitePaginationPage.checkLoadMoreButtonIsNotDisplayed(); await contentNodeSelector.contentListPage().dataTablePage().selectRowByContent('F' + folderModel6.name); @@ -336,7 +340,6 @@ describe('Document List Component - Actions', () => { await breadCrumbPage.chooseBreadCrumb(contentServicesUser.id); await contentServicesPage.waitForTableBody(); await contentServicesPage.checkContentIsDisplayed('A' + folderModel1.name); - }); it('[C305051] Copy action on folder with - Load more', async () => { diff --git a/e2e/pages/adf/content-services/breadcrumb/breadCrumbDropdownPage.ts b/e2e/pages/adf/content-services/breadcrumb/breadCrumbDropdownPage.ts index 456bd71fa8..0f8b70d6c9 100644 --- a/e2e/pages/adf/content-services/breadcrumb/breadCrumbDropdownPage.ts +++ b/e2e/pages/adf/content-services/breadcrumb/breadCrumbDropdownPage.ts @@ -22,14 +22,13 @@ export class BreadCrumbDropdownPage { breadCrumb: ElementFinder = element(by.css(`adf-dropdown-breadcrumb[data-automation-id='content-node-selector-content-breadcrumb']`)); parentFolder = this.breadCrumb.element(by.css(`button[data-automation-id='dropdown-breadcrumb-trigger']`)); - breadCrumbDropdown: ElementFinder = element(by.css(`div[class*='mat-select-panel']`)); + breadCrumbDropdown: ElementFinder = element.all(by.css(`div[class*='mat-select-panel']`)).first(); currentFolder = this.breadCrumb.element(by.css(`div span[data-automation-id="current-folder"]`)); async choosePath(pathName): Promise { const path = this.breadCrumbDropdown.element(by.cssContainingText(`mat-option[data-automation-class='dropdown-breadcrumb-path-option'] span[class='mat-option-text']`, pathName)); await BrowserActions.click(path); - } async clickParentFolder(): Promise { diff --git a/e2e/pages/adf/demo-shell/dataTablePage.ts b/e2e/pages/adf/demo-shell/dataTablePage.ts index 5dc6d8537a..4ca5b454ba 100644 --- a/e2e/pages/adf/demo-shell/dataTablePage.ts +++ b/e2e/pages/adf/demo-shell/dataTablePage.ts @@ -83,7 +83,7 @@ export class DataTablePage { await BrowserActions.click(this.reset); } - async checkRowIsNotSelected(rowNumber): Promise { + async checkRowIsNotSelected(rowNumber: string): Promise { const isRowSelected = this.dataTable.getCellElementByValue(this.columns.id, rowNumber) .element(by.xpath(`ancestor::div[contains(@class, 'adf-datatable-row custom-row-style ng-star-inserted is-selected')]`)); await BrowserVisibility.waitUntilElementIsNotVisible(isRowSelected); @@ -97,11 +97,11 @@ export class DataTablePage { await BrowserActions.click(this.selectAll); } - async checkRowIsChecked(rowNumber): Promise { + async checkRowIsChecked(rowNumber: string): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.getRowCheckbox(rowNumber)); } - async checkRowIsNotChecked(rowNumber): Promise { + async checkRowIsNotChecked(rowNumber: string): Promise { await BrowserVisibility.waitUntilElementIsNotVisible(this.getRowCheckbox(rowNumber)); } @@ -109,19 +109,19 @@ export class DataTablePage { return this.allSelectedRows.count(); } - async clickCheckbox(rowNumber): Promise { + async clickCheckbox(rowNumber: string): Promise { await BrowserActions.closeMenuAndDialogs(); const checkbox = this.dataTable.getCellElementByValue(this.columns.id, rowNumber) .element(by.xpath(`ancestor::div[contains(@class, 'adf-datatable-row')]//mat-checkbox/label`)); await BrowserActions.click(checkbox); } - async selectRow(rowNumber): Promise { + async selectRow(rowNumber: string): Promise { const row = this.dataTable.getCellElementByValue(this.columns.id, rowNumber); await BrowserActions.click(row); } - async selectRowWithKeyboard(rowNumber): Promise { + async selectRowWithKeyboard(rowNumber: string): Promise { await browser.actions().sendKeys(protractor.Key.COMMAND).perform(); await this.selectRow(rowNumber); await browser.actions().sendKeys(protractor.Key.NULL).perform(); @@ -133,7 +133,7 @@ export class DataTablePage { await BrowserActions.click(selectMode); } - getRowCheckbox(rowNumber): ElementFinder { + getRowCheckbox(rowNumber: string): ElementFinder { return this.dataTable.getCellElementByValue(this.columns.id, rowNumber).element(by.xpath(`ancestor::div/div/mat-checkbox[contains(@class, 'mat-checkbox-checked')]`)); } @@ -141,23 +141,25 @@ export class DataTablePage { return await this.dataTable.getCopyContentTooltip(); } - async mouseOverNameColumn(name): Promise { + async mouseOverNameColumn(name: string): Promise { await this.dataTable.mouseOverColumn(this.columns.name, name); } - async mouseOverCreatedByColumn(name): Promise { + async mouseOverCreatedByColumn(name: string): Promise { await this.dataTable.mouseOverColumn(this.columns.createdBy, name); } - async mouseOverIdColumn(name): Promise { + async mouseOverIdColumn(name: string): Promise { await this.dataTable.mouseOverColumn(this.columns.id, name); } - async mouseOverJsonColumn(rowNumber): Promise { - await this.dataTable.mouseOverElement(this.dataTable.getCellByRowNumberAndColumnName(rowNumber - 1, this.columns.json)); + async mouseOverJsonColumn(rowNumber: number): Promise { + const cell = this.dataTable.getCellByRowNumberAndColumnName(rowNumber - 1, this.columns.json); + await BrowserVisibility.waitUntilElementIsVisible(cell); + await browser.actions().mouseMove(cell).perform(); } - getDropTargetIdColumnCell(rowNumber): ElementFinder { + getDropTargetIdColumnCell(rowNumber: number): ElementFinder { return this.dataTable.getCellByRowNumberAndColumnName(rowNumber - 1, this.columns.id); } @@ -165,11 +167,11 @@ export class DataTablePage { return this.idColumnHeader; } - async clickOnIdColumn(name): Promise { + async clickOnIdColumn(name: string): Promise { await this.dataTable.clickColumn(this.columns.id, name); } - async clickOnJsonColumn(rowNumber): Promise { + async clickOnJsonColumn(rowNumber: number): Promise { await BrowserActions.click(this.dataTable.getCellByRowNumberAndColumnName(rowNumber - 1, this.columns.json)); } diff --git a/lib/testing/ng-package.json b/lib/testing/ng-package.json index 9819400163..0a197a6969 100644 --- a/lib/testing/ng-package.json +++ b/lib/testing/ng-package.json @@ -3,6 +3,11 @@ "dest": "../dist/testing", "lib": { "entryFile": "src/public-api.ts", - "flatModuleFile": "adf-testing" + "flatModuleFile": "adf-testing", + "umdModuleIds": { + "@alfresco/js-api": "@alfresco/js-api", + "@alfresco/adf-core": "@alfresco/adf-core", + "moment-es6": "moment-es6" + } } } diff --git a/lib/testing/src/lib/content-services/pages/document-list.page.ts b/lib/testing/src/lib/content-services/pages/document-list.page.ts index 79c62ff3ca..7750a04348 100644 --- a/lib/testing/src/lib/content-services/pages/document-list.page.ts +++ b/lib/testing/src/lib/content-services/pages/document-list.page.ts @@ -34,13 +34,13 @@ export class DocumentListPage { this.tableBody = rootElement.all(by.css('div[class="adf-datatable-body"]')).first(); } - async checkLockedIcon(content): Promise { + async checkLockedIcon(content: string): Promise { const row = this.dataTable.getRow('Display name', content); const lockIcon = row.element(by.cssContainingText('div[title="Lock"] mat-icon', 'lock')); await BrowserVisibility.waitUntilElementIsVisible(lockIcon); } - async checkUnlockedIcon(content): Promise { + async checkUnlockedIcon(content: string): Promise { const row = this.dataTable.getRow('Display name', content); const lockIcon = row.element(by.cssContainingText('div[title="Lock"] mat-icon', 'lock_open')); await BrowserVisibility.waitUntilElementIsVisible(lockIcon); @@ -50,19 +50,19 @@ export class DocumentListPage { await BrowserVisibility.waitUntilElementIsVisible(this.tableBody); } - async getTooltip(nodeName): Promise { + async getTooltip(nodeName: string): Promise { return await this.dataTable.getTooltip('Display name', nodeName); } - async selectRow(nodeName): Promise { + async selectRow(nodeName: string): Promise { await this.dataTable.selectRow('Display name', nodeName); } - async rightClickOnRow(nodeName): Promise { + async rightClickOnRow(nodeName: string): Promise { await this.dataTable.rightClickOnRow('Display name', nodeName); } - async clickOnActionMenu(content): Promise { + async clickOnActionMenu(content: string): Promise { await BrowserActions.closeMenuAndDialogs(); const row: ElementFinder = this.dataTable.getRow('Display name', content); await BrowserActions.click(row.element(this.optionButton)); @@ -78,11 +78,11 @@ export class DocumentListPage { return new DataTableComponentPage(this.rootElement); } - async getAllRowsColumnValues(column) { + async getAllRowsColumnValues(column: string) { return await this.dataTable.getAllRowsColumnValues(column); } - async doubleClickRow(nodeName): Promise { + async doubleClickRow(nodeName: string): Promise { await this.dataTable.doubleClickRow('Display name', nodeName); } } 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 8c68c3d192..b9dc0ad079 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 @@ -58,21 +58,21 @@ export class DataTableComponentPage { await BrowserVisibility.waitUntilElementIsNotVisible(this.selectAll.element(by.css('input[aria-checked="true"]'))); } - async clickCheckbox(columnName, columnValue): Promise { + async clickCheckbox(columnName: string, columnValue): Promise { const checkbox = this.getRowCheckbox(columnName, columnValue); await BrowserActions.click(checkbox); } - async checkRowIsNotChecked(columnName, columnValue): Promise { + async checkRowIsNotChecked(columnName: string, columnValue): Promise { await BrowserVisibility.waitUntilElementIsNotVisible(this.getRowCheckbox(columnName, columnValue).element(by.css('input[aria-checked="true"]'))); } - async checkRowIsChecked(columnName, columnValue): Promise { + async checkRowIsChecked(columnName: string, columnValue): Promise { const rowCheckbox = this.getRowCheckbox(columnName, columnValue); await BrowserVisibility.waitUntilElementIsVisible(rowCheckbox.element(by.css('input[aria-checked="true"]'))); } - getRowCheckbox(columnName, columnValue): ElementFinder { + getRowCheckbox(columnName: string, columnValue): ElementFinder { return this.getRow(columnName, columnValue).element(by.css('mat-checkbox')); } @@ -138,10 +138,10 @@ export class DataTableComponentPage { return initialList.toString() === sortedList.toString(); } - async rightClickOnRow(columnName, columnValue): Promise { + async rightClickOnRow(columnName: string, columnValue): Promise { const row = this.getRow(columnName, columnValue); - await browser.actions().mouseMove(row).perform(); - await browser.actions().click(row, protractor.Button.RIGHT).perform(); + await BrowserActions.rightClick(row); + await BrowserVisibility.waitUntilElementIsVisible(element(by.id('adf-context-menu-content'))); } @@ -155,7 +155,7 @@ export class DataTableComponentPage { await BrowserVisibility.waitUntilElementIsVisible(element(by.id('adf-context-menu-content'))); } - getFileHyperlink(filename): ElementFinder { + getFileHyperlink(filename: string): ElementFinder { return element(by.cssContainingText('adf-name-column[class*="adf-datatable-link"] span', filename)); } @@ -163,7 +163,7 @@ export class DataTableComponentPage { return await this.rootElement.all(this.rows).count(); } - async getAllRowsColumnValues(column) { + async getAllRowsColumnValues(column: string) { const columnLocator = by.css("adf-datatable div[class*='adf-datatable-body'] div[class*='adf-datatable-row'] div[title='" + column + "'] span"); await BrowserVisibility.waitUntilElementIsPresent(element.all(columnLocator).first()); return await element.all(columnLocator) @@ -171,7 +171,7 @@ export class DataTableComponentPage { .map(async (el) => await el.getText()); } - async getRowsWithSameColumnValues(columnName, columnValue) { + async getRowsWithSameColumnValues(columnName: string, columnValue) { const columnLocator = by.css(`div[title='${columnName}'] div[data-automation-id="text_${columnValue}"] span`); await BrowserVisibility.waitUntilElementIsVisible(this.rootElement.all(columnLocator).first()); return this.rootElement.all(columnLocator).getText(); @@ -187,12 +187,12 @@ export class DataTableComponentPage { await BrowserVisibility.waitUntilElementIsVisible(this.tableBody); } - async getFirstElementDetail(detail): Promise { + async getFirstElementDetail(detail: string): Promise { const firstNode = element.all(by.css(`adf-datatable div[title="${detail}"] span`)).first(); return await BrowserActions.getText(firstNode); } - geCellElementDetail(detail): ElementArrayFinder { + geCellElementDetail(detail: string): ElementArrayFinder { return element.all(by.css(`adf-datatable div[title="${detail}"] span`)); } @@ -221,31 +221,30 @@ export class DataTableComponentPage { } } - async checkContentIsDisplayed(columnName, columnValue): Promise { + async checkContentIsDisplayed(columnName: string, columnValue: string): Promise { const row = this.getCellElementByValue(columnName, columnValue); await BrowserVisibility.waitUntilElementIsVisible(row); } - async checkContentIsNotDisplayed(columnName, columnValue): Promise { + async checkContentIsNotDisplayed(columnName: string, columnValue: string): Promise { const row = this.getCellElementByValue(columnName, columnValue); await BrowserVisibility.waitUntilElementIsNotVisible(row); } - getRow(columnName, columnValue): ElementFinder { - return this.rootElement.all(by.css(`div[title="${columnName}"] div[data-automation-id="text_${columnValue}"]`)).first() - .element(by.xpath(`ancestor::div[contains(@class, 'adf-datatable-row')]`)); + getRow(columnName: string, columnValue: string): ElementFinder { + return this.rootElement.all(by.xpath(`//div[@title="${columnName}"]//div[@data-automation-id="text_${columnValue}"]//ancestor::div[contains(@class, 'adf-datatable-row')]`)).first(); } getRowByIndex(index: number): ElementFinder { return this.rootElement.element(by.xpath(`//div[contains(@class,'adf-datatable-body')]//div[contains(@class,'adf-datatable-row')][${index}]`)); } - async contentInPosition(position): Promise { + async contentInPosition(position: number): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.contents.first()); return await BrowserActions.getText(this.contents.get(position - 1)); } - getCellElementByValue(columnName, columnValue): ElementFinder { + getCellElementByValue(columnName: string, columnValue: string): ElementFinder { return this.rootElement.all(by.css(`div[title="${columnName}"] div[data-automation-id="text_${columnValue}"] span`)).first(); } @@ -301,33 +300,33 @@ export class DataTableComponentPage { await BrowserVisibility.waitUntilElementIsVisible(cell); } - async clickRowByContent(name): Promise { + async clickRowByContent(name: string): Promise { const resultElement = this.rootElement.all(by.css(`div[data-automation-id='${name}']`)).first(); await BrowserActions.click(resultElement); } - async clickRowByContentCheckbox(name): Promise { + async clickRowByContentCheckbox(name: string): Promise { const resultElement = this.rootElement.all(by.css(`div[data-automation-id='${name}']`)).first().element(by.xpath(`ancestor::div/div/mat-checkbox`)); await browser.actions().mouseMove(resultElement); await BrowserActions.click(resultElement); } - async checkRowContentIsDisplayed(content): Promise { + async checkRowContentIsDisplayed(content: string): Promise { const resultElement = this.rootElement.all(by.css(`div[data-automation-id='${content}']`)).first(); await BrowserVisibility.waitUntilElementIsVisible(resultElement); } - async checkRowContentIsNotDisplayed(content): Promise { + async checkRowContentIsNotDisplayed(content: string): Promise { const resultElement = this.rootElement.all(by.css(`div[data-automation-id='${content}']`)).first(); await BrowserVisibility.waitUntilElementIsNotVisible(resultElement); } - async checkRowContentIsDisabled(content): Promise { + async checkRowContentIsDisabled(content: string): Promise { const resultElement = this.rootElement.all(by.css(`div[data-automation-id='${content}'] div.adf-cell-value img[aria-label='disable']`)).first(); await BrowserVisibility.waitUntilElementIsVisible(resultElement); } - async doubleClickRowByContent(name): Promise { + async doubleClickRowByContent(name: string): Promise { const resultElement = this.rootElement.all(by.css(`div[data-automation-id='${name}']`)).first(); await BrowserActions.click(resultElement); await browser.actions().sendKeys(protractor.Key.ENTER).perform(); @@ -341,17 +340,13 @@ export class DataTableComponentPage { await BrowserVisibility.waitUntilElementIsStale(this.copyColumnTooltip); } - async mouseOverColumn(columnName, columnValue): Promise { + async mouseOverColumn(columnName: string, columnValue): Promise { const column = this.getCellElementByValue(columnName, columnValue); - await this.mouseOverElement(column); + await BrowserVisibility.waitUntilElementIsVisible(column); + await browser.actions().mouseMove(column).perform(); } - async mouseOverElement(elem): Promise { - await BrowserVisibility.waitUntilElementIsVisible(elem); - await browser.actions().mouseMove(elem).perform(); - } - - async clickColumn(columnName, columnValue): Promise { + async clickColumn(columnName: string, columnValue: string): Promise { await BrowserActions.clickExecuteScript(`div[title="${columnName}"] div[data-automation-id="text_${columnValue}"] span`); } } diff --git a/lib/testing/src/lib/core/pages/login-sso.page.ts b/lib/testing/src/lib/core/pages/login-sso.page.ts index 036647b311..cb9d23467d 100644 --- a/lib/testing/src/lib/core/pages/login-sso.page.ts +++ b/lib/testing/src/lib/core/pages/login-sso.page.ts @@ -25,7 +25,7 @@ export class LoginSSOPage { usernameField = element(by.id('username')); passwordField = element(by.id('password')); loginButton = element(by.css('input[type="submit"]')); - header = element(by.id('adf-header')); + header = element(by.tagName('adf-layout-header')); loginError = element(by.css(`div[data-automation-id="login-error"]`)); async loginSSOIdentityService(username, password) { diff --git a/lib/testing/src/lib/core/utils/browser-actions.ts b/lib/testing/src/lib/core/utils/browser-actions.ts index 116bab2d66..2fadac5402 100644 --- a/lib/testing/src/lib/core/utils/browser-actions.ts +++ b/lib/testing/src/lib/core/utils/browser-actions.ts @@ -77,8 +77,7 @@ export class BrowserActions { } static async rightClick(elementFinder: ElementFinder): Promise { - await BrowserVisibility.waitUntilElementIsVisible(elementFinder); - await browser.actions().mouseMove(elementFinder).perform(); + await browser.actions().mouseMove(elementFinder).mouseDown().mouseMove(elementFinder).perform(); await browser.actions().click(elementFinder, protractor.Button.RIGHT).perform(); } diff --git a/scripts/travis/build/build.sh b/scripts/travis/build/build.sh index 21144f3685..7ce253bfe9 100755 --- a/scripts/travis/build/build.sh +++ b/scripts/travis/build/build.sh @@ -10,9 +10,17 @@ rm -rf tmp && mkdir tmp; if [[ $TRAVIS_PULL_REQUEST == "false" ]]; then - ./scripts/update-version.sh -nextalpha -gnu -minor -components - ./scripts/npm-build-all.sh -c || exit 1; + + if [[ $TRAVIS_BRANCH == "development" ]]; + then + ./scripts/update-version.sh -gnu -alpha || exit 1; + fi + + ./scripts/npm-build-all.sh || exit 1; else + ./scripts/update-version.sh -gnu -alpha || exit 1; + npm install; + ./scripts/lint.sh || exit 1; ./scripts/smart-build.sh -b $TRAVIS_BRANCH -gnu || exit 1; fi;