[ADF-5463] Rework Protractor tests - changes related to element/element… (#7284)

* ADF-5463 Rework Protractor tests - changes related to element/elements and duplication of locators

* Fix one which I missed

* Remove console.logs

* Remove console.logs

* Reverse the timeouts

* Fixed things TSLint

* Remove unused import

* Fixed broken tests

* Last test fixed
This commit is contained in:
MichalFidor
2021-10-08 17:28:37 +02:00
committed by GitHub
parent db6a638a2d
commit 1e62b46060
156 changed files with 1653 additions and 1647 deletions

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { by, element } from 'protractor';
import { $, $$ } from 'protractor';
import { BrowserActions, TestElement } from '@alfresco/adf-testing';
export class CreateLibraryDialogPage {
@@ -30,11 +30,11 @@ export class CreateLibraryDialogPage {
cancelButton = TestElement.byCss('button[data-automation-id="cancel-library-id"]');
createButton = TestElement.byCss('button[data-automation-id="create-library-id"]');
errorMessage = TestElement.byCss('.mat-dialog-content .mat-error');
errorMessages = element.all(by.css('.mat-dialog-content .mat-error'));
errorMessages = $$('.mat-dialog-content .mat-error');
libraryNameHint = TestElement.byCss('adf-library-dialog .mat-hint');
async getSelectedRadio(): Promise<string> {
const radio = element(by.css('.mat-radio-button[class*="checked"]'));
const radio = $('.mat-radio-button[class*="checked"]');
return BrowserActions.getText(radio);
}

View File

@@ -15,18 +15,18 @@
* limitations under the License.
*/
import { by, element, ElementFinder } from 'protractor';
import { $$, ElementFinder } from 'protractor';
import { BrowserVisibility, BrowserActions } from '@alfresco/adf-testing';
export class FolderDialogPage {
folderDialog = element.all(by.css('adf-folder-dialog')).first();
folderNameField = this.folderDialog.element(by.id('adf-folder-name-input'));
folderDescriptionField = this.folderDialog.element(by.id('adf-folder-description-input'));
createUpdateButton = this.folderDialog.element(by.id('adf-folder-create-button'));
cancelButton = this.folderDialog.element(by.id('adf-folder-cancel-button'));
folderTitle = this.folderDialog.element((by.css('h2.mat-dialog-title')));
validationMessage = this.folderDialog.element(by.css('div.mat-form-field-subscript-wrapper mat-hint span'));
folderDialog = $$('adf-folder-dialog').first();
folderNameField = this.folderDialog.$('#adf-folder-name-input');
folderDescriptionField = this.folderDialog.$('#adf-folder-description-input');
createUpdateButton = this.folderDialog.$('#adf-folder-create-button');
cancelButton = this.folderDialog.$('#adf-folder-cancel-button');
folderTitle = this.folderDialog.$('h2.mat-dialog-title');
validationMessage = this.folderDialog.$('div.mat-form-field-subscript-wrapper mat-hint span');
async getDialogTitle(): Promise<string> {
return BrowserActions.getText(this.folderTitle);

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { element, by } from 'protractor';
import { $$, $ } from 'protractor';
import { BrowserVisibility, TogglePage, BrowserActions, DateTimePickerPage } from '@alfresco/adf-testing';
import moment = require('moment');
@@ -23,18 +23,18 @@ export class ShareDialogPage {
togglePage = new TogglePage();
dateTimePickerPage = new DateTimePickerPage();
shareDialog = element(by.css('adf-share-dialog'));
dialogTitle = element.all(by.css('[data-automation-id="adf-share-dialog-title"]')).first();
shareToggle = element(by.css('[data-automation-id="adf-share-toggle"] label'));
expireToggle = element(by.css(`[data-automation-id="adf-expire-toggle"] label`));
shareToggleChecked = element(by.css('mat-dialog-container mat-slide-toggle.mat-checked'));
shareLink = element(by.css('[data-automation-id="adf-share-link"]'));
closeButton = element(by.css('button[data-automation-id="adf-share-dialog-close"]'));
copySharedLinkButton = element(by.css('.adf-input-action'));
expirationDateInput = element(by.css('input[formcontrolname="time"]'));
confirmationDialog = element(by.css('adf-confirm-dialog'));
confirmationCancelButton = element(by.id('adf-confirm-cancel'));
confirmationRemoveButton = element(by.id('adf-confirm-accept'));
shareDialog = $('adf-share-dialog');
dialogTitle = $$('[data-automation-id="adf-share-dialog-title"]').first();
shareToggle = $('[data-automation-id="adf-share-toggle"] label');
expireToggle = $(`[data-automation-id="adf-expire-toggle"] label`);
shareToggleChecked = $('mat-dialog-container mat-slide-toggle.mat-checked');
shareLink = $('[data-automation-id="adf-share-link"]');
closeButton = $('button[data-automation-id="adf-share-dialog-close"]');
copySharedLinkButton = $('.adf-input-action');
expirationDateInput = $('input[formcontrolname="time"]');
confirmationDialog = $('adf-confirm-dialog');
confirmationCancelButton = $('#adf-confirm-cancel');
confirmationRemoveButton = $('#adf-confirm-accept');
async checkDialogIsDisplayed(): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(this.dialogTitle);
@@ -106,7 +106,7 @@ export class ShareDialogPage {
}
async dateTimePickerDialogIsClosed(): Promise<void> {
await BrowserVisibility.waitUntilElementIsStale(element(by.css('mat-datetimepicker-content')));
await BrowserVisibility.waitUntilElementIsStale($('mat-datetimepicker-content'));
}
async getExpirationDate(): Promise<string> {

View File

@@ -15,28 +15,28 @@
* limitations under the License.
*/
import { element, by, browser, ElementFinder, Locator } from 'protractor';
import { element, by, browser, ElementFinder, $, $$ } from 'protractor';
import { BrowserVisibility, BrowserActions } from '@alfresco/adf-testing';
export class UploadDialogPage {
closeButton = element((by.css('footer[class*="upload-dialog__actions"] button[id="adf-upload-dialog-close"]')));
dialog = element(by.css('div[id="upload-dialog"]'));
minimizedDialog = element(by.css('div[class*="upload-dialog--minimized"]'));
uploadedStatusIcon: Locator = by.css('mat-icon[class*="status--done"]');
cancelledStatusIcon: Locator = by.css('div[class*="status--cancelled"]');
errorStatusIcon: Locator = by.css('div[class*="status--error"] mat-icon');
errorTooltip = element(by.css('div.mat-tooltip'));
closeButton = $('footer[class*="upload-dialog__actions"] button[id="adf-upload-dialog-close"]');
dialog = $('div[id="upload-dialog"]');
minimizedDialog = $('div[class*="upload-dialog--minimized"]');
uploadedStatusIcon = 'mat-icon[class*="status--done"]';
cancelledStatusIcon = 'div[class*="status--cancelled"]';
errorStatusIcon = 'div[class*="status--error"] mat-icon';
errorTooltip = $('div.mat-tooltip');
rowByRowName = by.xpath('ancestor::adf-file-uploading-list-row');
title = element(by.css('span[class*="upload-dialog__title"]'));
minimizeButton = element(by.css('mat-icon[title="Minimize"]'));
maximizeButton = element(by.css('mat-icon[title="Maximize"]'));
canUploadConfirmationTitle = element(by.css('.upload-dialog__confirmation--title'));
canUploadConfirmationDescription = element(by.css('.upload-dialog__confirmation--text'));
title = $('span[class*="upload-dialog__title"]');
minimizeButton = $('mat-icon[title="Minimize"]');
maximizeButton = $('mat-icon[title="Maximize"]');
canUploadConfirmationTitle = $('.upload-dialog__confirmation--title');
canUploadConfirmationDescription = $('.upload-dialog__confirmation--text');
confirmationDialogNoButton = element(by.partialButtonText('No'));
confirmationDialogYesButton = element(by.partialButtonText('Yes'));
cancelUploadsElement = element((by.css('footer[class*="upload-dialog__actions"] button[id="adf-upload-dialog-cancel-all"]')));
cancelUploadInProgressButton = element(by.css('div[data-automation-id="cancel-upload-progress"]'));
cancelUploadsElement = $('footer[class*="upload-dialog__actions"] button[id="adf-upload-dialog-cancel-all"]');
cancelUploadInProgressButton = $('div[data-automation-id="cancel-upload-progress"]');
async clickOnCloseButton(): Promise<void> {
await this.checkCloseButtonIsDisplayed();
@@ -59,24 +59,20 @@ export class UploadDialogPage {
await BrowserVisibility.waitUntilElementIsNotVisible(this.dialog);
}
getRowsByName(content: string): ElementFinder {
return element.all(by.css(`div[class*='uploading-row'] span[title="${content}"]`)).first();
}
async getRowByRowName(content: string): Promise<ElementFinder> {
const rows = this.getRowsByName(content);
await BrowserVisibility.waitUntilElementIsVisible(rows);
return rows.element(this.rowByRowName);
const row = await $$(`div[class*='uploading-row'] span[title="${content}"]`).last();
await BrowserVisibility.waitUntilElementIsVisible(row);
return row.element(this.rowByRowName);
}
async fileIsUploaded(content: string): Promise<void> {
const row = await this.getRowByRowName(content);
await BrowserVisibility.waitUntilElementIsVisible(row.element(this.uploadedStatusIcon), 60000);
const row: ElementFinder = await this.getRowByRowName(content);
await BrowserVisibility.waitUntilElementIsVisible(row.$(this.uploadedStatusIcon), 10000);
}
async fileIsError(content: string) {
const row = await this.getRowByRowName(content);
await BrowserVisibility.waitUntilElementIsVisible(row.element(this.errorStatusIcon));
const row: ElementFinder = await this.getRowByRowName(content);
await BrowserVisibility.waitUntilElementIsVisible(row.$(this.errorStatusIcon));
}
async filesAreUploaded(content: string[]): Promise<void> {
@@ -86,7 +82,7 @@ export class UploadDialogPage {
}
async fileIsNotDisplayedInDialog(content: string): Promise<void> {
await BrowserVisibility.waitUntilElementIsNotVisible(element(by.css(`div[class*='uploading-row'] span[title="${content}"]`)));
await BrowserVisibility.waitUntilElementIsNotVisible($(`div[class*='uploading-row'] span[title="${content}"]`));
}
async cancelUploads(): Promise<void> {
@@ -102,16 +98,16 @@ export class UploadDialogPage {
}
async fileIsCancelled(content: string): Promise<void> {
const row = await this.getRowByRowName(content);
const row: ElementFinder = await this.getRowByRowName(content);
await BrowserVisibility.waitUntilElementIsVisible(row);
await BrowserVisibility.waitUntilElementIsVisible(row.element(this.cancelledStatusIcon), 10000);
await BrowserVisibility.waitUntilElementIsVisible(row.$(this.cancelledStatusIcon), 10000);
}
async removeUploadedFile(content: string): Promise<void> {
const row = await this.getRowByRowName(content);
await BrowserVisibility.waitUntilElementIsVisible(row.element(this.uploadedStatusIcon));
const row: ElementFinder = await this.getRowByRowName(content);
await BrowserVisibility.waitUntilElementIsVisible(row.$(this.uploadedStatusIcon));
const elementRow = await this.getRowByRowName(content);
await BrowserActions.click(elementRow.element(this.uploadedStatusIcon));
await BrowserActions.click(elementRow.$(this.uploadedStatusIcon));
}
async getTitleText(): Promise<string> {
@@ -156,8 +152,8 @@ export class UploadDialogPage {
}
async displayTooltip(): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(element(this.errorStatusIcon));
await browser.actions().mouseMove(element(this.errorStatusIcon)).perform();
await BrowserVisibility.waitUntilElementIsVisible($(this.errorStatusIcon));
await browser.actions().mouseMove($(this.errorStatusIcon)).perform();
}
async getTooltip(): Promise<string> {

View File

@@ -15,20 +15,20 @@
* limitations under the License.
*/
import { browser, by, element } from 'protractor';
import { $, browser } from 'protractor';
import { BrowserActions, BrowserVisibility, TogglePage } from '@alfresco/adf-testing';
export class UploadTogglesPage {
togglePage = new TogglePage();
multipleFileUploadToggle = element(by.id('adf-multiple-upload-switch'));
uploadFolderToggle = element(by.css('#adf-folder-upload-switch'));
extensionFilterToggle = element(by.id('adf-extension-filter-upload-switch'));
maxSizeToggle = element(by.id('adf-max-size-filter-upload-switch'));
versioningToggle = element(by.id('adf-version-upload-switch'));
extensionAcceptedField = element(by.css('input[data-automation-id="accepted-files-type"]'));
maxSizeField = element(by.css('input[data-automation-id="max-files-size"]'));
disableUploadCheckbox = element(by.css('[id="adf-disable-upload"]'));
multipleFileUploadToggle = $('#adf-multiple-upload-switch');
uploadFolderToggle = $('#adf-folder-upload-switch');
extensionFilterToggle = $('#adf-extension-filter-upload-switch');
maxSizeToggle = $('#adf-max-size-filter-upload-switch');
versioningToggle = $('#adf-version-upload-switch');
extensionAcceptedField = $('input[data-automation-id="accepted-files-type"]');
maxSizeField = $('input[data-automation-id="max-files-size"]');
disableUploadCheckbox = $('[id="adf-disable-upload"]');
async enableMultipleFileUpload(): Promise<void> {
await browser.executeScript('arguments[0].scrollIntoView()', this.multipleFileUploadToggle);
@@ -46,7 +46,7 @@ export class UploadTogglesPage {
async checkFolderUploadToggleIsEnabled(): Promise<boolean> {
try {
const enabledFolderUpload = element(by.css('mat-slide-toggle[id="adf-folder-upload-switch"][class*="mat-checked"]'));
const enabledFolderUpload = $('mat-slide-toggle[id="adf-folder-upload-switch"][class*="mat-checked"]');
await BrowserVisibility.waitUntilElementIsVisible(enabledFolderUpload);
return true;
} catch {
@@ -55,17 +55,17 @@ export class UploadTogglesPage {
}
async checkMultipleFileUploadToggleIsEnabled(): Promise<void> {
const enabledToggle = element(by.css('mat-slide-toggle[id="adf-multiple-upload-switch"][class*="mat-checked"]'));
const enabledToggle = $('mat-slide-toggle[id="adf-multiple-upload-switch"][class*="mat-checked"]');
await BrowserVisibility.waitUntilElementIsVisible(enabledToggle);
}
async checkMaxSizeToggleIsEnabled(): Promise<void> {
const enabledToggle = element(by.css('mat-slide-toggle[id="adf-max-size-filter-upload-switch"][class*="mat-checked"]'));
const enabledToggle = $('mat-slide-toggle[id="adf-max-size-filter-upload-switch"][class*="mat-checked"]');
await BrowserVisibility.waitUntilElementIsVisible(enabledToggle);
}
async checkVersioningToggleIsEnabled(): Promise<void> {
const enabledToggle = element(by.css('mat-slide-toggle[id="adf-version-upload-switch"][class*="mat-checked"]'));
const enabledToggle = $('mat-slide-toggle[id="adf-version-upload-switch"][class*="mat-checked"]');
await BrowserVisibility.waitUntilElementIsVisible(enabledToggle);
}
@@ -74,7 +74,7 @@ export class UploadTogglesPage {
}
async checkFolderUploadToggleIsNotEnabled(): Promise<boolean> {
try {
const inactiveToggleFolder = element(by.css('#adf-folder-upload-switch .mat-slide-toggle-label'));
const inactiveToggleFolder = $('#adf-folder-upload-switch .mat-slide-toggle-label');
await BrowserVisibility.waitUntilElementIsVisible(inactiveToggleFolder);
return true;
} catch {