mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
TestElement prototype to greatly reduce e2e coding time (#6525)
* TestElement prototype * introduce byText wrapper * extend TestElement api * cleanup tests a bit more * cleanup e2e * more e2e cleanup * add missing CSS classes * fix test
This commit is contained in:
@@ -381,7 +381,7 @@ export class ContentServicesPage {
|
||||
|
||||
async openCreateLibraryDialog(): Promise<void> {
|
||||
await BrowserActions.click(this.createLibraryButton);
|
||||
await this.createLibraryDialog.waitForDialogToOpen();
|
||||
await this.createLibraryDialog.libraryDialog.waitVisible();
|
||||
}
|
||||
|
||||
async createNewFolder(folderName: string): Promise<void> {
|
||||
|
@@ -15,140 +15,30 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { by, element, protractor } from 'protractor';
|
||||
import { BrowserVisibility, BrowserActions } from '@alfresco/adf-testing';
|
||||
import { by, element } from 'protractor';
|
||||
import { BrowserActions, TestElement } from '@alfresco/adf-testing';
|
||||
|
||||
export class CreateLibraryDialogPage {
|
||||
libraryDialog = element(by.css('[role="dialog"]'));
|
||||
libraryTitle = element(by.css('.adf-library-dialog>h2'));
|
||||
libraryNameField = element(by.css('input[formcontrolname="title"]'));
|
||||
libraryIdField = element(by.css('input[formcontrolname="id"]'));
|
||||
libraryDescriptionField = element(by.css('textarea[formcontrolname="description"]'));
|
||||
publicRadioButton = element(by.css('[data-automation-id="PUBLIC"]>label'));
|
||||
privateRadioButton = element(by.css('[data-automation-id="PRIVATE"]>label'));
|
||||
moderatedRadioButton = element(by.css('[data-automation-id="MODERATED"]>label'));
|
||||
cancelButton = element(by.css('button[data-automation-id="cancel-library-id"]'));
|
||||
createButton = element(by.css('button[data-automation-id="create-library-id"]'));
|
||||
errorMessage = element(by.css('.mat-dialog-content .mat-error'));
|
||||
libraryDialog = TestElement.byCss('[role="dialog"]');
|
||||
libraryTitle = TestElement.byCss('.adf-library-dialog>h2');
|
||||
libraryNameField = TestElement.byCss('input[formcontrolname="title"]');
|
||||
libraryIdField = TestElement.byCss('input[formcontrolname="id"]');
|
||||
libraryDescriptionField = TestElement.byCss('textarea[formcontrolname="description"]');
|
||||
publicRadioButton = TestElement.byCss('[data-automation-id="PUBLIC"]>label');
|
||||
privateRadioButton = TestElement.byCss('[data-automation-id="PRIVATE"]>label');
|
||||
moderatedRadioButton = TestElement.byCss('[data-automation-id="MODERATED"]>label');
|
||||
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'));
|
||||
libraryNameHint = element(by.css('adf-library-dialog .mat-hint'));
|
||||
libraryNameHint = TestElement.byCss('adf-library-dialog .mat-hint');
|
||||
|
||||
async getSelectedRadio(): Promise<string> {
|
||||
const radio = element(by.css('.mat-radio-button[class*="checked"]'));
|
||||
return BrowserActions.getText(radio);
|
||||
}
|
||||
|
||||
async waitForDialogToOpen(): Promise<void> {
|
||||
await BrowserVisibility.waitUntilElementIsVisible(this.libraryDialog);
|
||||
}
|
||||
|
||||
async waitForDialogToClose(): Promise<void> {
|
||||
await BrowserVisibility.waitUntilElementIsNotPresent(this.libraryDialog, 60000);
|
||||
}
|
||||
|
||||
async isDialogOpen(): Promise<any> {
|
||||
return BrowserVisibility.waitUntilElementIsVisible(this.libraryDialog);
|
||||
}
|
||||
|
||||
async getTitle(): Promise<string> {
|
||||
return BrowserActions.getText(this.libraryTitle);
|
||||
}
|
||||
|
||||
async waitUntilLibraryIdTextHasValue(value: string): Promise<void> {
|
||||
await BrowserVisibility.waitUntilElementHasValue(this.libraryIdField, value);
|
||||
}
|
||||
|
||||
async waitErrorMessageIsDisplayed(): Promise<void> {
|
||||
await BrowserVisibility.waitUntilElementIsVisible(this.errorMessage, 60000);
|
||||
}
|
||||
|
||||
async getErrorMessage(): Promise<string> {
|
||||
return BrowserActions.getText(this.errorMessage);
|
||||
}
|
||||
|
||||
async getErrorMessages(position: number): Promise<string> {
|
||||
return BrowserActions.getText(this.errorMessages.get(position));
|
||||
}
|
||||
|
||||
async waitForLibraryNameHint(): Promise<void> {
|
||||
await BrowserVisibility.waitUntilElementIsVisible(this.libraryNameHint);
|
||||
}
|
||||
|
||||
async getLibraryNameHint(): Promise<string> {
|
||||
return BrowserActions.getText(this.libraryNameHint);
|
||||
}
|
||||
|
||||
async isNameDisplayed(): Promise<boolean> {
|
||||
return this.libraryNameField.isDisplayed();
|
||||
}
|
||||
|
||||
async isLibraryIdDisplayed(): Promise<boolean> {
|
||||
return this.libraryIdField.isDisplayed();
|
||||
}
|
||||
|
||||
async isDescriptionDisplayed(): Promise<boolean> {
|
||||
return this.libraryDescriptionField.isDisplayed();
|
||||
}
|
||||
|
||||
async isPublicDisplayed(): Promise<boolean> {
|
||||
return this.publicRadioButton.isDisplayed();
|
||||
}
|
||||
|
||||
async isModeratedDisplayed(): Promise<boolean> {
|
||||
return this.moderatedRadioButton.isDisplayed();
|
||||
}
|
||||
|
||||
async isPrivateDisplayed(): Promise<boolean> {
|
||||
return this.privateRadioButton.isDisplayed();
|
||||
}
|
||||
|
||||
async isCreateEnabled(): Promise<boolean> {
|
||||
return this.createButton.isEnabled();
|
||||
}
|
||||
|
||||
async isCancelEnabled(): Promise<boolean> {
|
||||
return this.cancelButton.isEnabled();
|
||||
}
|
||||
|
||||
async clickCreate(): Promise<void> {
|
||||
await BrowserActions.click(this.createButton);
|
||||
}
|
||||
|
||||
async clickCancel(): Promise<void> {
|
||||
await BrowserActions.click(this.cancelButton);
|
||||
}
|
||||
|
||||
async typeLibraryName(libraryName: string): Promise<void> {
|
||||
await BrowserActions.clearSendKeys(this.libraryNameField, libraryName);
|
||||
}
|
||||
|
||||
async typeLibraryId(libraryId: string): Promise<void> {
|
||||
await BrowserActions.clearSendKeys(this.libraryIdField, libraryId);
|
||||
}
|
||||
|
||||
async typeLibraryDescription(libraryDescription: string): Promise<void> {
|
||||
await BrowserActions.clearSendKeys(this.libraryDescriptionField, libraryDescription);
|
||||
}
|
||||
|
||||
async clearLibraryName(): Promise<void> {
|
||||
await this.libraryNameField.clear();
|
||||
await this.libraryNameField.sendKeys(' ', protractor.Key.CONTROL, 'a', protractor.Key.NULL, protractor.Key.BACK_SPACE);
|
||||
}
|
||||
|
||||
async clearLibraryId(): Promise<void> {
|
||||
await this.libraryIdField.clear();
|
||||
await this.libraryIdField.sendKeys(' ', protractor.Key.CONTROL, 'a', protractor.Key.NULL, protractor.Key.BACK_SPACE);
|
||||
}
|
||||
|
||||
async selectPublic(): Promise<void> {
|
||||
await BrowserActions.click(this.publicRadioButton);
|
||||
}
|
||||
|
||||
async selectPrivate(): Promise<void> {
|
||||
await BrowserActions.click(this.privateRadioButton);
|
||||
}
|
||||
|
||||
async selectModerated(): Promise<void> {
|
||||
await BrowserActions.click(this.moderatedRadioButton);
|
||||
}
|
||||
}
|
||||
|
@@ -16,76 +16,53 @@
|
||||
*/
|
||||
|
||||
import * as path from 'path';
|
||||
import { BrowserActions, BrowserVisibility, TogglePage } from '@alfresco/adf-testing';
|
||||
import { browser, by, element, ElementFinder } from 'protractor';
|
||||
import { BrowserActions, TestElement, TogglePage } from '@alfresco/adf-testing';
|
||||
import { browser, by, element } from 'protractor';
|
||||
|
||||
export class VersionManagePage {
|
||||
|
||||
togglePage = new TogglePage();
|
||||
|
||||
showNewVersionButton = element(by.id('adf-show-version-upload-button'));
|
||||
uploadNewVersionInput = element(by.css('adf-upload-version-button input[data-automation-id="upload-single-file"]'));
|
||||
uploadNewVersionButton = element(by.css('adf-upload-version-button'));
|
||||
uploadNewVersionContainer = element(by.id('adf-new-version-uploader-container'));
|
||||
cancelButton = element(by.id('adf-new-version-cancel'));
|
||||
majorRadio = element(by.id('adf-new-version-major'));
|
||||
minorRadio = element(by.id('adf-new-version-minor'));
|
||||
commentText = element(by.id('adf-new-version-text-area'));
|
||||
showNewVersionButton = TestElement.byId('adf-show-version-upload-button');
|
||||
uploadNewVersionInput = TestElement.byCss('.adf-upload-version-button input[data-automation-id="upload-single-file"]');
|
||||
uploadNewVersionButton = TestElement.byCss('.adf-upload-version-button');
|
||||
uploadNewVersionContainer = TestElement.byId('adf-new-version-uploader-container');
|
||||
cancelButton = TestElement.byId('adf-new-version-cancel');
|
||||
majorRadio = TestElement.byId('adf-new-version-major');
|
||||
minorRadio = TestElement.byId('adf-new-version-minor');
|
||||
commentText = TestElement.byId('adf-new-version-text-area');
|
||||
readOnlySwitch = element(by.id('adf-version-manager-switch-readonly'));
|
||||
downloadSwitch = element(by.id('adf-version-manager-switch-download'));
|
||||
commentsSwitch = element(by.id('adf-version-manager-switch-comments'));
|
||||
|
||||
async checkUploadNewVersionsButtonIsDisplayed(): Promise<void> {
|
||||
await BrowserVisibility.waitUntilElementIsVisible(this.showNewVersionButton);
|
||||
}
|
||||
|
||||
async checkCancelButtonIsDisplayed(): Promise<void> {
|
||||
await BrowserVisibility.waitUntilElementIsVisible(this.cancelButton);
|
||||
}
|
||||
confirmAccept = TestElement.byId('adf-confirm-accept');
|
||||
confirmCancel = TestElement.byId('adf-confirm-cancel');
|
||||
|
||||
async uploadNewVersionFile(fileLocation: string): Promise<void> {
|
||||
await BrowserVisibility.waitUntilElementIsPresent(this.uploadNewVersionInput);
|
||||
await this.uploadNewVersionInput.sendKeys(path.resolve(path.join(browser.params.testConfig.main.rootPath, fileLocation)));
|
||||
await BrowserVisibility.waitUntilElementIsVisible(this.showNewVersionButton);
|
||||
const filePath = path.resolve(path.join(browser.params.testConfig.main.rootPath, fileLocation));
|
||||
|
||||
await this.uploadNewVersionInput.waitPresent();
|
||||
await this.uploadNewVersionInput.elementFinder.sendKeys(filePath);
|
||||
await this.showNewVersionButton.waitVisible();
|
||||
}
|
||||
|
||||
async getFileVersionName(version: string): Promise<string> {
|
||||
const fileElement = element(by.css(`[id="adf-version-list-item-name-${version}"]`));
|
||||
return BrowserActions.getText(fileElement);
|
||||
getFileVersionName(version: string): Promise<string> {
|
||||
return TestElement.byCss(`[id="adf-version-list-item-name-${version}"]`).getText();
|
||||
}
|
||||
|
||||
async checkFileVersionExist(version: string): Promise<void> {
|
||||
const fileVersion = element(by.id(`adf-version-list-item-version-${version}`));
|
||||
await BrowserVisibility.waitUntilElementIsVisible(fileVersion);
|
||||
checkFileVersionExist(version: string): Promise<void> {
|
||||
return TestElement.byId(`adf-version-list-item-version-${version}`).waitVisible();
|
||||
}
|
||||
|
||||
async checkFileVersionNotExist(version: string): Promise<void> {
|
||||
const fileVersion = element(by.id(`adf-version-list-item-version-${version}`));
|
||||
await BrowserVisibility.waitUntilElementIsNotVisible(fileVersion);
|
||||
checkFileVersionNotExist(version: string): Promise<void> {
|
||||
return TestElement.byId(`adf-version-list-item-version-${version}`).waitNotVisible();
|
||||
}
|
||||
|
||||
async getFileVersionComment(version: string): Promise<string> {
|
||||
const fileComment = element(by.id(`adf-version-list-item-comment-${version}`));
|
||||
return BrowserActions.getText(fileComment);
|
||||
getFileVersionComment(version: string): Promise<string> {
|
||||
return TestElement.byId(`adf-version-list-item-comment-${version}`).getText();
|
||||
}
|
||||
|
||||
async getFileVersionDate(version: string): Promise<string> {
|
||||
const fileDate = element(by.id(`adf-version-list-item-date-${version}`));
|
||||
return BrowserActions.getText(fileDate);
|
||||
}
|
||||
|
||||
async enterCommentText(text: string): Promise<void> {
|
||||
await BrowserActions.clearSendKeys(this.commentText, text);
|
||||
}
|
||||
|
||||
async clickMajorChange(): Promise<void> {
|
||||
const radioMajor = element(by.id(`adf-new-version-major`));
|
||||
await BrowserActions.click(radioMajor);
|
||||
}
|
||||
|
||||
async clickMinorChange(): Promise<void> {
|
||||
const radioMinor = element(by.id(`adf-new-version-minor`));
|
||||
await BrowserActions.click(radioMinor);
|
||||
getFileVersionDate(version: string): Promise<string> {
|
||||
return TestElement.byId(`adf-version-list-item-date-${version}`).getText();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,16 +109,8 @@ export class VersionManagePage {
|
||||
}
|
||||
|
||||
async clickActionButton(version: string): Promise<void> {
|
||||
await BrowserActions.click(element(by.id(`adf-version-list-action-menu-button-${version}`)));
|
||||
await BrowserVisibility.waitUntilElementIsVisible(element(by.css('.cdk-overlay-container .mat-menu-content')));
|
||||
}
|
||||
|
||||
async clickAcceptConfirm(): Promise<void> {
|
||||
await BrowserActions.click(element(by.id(`adf-confirm-accept`)));
|
||||
}
|
||||
|
||||
async clickCancelConfirm(): Promise<void> {
|
||||
await BrowserActions.click(element(by.id(`adf-confirm-cancel`)));
|
||||
await TestElement.byId(`adf-version-list-action-menu-button-${version}`).click();
|
||||
await TestElement.byCss('.cdk-overlay-container .mat-menu-content').waitVisible();
|
||||
}
|
||||
|
||||
async closeActionsMenu(): Promise<void> {
|
||||
@@ -149,44 +118,48 @@ export class VersionManagePage {
|
||||
}
|
||||
|
||||
async closeDisabledActionsMenu(): Promise<void> {
|
||||
const container = element(by.css('div.cdk-overlay-backdrop.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing'));
|
||||
const container = TestElement.byCss('div.cdk-overlay-backdrop.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing');
|
||||
await BrowserActions.closeDisabledMenu();
|
||||
await BrowserVisibility.waitUntilElementIsNotVisible(container);
|
||||
await container.waitNotVisible();
|
||||
}
|
||||
|
||||
async downloadFileVersion(version: string): Promise<void> {
|
||||
await this.clickActionButton(version);
|
||||
const downloadButton = element(by.id(`adf-version-list-action-download-${version}`));
|
||||
await BrowserActions.click(downloadButton);
|
||||
await BrowserVisibility.waitUntilElementIsNotVisible(downloadButton);
|
||||
|
||||
const downloadButton = TestElement.byId(`adf-version-list-action-download-${version}`);
|
||||
await downloadButton.click();
|
||||
await downloadButton.waitNotVisible();
|
||||
}
|
||||
|
||||
async deleteFileVersion(version: string): Promise<void> {
|
||||
await this.clickActionButton(version);
|
||||
const deleteButton = element(by.id(`adf-version-list-action-delete-${version}`));
|
||||
await BrowserActions.click(deleteButton);
|
||||
|
||||
const deleteButton = TestElement.byId(`adf-version-list-action-delete-${version}`);
|
||||
await deleteButton.click();
|
||||
}
|
||||
|
||||
async restoreFileVersion(version: string): Promise<void> {
|
||||
await this.clickActionButton(version);
|
||||
const restoreButton = element(by.id(`adf-version-list-action-restore-${version}`));
|
||||
await BrowserActions.click(restoreButton);
|
||||
|
||||
const restoreButton = TestElement.byId(`adf-version-list-action-restore-${version}`);
|
||||
await restoreButton.click();
|
||||
}
|
||||
|
||||
async viewFileVersion(version): Promise<void> {
|
||||
await this.clickActionButton(version);
|
||||
const viewButton: ElementFinder = element(by.id(`adf-version-list-action-view-${version}`));
|
||||
await BrowserActions.click(viewButton);
|
||||
|
||||
const viewButton = TestElement.byId(`adf-version-list-action-view-${version}`);
|
||||
await viewButton.click();
|
||||
}
|
||||
|
||||
async checkActionsArePresent(version: string): Promise<void> {
|
||||
await BrowserVisibility.waitUntilElementIsVisible(element(by.id(`adf-version-list-action-download-${version}`)));
|
||||
await BrowserVisibility.waitUntilElementIsVisible(element(by.id(`adf-version-list-action-delete-${version}`)));
|
||||
await BrowserVisibility.waitUntilElementIsVisible(element(by.id(`adf-version-list-action-restore-${version}`)));
|
||||
await TestElement.byId(`adf-version-list-action-download-${version}`).waitVisible();
|
||||
await TestElement.byId(`adf-version-list-action-delete-${version}`).waitVisible();
|
||||
await TestElement.byId(`adf-version-list-action-restore-${version}`).waitVisible();
|
||||
}
|
||||
|
||||
async closeVersionDialog(): Promise<void> {
|
||||
await BrowserActions.closeMenuAndDialogs();
|
||||
await BrowserVisibility.waitUntilElementIsNotVisible(this.uploadNewVersionContainer);
|
||||
await this.uploadNewVersionContainer.waitNotVisible();
|
||||
}
|
||||
}
|
||||
|
@@ -442,8 +442,7 @@ describe('Content Services Viewer', () => {
|
||||
await viewerPage.viewFile(originalFileName);
|
||||
await viewerPage.clickCloseButton();
|
||||
await contentServicesPage.versionManagerContent(originalFileName);
|
||||
await versionManagePage.checkUploadNewVersionsButtonIsDisplayed();
|
||||
await BrowserActions.click(versionManagePage.showNewVersionButton);
|
||||
await versionManagePage.showNewVersionButton.click();
|
||||
await versionManagePage.uploadNewVersionFile(newVersionLocation);
|
||||
await versionManagePage.closeActionsMenu();
|
||||
await versionManagePage.closeVersionDialog();
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { browser } from 'protractor';
|
||||
import { ApiService, BrowserActions, FileBrowserUtil, LoginPage, UploadActions, UserModel, UsersActions, ViewerPage } from '@alfresco/adf-testing';
|
||||
import { ApiService, FileBrowserUtil, LoginPage, UploadActions, UserModel, UsersActions, ViewerPage } from '@alfresco/adf-testing';
|
||||
import { ContentServicesPage } from '../../core/pages/content-services.page';
|
||||
import { FileModel } from '../../models/ACS/file.model';
|
||||
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
|
||||
@@ -94,7 +94,7 @@ describe('Viewer', () => {
|
||||
|
||||
it('[C362242] Should the Viewer be able to view a previous version of a file', async () => {
|
||||
await contentServicesPage.versionManagerContent(txtFileInfo.name);
|
||||
await BrowserActions.click(versionManagePage.showNewVersionButton);
|
||||
await versionManagePage.showNewVersionButton.click();
|
||||
await versionManagePage.uploadNewVersionFile(fileModelVersionTwo.location);
|
||||
await versionManagePage.closeVersionDialog();
|
||||
await contentServicesPage.doubleClickRow(txtFileUploaded.entry.name);
|
||||
|
Reference in New Issue
Block a user