e2e refactorings (#1346)

* - create a generic-dialog class to remove some duplicated code
- add return types

* - share dialog needs custom methods
- also, fix copy/paste mistake :D
This commit is contained in:
Adina Parpalita
2020-02-25 12:28:59 +02:00
committed by GitHub
parent 59b529160d
commit a825c37da4
14 changed files with 376 additions and 517 deletions

View File

@@ -44,43 +44,32 @@ export class Breadcrumb extends Component {
return this.items.get(nth - 1);
}
async getNthItemName(nth: number) {
return this.getNthItem(nth).getText();
}
async getItemsCount() {
async getItemsCount(): Promise<number> {
return this.items.count();
}
async getAllItems() {
return this.items.map(async elem => {
async getAllItems(): Promise<string[]> {
const items: string[] = await this.items.map(async elem => {
const str = await elem.getText();
return str.split('\nchevron_right')[0];
});
return items;
}
async getFirstItemName() {
return this.items.get(0).getText();
}
getCurrentItem() {
getCurrentItem(): ElementFinder {
return this.currentItem;
}
async getCurrentItemName() {
async getCurrentItemName(): Promise<string> {
return this.currentItem.getText();
}
async clickItem(name: string) {
async clickItem(name: string): Promise<void> {
const elem = this.component.element(by.css(`${Breadcrumb.selectors.item}[title=${name}]`));
await elem.click();
}
async clickNthItem(nth: number) {
await this.getNthItem(nth).click();
}
async getNthItemTooltip(nth: number) {
async getNthItemTooltip(nth: number): Promise<string> {
return this.getNthItem(nth).getAttribute('title');
}
}

View File

@@ -48,31 +48,33 @@ export class DateTimePicker extends Component {
headerYear: ElementFinder = this.component.element(by.css(DateTimePicker.selectors.year));
dayPicker: ElementFinder = this.component.element(by.css(DateTimePicker.selectors.dayPicker));
rootElemLocator = by.css(DateTimePicker.selectors.root);
constructor(ancestor?: string) {
super(DateTimePicker.selectors.root, ancestor);
}
async waitForDateTimePickerToOpen() {
async waitForDateTimePickerToOpen(): Promise<void> {
await browser.wait(EC.presenceOf(this.calendar), BROWSER_WAIT_TIMEOUT);
}
async waitForDateTimePickerToClose() {
async waitForDateTimePickerToClose(): Promise<void> {
await browser.wait(EC.stalenessOf(this.calendar), BROWSER_WAIT_TIMEOUT);
}
async isCalendarOpen() {
return browser.isElementPresent(by.css(DateTimePicker.selectors.root));
async isCalendarOpen(): Promise<boolean> {
return (await browser.element(this.rootElemLocator).isPresent()) && (await browser.element(this.rootElemLocator).isDisplayed());
}
async getDate() {
async getDate(): Promise<string> {
return this.headerDate.getText();
}
async getYear() {
async getYear(): Promise<string> {
return this.headerYear.getText();
}
async setDefaultDay() {
async setDefaultDay(): Promise<string> {
const today = moment();
const tomorrow = today.add(1, 'day');
const dayOfTomorrow = tomorrow.date();

View File

@@ -23,105 +23,66 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser, ExpectedConditions as EC } from 'protractor';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { Component } from '../component';
import { by } from 'protractor';
import { GenericDialog } from '../dialog/generic-dialog';
export class ConfirmDialog extends Component {
export class ConfirmDialog extends GenericDialog {
private static selectors = {
root: 'adf-confirm-dialog',
title: '.mat-dialog-title',
content: '.mat-dialog-content',
accept: 'adf-confirm-accept',
cancel: 'adf-confirm-cancel',
actionButton: 'adf-confirm'
};
title: ElementFinder = this.component.element(by.css(ConfirmDialog.selectors.title));
content: ElementFinder = this.component.element(by.css(ConfirmDialog.selectors.content));
acceptButton: ElementFinder = this.component.element(by.id(ConfirmDialog.selectors.accept));
cancelButton: ElementFinder = this.component.element(by.id(ConfirmDialog.selectors.cancel));
actionButton: ElementFinder = this.component.element(by.id(ConfirmDialog.selectors.actionButton));
constructor(ancestor?: string) {
super(ConfirmDialog.selectors.root, ancestor);
okButton: by.buttonText('OK'),
cancelButton: by.buttonText('Cancel'),
keepButton: by.buttonText('Keep'),
deleteButton: by.buttonText('Delete'),
removeButton: by.buttonText('Remove')
}
async waitForDialogToClose() {
await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT);
constructor() {
super(ConfirmDialog.selectors.root);
}
async waitForDialogToOpen() {
await browser.wait(EC.presenceOf(this.title), BROWSER_WAIT_TIMEOUT);
}
async isDialogOpen() {
return browser.isElementPresent(by.css(ConfirmDialog.selectors.root));
}
async getTitle() {
return this.title.getText();
}
async getText() {
async getText(): Promise<string> {
return this.content.getText();
}
getButtonByName(name: string) {
return this.component.element(by.buttonText(name));
async isOkEnabled(): Promise<boolean> {
return this.isButtonEnabled(ConfirmDialog.selectors.okButton);
}
async clickButton(name: string) {
const button = this.getButtonByName(name);
await button.click();
async isCancelEnabled(): Promise<boolean> {
return this.isButtonEnabled(ConfirmDialog.selectors.cancelButton);
}
async isButtonEnabled(name: string) {
const button = this.getButtonByName(name);
return button.isEnabled();
async isKeepEnabled(): Promise<boolean> {
return this.isButtonEnabled(ConfirmDialog.selectors.keepButton);
}
async isOkEnabled() {
return this.isButtonEnabled('OK');
async isDeleteEnabled(): Promise<boolean> {
return this.isButtonEnabled(ConfirmDialog.selectors.deleteButton);
}
async isCancelEnabled() {
return this.isButtonEnabled('Cancel');
async isRemoveEnabled(): Promise<boolean> {
return this.isButtonEnabled(ConfirmDialog.selectors.removeButton);
}
async isKeepEnabled() {
return this.isButtonEnabled('Keep');
async clickOk(): Promise<void> {
await this.clickButton(ConfirmDialog.selectors.okButton);
}
async isDeleteEnabled() {
return this.isButtonEnabled('Delete');
async clickCancel(): Promise<void> {
await this.clickButton(ConfirmDialog.selectors.cancelButton);
}
async isRemoveEnabled() {
return this.isButtonEnabled('Remove');
async clickKeep(): Promise<void> {
await this.clickButton(ConfirmDialog.selectors.keepButton);
}
async clickOk() {
await this.clickButton('OK');
async clickDelete(): Promise<void> {
await this.clickButton(ConfirmDialog.selectors.deleteButton);
}
async clickCancel() {
await this.cancelButton.click();
}
async clickKeep() {
await this.clickButton('Keep');
}
async clickDelete() {
await this.clickButton('Delete');
}
async clickRemove() {
await this.clickButton('Remove');
async clickRemove(): Promise<void> {
await this.clickButton(ConfirmDialog.selectors.removeButton);
}
}

View File

@@ -25,55 +25,41 @@
import { ElementFinder, by, browser, ExpectedConditions as EC, protractor } from 'protractor';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { Component } from '../component';
import { GenericDialog } from '../dialog/generic-dialog';
import { Utils } from '../../utilities/utils';
import { DropDownBreadcrumb } from '../breadcrumb/dropdown-breadcrumb';
import { DataTable } from '../data-table/data-table';
export class ContentNodeSelectorDialog extends Component {
export class ContentNodeSelectorDialog extends GenericDialog {
private static selectors = {
root: '.adf-content-node-selector-dialog',
title: '.mat-dialog-title',
locationDropDown: 'site-dropdown-container',
locationOption: '.mat-option .mat-option-text',
dataTable: '.adf-datatable-body',
selectedRow: '.adf-is-selected',
button: '.mat-dialog-actions button',
chooseAction: '.adf-choose-action',
searchInput: '#searchInput',
toolbarTitle: '.adf-toolbar-title'
toolbarTitle: '.adf-toolbar-title',
cancelButton: by.css('[data-automation-id="content-node-selector-actions-cancel"]'),
copyButton: by.cssContainingText('[data-automation-id="content-node-selector-actions-choose"]', 'Copy'),
moveButton: by.cssContainingText('[data-automation-id="content-node-selector-actions-choose"]', 'Move')
};
title: ElementFinder = this.component.element(by.css(ContentNodeSelectorDialog.selectors.title));
locationDropDown: ElementFinder = this.component.element(by.id(ContentNodeSelectorDialog.selectors.locationDropDown));
locationDropDown: ElementFinder = this.rootElem.element(by.id(ContentNodeSelectorDialog.selectors.locationDropDown));
locationPersonalFiles: ElementFinder = browser.element(by.cssContainingText(ContentNodeSelectorDialog.selectors.locationOption, 'Personal Files'));
locationFileLibraries: ElementFinder = browser.element(by.cssContainingText(ContentNodeSelectorDialog.selectors.locationOption, 'File Libraries'));
cancelButton: ElementFinder = this.component.element(by.cssContainingText(ContentNodeSelectorDialog.selectors.button, 'Cancel'));
copyButton: ElementFinder = this.component.element(by.css(ContentNodeSelectorDialog.selectors.chooseAction));
moveButton: ElementFinder = this.component.element(by.cssContainingText(ContentNodeSelectorDialog.selectors.button, 'Move'));
searchInput: ElementFinder = this.component.element(by.css(ContentNodeSelectorDialog.selectors.searchInput));
toolbarTitle: ElementFinder = this.component.element(by.css(ContentNodeSelectorDialog.selectors.toolbarTitle));
searchInput: ElementFinder = this.rootElem.element(by.css(ContentNodeSelectorDialog.selectors.searchInput));
toolbarTitle: ElementFinder = this.rootElem.element(by.css(ContentNodeSelectorDialog.selectors.toolbarTitle));
breadcrumb: DropDownBreadcrumb = new DropDownBreadcrumb();
dataTable: DataTable = new DataTable(ContentNodeSelectorDialog.selectors.root);
constructor(ancestor?: string) {
super(ContentNodeSelectorDialog.selectors.root, ancestor);
}
async waitForDialogToOpen(): Promise<void> {
await browser.wait(EC.presenceOf(this.title), BROWSER_WAIT_TIMEOUT, 'timeout waiting for dialog title');
await browser.wait(EC.presenceOf(browser.element(by.css('.cdk-overlay-backdrop'))), BROWSER_WAIT_TIMEOUT, 'timeout waiting for overlay backdrop');
}
async waitForDialogToClose(): Promise<void> {
await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT);
constructor() {
super(ContentNodeSelectorDialog.selectors.root);
}
async waitForDropDownToOpen(): Promise<void> {
@@ -85,28 +71,20 @@ export class ContentNodeSelectorDialog extends Component {
}
async waitForRowToBeSelected(): Promise<void> {
await browser.wait(EC.presenceOf(this.component.element(by.css(ContentNodeSelectorDialog.selectors.selectedRow))), BROWSER_WAIT_TIMEOUT);
}
async isDialogOpen(): Promise<boolean> {
return browser.$(ContentNodeSelectorDialog.selectors.root).isDisplayed();
}
async getTitle(): Promise<string> {
return this.title.getText();
await browser.wait(EC.presenceOf(browser.element(by.css(ContentNodeSelectorDialog.selectors.selectedRow))), BROWSER_WAIT_TIMEOUT);
}
async clickCancel(): Promise<void> {
await this.cancelButton.click();
await this.clickButton(ContentNodeSelectorDialog.selectors.cancelButton);
await this.waitForDialogToClose();
}
async clickCopy(): Promise<void> {
await this.copyButton.click();
await this.clickButton(ContentNodeSelectorDialog.selectors.copyButton);
}
async clickMove(): Promise<void> {
await this.moveButton.click();
await this.clickButton(ContentNodeSelectorDialog.selectors.moveButton);
}
async selectLocation(location: 'Personal Files' | 'File Libraries'): Promise<void> {
@@ -138,11 +116,11 @@ export class ContentNodeSelectorDialog extends Component {
}
async isCopyButtonEnabled(): Promise<boolean> {
return (await this.copyButton.isPresent()) && (await this.copyButton.isEnabled());
return this.isButtonEnabled(ContentNodeSelectorDialog.selectors.copyButton);
}
async isCancelButtonEnabled(): Promise<boolean> {
return (await this.cancelButton.isPresent()) && (await this.cancelButton.isEnabled());
return this.isButtonEnabled(ContentNodeSelectorDialog.selectors.cancelButton);
}
async searchFor(text: string): Promise<void> {

View File

@@ -23,72 +23,58 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser, protractor, ExpectedConditions as EC } from 'protractor';
import { ElementFinder, by, protractor, browser, ExpectedConditions as EC } from 'protractor';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { Component } from '../component';
import { Utils } from '../../utilities/utils';
import { GenericDialog } from '../dialog/generic-dialog';
export class CreateOrEditFolderDialog extends Component {
export class CreateOrEditFolderDialog extends GenericDialog {
private static selectors = {
root: 'adf-folder-dialog',
title: '.mat-dialog-title',
nameInput: 'input[placeholder="Name" i]',
descriptionTextArea: 'textarea[placeholder="Description" i]',
button: '.mat-dialog-actions button',
validationMessage: '.mat-hint span'
validationMessage: '.mat-hint span',
createButton: by.cssContainingText('.mat-dialog-actions button', 'Create'),
cancelButton: by.id('adf-folder-cancel-button'),
updateButton: by.cssContainingText('.mat-dialog-actions button', 'Update')
};
title: ElementFinder = this.component.element(by.css(CreateOrEditFolderDialog.selectors.title));
nameInput: ElementFinder = this.component.element(by.css(CreateOrEditFolderDialog.selectors.nameInput));
descriptionTextArea: ElementFinder = this.component.element(by.css(CreateOrEditFolderDialog.selectors.descriptionTextArea));
createButton: ElementFinder = this.component.element(by.cssContainingText(CreateOrEditFolderDialog.selectors.button, 'Create'));
cancelButton: ElementFinder = this.component.element(by.cssContainingText(CreateOrEditFolderDialog.selectors.button, 'Cancel'));
updateButton: ElementFinder = this.component.element(by.cssContainingText(CreateOrEditFolderDialog.selectors.button, 'Update'));
validationMessage: ElementFinder = this.component.element(by.css(CreateOrEditFolderDialog.selectors.validationMessage));
nameInput: ElementFinder = this.rootElem.element(by.css(CreateOrEditFolderDialog.selectors.nameInput));
descriptionTextArea: ElementFinder = this.rootElem.element(by.css(CreateOrEditFolderDialog.selectors.descriptionTextArea));
validationMessage: ElementFinder = this.rootElem.element(by.css(CreateOrEditFolderDialog.selectors.validationMessage));
constructor(ancestor?: string) {
super(CreateOrEditFolderDialog.selectors.root, ancestor);
constructor() {
super(CreateOrEditFolderDialog.selectors.root);
}
async waitForDialogToOpen() {
await browser.wait(EC.presenceOf(this.title), BROWSER_WAIT_TIMEOUT);
await browser.wait(EC.presenceOf(browser.element(by.css('.cdk-overlay-backdrop'))), BROWSER_WAIT_TIMEOUT);
}
async waitForDialogToClose() {
await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT, '---- timeout waiting for dialog to close ----');
}
async isDialogOpen() {
return browser.isElementPresent(by.css(CreateOrEditFolderDialog.selectors.root));
}
async getTitle() {
return this.title.getText();
await super.waitForDialogToOpen();
await browser.wait(EC.elementToBeClickable(this.nameInput), BROWSER_WAIT_TIMEOUT, '--- timeout waiting for input to be clickable ---');
}
async isValidationMessageDisplayed(): Promise<boolean> {
return (await this.validationMessage.isPresent()) && (await this.validationMessage.isDisplayed());
}
async isUpdateButtonEnabled() {
return this.updateButton.isEnabled();
async isUpdateButtonEnabled(): Promise<boolean> {
return this.isButtonEnabled(CreateOrEditFolderDialog.selectors.updateButton);
}
async isCreateButtonEnabled() {
return this.createButton.isEnabled();
async isCreateButtonEnabled(): Promise<boolean> {
return this.isButtonEnabled(CreateOrEditFolderDialog.selectors.createButton);
}
async isCancelButtonEnabled() {
return this.cancelButton.isEnabled();
async isCancelButtonEnabled(): Promise<boolean> {
return this.isButtonEnabled(CreateOrEditFolderDialog.selectors.cancelButton);
}
async isNameDisplayed() {
async isNameDisplayed(): Promise<boolean> {
return this.nameInput.isDisplayed();
}
async isDescriptionDisplayed() {
async isDescriptionDisplayed(): Promise<boolean> {
return this.descriptionTextArea.isDisplayed();
}
@@ -100,40 +86,40 @@ export class CreateOrEditFolderDialog extends Component {
}
}
async getName() {
async getName(): Promise<string> {
return this.nameInput.getAttribute('value');
}
async getDescription() {
async getDescription(): Promise<string> {
return this.descriptionTextArea.getAttribute('value');
}
async enterName(name: string) {
async enterName(name: string): Promise<void> {
await this.nameInput.clear();
await Utils.typeInField(this.nameInput, name);
await this.nameInput.sendKeys(name);
}
async enterDescription(description: string) {
async enterDescription(description: string): Promise<void> {
await this.descriptionTextArea.clear();
await Utils.typeInField(this.descriptionTextArea, description);
await this.descriptionTextArea.sendKeys(description);
}
async deleteNameWithBackspace() {
async deleteNameWithBackspace(): Promise<void> {
await this.nameInput.clear();
await this.nameInput.sendKeys(' ', protractor.Key.CONTROL, 'a', protractor.Key.NULL, protractor.Key.BACK_SPACE);
}
async clickCreate() {
await this.createButton.click();
async clickCreate(): Promise<void> {
await this.clickButton(CreateOrEditFolderDialog.selectors.createButton);
}
async clickCancel() {
await this.cancelButton.click();
async clickCancel(): Promise<void> {
await this.clickButton(CreateOrEditFolderDialog.selectors.cancelButton);
await this.waitForDialogToClose();
}
async clickUpdate() {
await this.updateButton.click();
async clickUpdate(): Promise<void> {
await this.clickButton(CreateOrEditFolderDialog.selectors.updateButton);
}
}

View File

@@ -23,49 +23,29 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser, protractor, ExpectedConditions as EC } from 'protractor';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { Component } from '../component';
import { ElementFinder, by, protractor } from 'protractor';
import { GenericDialog } from '../dialog/generic-dialog';
export class CreateFromTemplateDialog extends Component {
export class CreateFromTemplateDialog extends GenericDialog {
private static selectors = {
root: '.aca-create-from-template-dialog',
title: '.mat-dialog-title',
nameInput: 'input[placeholder="Name" i]',
titleInput: 'input[placeholder="Title" i]',
descriptionTextArea: 'textarea[placeholder="Description" i]',
button: '.mat-dialog-actions button',
validationMessage: '.mat-error'
validationMessage: '.mat-error',
createButton: by.cssContainingText('.mat-dialog-actions button', 'Create'),
cancelButton: by.cssContainingText('.mat-dialog-actions button', 'CANCEL')
};
title: ElementFinder = this.component.element(by.css(CreateFromTemplateDialog.selectors.title));
nameInput: ElementFinder = this.component.element(by.css(CreateFromTemplateDialog.selectors.nameInput));
titleInput: ElementFinder = this.component.element(by.css(CreateFromTemplateDialog.selectors.titleInput));
descriptionTextArea: ElementFinder = this.component.element(by.css(CreateFromTemplateDialog.selectors.descriptionTextArea));
createButton: ElementFinder = this.component.element(by.cssContainingText(CreateFromTemplateDialog.selectors.button, 'Create'));
cancelButton: ElementFinder = this.component.element(by.cssContainingText(CreateFromTemplateDialog.selectors.button, 'CANCEL'));
validationMessage: ElementFinder = this.component.element(by.css(CreateFromTemplateDialog.selectors.validationMessage));
nameInput: ElementFinder = this.rootElem.element(by.css(CreateFromTemplateDialog.selectors.nameInput));
titleInput: ElementFinder = this.rootElem.element(by.css(CreateFromTemplateDialog.selectors.titleInput));
descriptionTextArea: ElementFinder = this.rootElem.element(by.css(CreateFromTemplateDialog.selectors.descriptionTextArea));
validationMessage: ElementFinder = this.rootElem.element(by.css(CreateFromTemplateDialog.selectors.validationMessage));
constructor(ancestor?: string) {
super(CreateFromTemplateDialog.selectors.root, ancestor);
}
async waitForDialogToOpen(): Promise<void> {
await browser.wait(EC.presenceOf(this.title), BROWSER_WAIT_TIMEOUT, 'timeout waiting for dialog title');
await browser.wait(EC.presenceOf(browser.element(by.css('.cdk-overlay-backdrop'))), BROWSER_WAIT_TIMEOUT, 'timeout waiting for overlay backdrop');
}
async waitForDialogToClose(): Promise<void> {
await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT, '---- timeout waiting for dialog to close ----');
}
async isDialogOpen(): Promise<boolean> {
return browser.isElementPresent(by.css(CreateFromTemplateDialog.selectors.root));
}
async getTitle(): Promise<string> {
return this.title.getText();
constructor() {
super(CreateFromTemplateDialog.selectors.root);
}
async isValidationMessageDisplayed(): Promise<boolean> {
@@ -73,11 +53,11 @@ export class CreateFromTemplateDialog extends Component {
}
async isCreateButtonEnabled(): Promise<boolean> {
return this.createButton.isEnabled();
return this.isButtonEnabled(CreateFromTemplateDialog.selectors.createButton);
}
async isCancelButtonEnabled(): Promise<boolean> {
return this.cancelButton.isEnabled();
return this.isButtonEnabled(CreateFromTemplateDialog.selectors.cancelButton);
}
async isNameFieldDisplayed(): Promise<boolean> {
@@ -129,11 +109,11 @@ export class CreateFromTemplateDialog extends Component {
}
async clickCreate(): Promise<void> {
await this.createButton.click();
await this.clickButton(CreateFromTemplateDialog.selectors.createButton);
}
async clickCancel(): Promise<void> {
await this.cancelButton.click();
await this.clickButton(CreateFromTemplateDialog.selectors.cancelButton);
await this.waitForDialogToClose();
}

View File

@@ -23,151 +23,140 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser, protractor, ExpectedConditions as EC } from 'protractor';
import { ElementFinder, by, protractor, browser, ExpectedConditions as EC } from 'protractor';
import { GenericDialog } from '../dialog/generic-dialog';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { Component } from '../component';
import { Utils } from '../../utilities/utils';
export class CreateLibraryDialog extends Component {
export class CreateLibraryDialog extends GenericDialog {
private static selectors = {
root: 'adf-library-dialog',
title: '.mat-dialog-title',
nameInput: 'input[placeholder="Name" i]',
libraryIdInput: 'input[placeholder="Library ID" i]',
descriptionTextArea: 'textarea[placeholder="Description" i]',
button: '.mat-dialog-actions button',
radioButton: '.mat-radio-label',
radioChecked: 'mat-radio-checked',
errorMessage: '.mat-error'
errorMessage: '.mat-error',
createButton: by.cssContainingText('.mat-dialog-actions button', 'Create'),
cancelButton: by.cssContainingText('.mat-dialog-actions button', 'Cancel')
};
title: ElementFinder = this.component.element(by.css(CreateLibraryDialog.selectors.title));
nameInput: ElementFinder = this.component.element(by.css(CreateLibraryDialog.selectors.nameInput));
libraryIdInput: ElementFinder = this.component.element(by.css(CreateLibraryDialog.selectors.libraryIdInput));
descriptionTextArea: ElementFinder = this.component.element(by.css(CreateLibraryDialog.selectors.descriptionTextArea));
visibilityPublic: ElementFinder = this.component.element(by.cssContainingText(CreateLibraryDialog.selectors.radioButton, 'Public'));
visibilityModerated: ElementFinder = this.component.element(by.cssContainingText(CreateLibraryDialog.selectors.radioButton, 'Moderated'));
visibilityPrivate: ElementFinder = this.component.element(by.cssContainingText(CreateLibraryDialog.selectors.radioButton, 'Private'));
createButton: ElementFinder = this.component.element(by.cssContainingText(CreateLibraryDialog.selectors.button, 'Create'));
cancelButton: ElementFinder = this.component.element(by.cssContainingText(CreateLibraryDialog.selectors.button, 'Cancel'));
errorMessage: ElementFinder = this.component.element(by.css(CreateLibraryDialog.selectors.errorMessage));
nameInput: ElementFinder = this.rootElem.element(by.css(CreateLibraryDialog.selectors.nameInput));
libraryIdInput: ElementFinder = this.rootElem.element(by.css(CreateLibraryDialog.selectors.libraryIdInput));
descriptionTextArea: ElementFinder = this.rootElem.element(by.css(CreateLibraryDialog.selectors.descriptionTextArea));
visibilityPublic: ElementFinder = this.rootElem.element(by.cssContainingText(CreateLibraryDialog.selectors.radioButton, 'Public'));
visibilityModerated: ElementFinder = this.rootElem.element(by.cssContainingText(CreateLibraryDialog.selectors.radioButton, 'Moderated'));
visibilityPrivate: ElementFinder = this.rootElem.element(by.cssContainingText(CreateLibraryDialog.selectors.radioButton, 'Private'));
constructor(ancestor?: string) {
super(CreateLibraryDialog.selectors.root, ancestor);
errorMessage: ElementFinder = this.rootElem.element(by.css(CreateLibraryDialog.selectors.errorMessage));
constructor() {
super(CreateLibraryDialog.selectors.root);
}
async waitForDialogToOpen() {
await browser.wait(EC.presenceOf(this.title), BROWSER_WAIT_TIMEOUT);
await browser.wait(EC.presenceOf(browser.element(by.css('.cdk-overlay-backdrop'))), BROWSER_WAIT_TIMEOUT);
async waitForDialogToOpen(): Promise<void> {
await super.waitForDialogToOpen();
await browser.wait(EC.elementToBeClickable(this.nameInput), BROWSER_WAIT_TIMEOUT, '--- timeout waiting for input to be clickable ---');
}
async waitForDialogToClose() {
await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT);
}
async isDialogOpen() {
return browser.isElementPresent(by.css(CreateLibraryDialog.selectors.root));
}
async getTitle() {
return this.title.getText();
}
async isErrorMessageDisplayed() {
async isErrorMessageDisplayed(): Promise<boolean> {
return this.errorMessage.isDisplayed();
}
async getErrorMessage() {
await this.isErrorMessageDisplayed();
return this.errorMessage.getText();
async getErrorMessage(): Promise<string> {
if (await this.isErrorMessageDisplayed()) {
return this.errorMessage.getText();
}
return '';
}
async isNameDisplayed() {
async isNameDisplayed(): Promise<boolean> {
return this.nameInput.isDisplayed();
}
async isLibraryIdDisplayed() {
async isLibraryIdDisplayed(): Promise<boolean> {
return this.libraryIdInput.isDisplayed();
}
async isDescriptionDisplayed() {
async isDescriptionDisplayed(): Promise<boolean> {
return this.descriptionTextArea.isDisplayed();
}
async isPublicDisplayed() {
async isPublicDisplayed(): Promise<boolean> {
return this.visibilityPublic.isDisplayed();
}
async isModeratedDisplayed() {
async isModeratedDisplayed(): Promise<boolean> {
return this.visibilityModerated.isDisplayed();
}
async isPrivateDisplayed() {
async isPrivateDisplayed(): Promise<boolean> {
return this.visibilityPrivate.isDisplayed();
}
async enterName(name: string) {
async enterName(name: string): Promise<void> {
await this.nameInput.clear();
await Utils.typeInField(this.nameInput, name);
await this.nameInput.sendKeys(name);
}
async enterLibraryId(id: string) {
async enterLibraryId(id: string): Promise<void> {
await this.libraryIdInput.clear();
await Utils.typeInField(this.libraryIdInput, id);
await this.libraryIdInput.sendKeys(id);
}
async enterDescription(description: string) {
async enterDescription(description: string): Promise<void> {
await this.descriptionTextArea.clear();
await Utils.typeInField(this.descriptionTextArea, description);
await this.descriptionTextArea.sendKeys(description);
}
async deleteNameWithBackspace() {
async deleteNameWithBackspace(): Promise<void> {
await this.nameInput.clear();
await this.nameInput.sendKeys(' ', protractor.Key.CONTROL, 'a', protractor.Key.NULL, protractor.Key.BACK_SPACE);
}
async isCreateEnabled() {
return this.createButton.isEnabled();
async isCreateEnabled(): Promise<boolean> {
return this.isButtonEnabled(CreateLibraryDialog.selectors.createButton);
}
async isCancelEnabled() {
return this.cancelButton.isEnabled();
async isCancelEnabled(): Promise<boolean> {
return this.isButtonEnabled(CreateLibraryDialog.selectors.cancelButton);
}
async clickCreate() {
await this.createButton.click();
async clickCreate(): Promise<void> {
await this.clickButton(CreateLibraryDialog.selectors.createButton);
}
async clickCancel() {
await this.cancelButton.click();
async clickCancel(): Promise<void> {
await this.clickButton(CreateLibraryDialog.selectors.cancelButton);
await this.waitForDialogToClose();
}
async isPublicChecked() {
async isPublicChecked(): Promise<boolean> {
const elemClass = await this.visibilityPublic.element(by.xpath('..')).getAttribute('class');
return elemClass.includes(CreateLibraryDialog.selectors.radioChecked);
}
async isModeratedChecked() {
async isModeratedChecked(): Promise<boolean> {
const elemClass = await this.visibilityModerated.element(by.xpath('..')).getAttribute('class');
return elemClass.includes(CreateLibraryDialog.selectors.radioChecked);
}
async isPrivateChecked() {
async isPrivateChecked(): Promise<boolean> {
const elemClass = await this.visibilityPrivate.element(by.xpath('..')).getAttribute('class');
return elemClass.includes(CreateLibraryDialog.selectors.radioChecked);
}
async selectPublic() {
async selectPublic(): Promise<void> {
await this.visibilityPublic.click();
}
async selectModerated() {
async selectModerated(): Promise<void> {
await this.visibilityModerated.click();
}
async selectPrivate() {
async selectPrivate(): Promise<void> {
await this.visibilityPrivate.click();
}
}

View File

@@ -0,0 +1,86 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser, ExpectedConditions as EC, Locator } from 'protractor';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
export abstract class GenericDialog {
private static locators = {
title: '.mat-dialog-title',
content: '.mat-dialog-content'
};
private rootCssSelector: string;
constructor(selector?: string) {
this.rootCssSelector = selector;
}
get rootElem(): ElementFinder {
return browser.element(by.css(this.rootCssSelector));
}
get title(): ElementFinder {
return this.rootElem.element(by.css(GenericDialog.locators.title));
}
get content(): ElementFinder {
return this.rootElem.element(by.css(GenericDialog.locators.content));
}
async getText(): Promise<string> {
return this.content.getText();
}
async waitForDialogToOpen(): Promise<void> {
await browser.wait(EC.presenceOf(this.rootElem), BROWSER_WAIT_TIMEOUT);
await browser.wait(EC.visibilityOf(this.content), BROWSER_WAIT_TIMEOUT);
await browser.wait(EC.presenceOf(browser.element(by.css('.cdk-overlay-backdrop'))), BROWSER_WAIT_TIMEOUT);
}
async waitForDialogToClose(): Promise<void> {
await browser.wait(EC.stalenessOf(this.content), BROWSER_WAIT_TIMEOUT, '---- timeout waiting for dialog to close ----');
}
async isDialogOpen(): Promise<boolean> {
return (await this.rootElem.isPresent()) && (await this.rootElem.isDisplayed());
}
async getTitle(): Promise<string> {
return this.title.getText();
}
getActionButton(selector: Locator): ElementFinder {
return this.rootElem.element(selector);
}
async isButtonEnabled(selector: Locator): Promise<boolean> {
return (await this.getActionButton(selector).isPresent()) && (await this.getActionButton(selector).isEnabled());
}
async clickButton(selector: Locator): Promise<void> {
await this.getActionButton(selector).click();
}
}

View File

@@ -23,45 +23,22 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser, ExpectedConditions as EC } from 'protractor';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { Component } from '../component';
import { by } from 'protractor';
import { GenericDialog } from '../dialog/generic-dialog';
export class ManageVersionsDialog extends Component {
export class ManageVersionsDialog extends GenericDialog {
private static selectors = {
root: '.aca-node-versions-dialog',
title: '.mat-dialog-title',
content: '.mat-dialog-content',
button: '.mat-button'
closeButton: by.cssContainingText('.mat-button', 'Close')
};
title: ElementFinder = this.component.element(by.css(ManageVersionsDialog.selectors.title));
content: ElementFinder = this.component.element(by.css(ManageVersionsDialog.selectors.content));
closeButton: ElementFinder = this.component.element(by.cssContainingText(ManageVersionsDialog.selectors.button, 'Close'));
constructor(ancestor?: string) {
super(ManageVersionsDialog.selectors.root, ancestor);
constructor() {
super(ManageVersionsDialog.selectors.root);
}
async waitForDialogToClose() {
await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT);
}
async isDialogOpen() {
return browser.$(ManageVersionsDialog.selectors.root).isDisplayed();
}
async getTitle() {
return this.title.getText();
}
async getText() {
return this.content.getText();
}
async clickClose() {
await this.closeButton.click();
async clickClose(): Promise<void> {
await this.clickButton(ManageVersionsDialog.selectors.closeButton);
await this.waitForDialogToClose();
}
}

View File

@@ -23,71 +23,45 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser, ExpectedConditions as EC, until } from 'protractor';
import { ElementFinder, by, browser, until } from 'protractor';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { Component } from '../component';
import { GenericDialog } from '../dialog/generic-dialog';
export class PasswordDialog extends Component {
export class PasswordDialog extends GenericDialog {
private static selectors = {
root: 'adf-pdf-viewer-password-dialog',
title: '.mat-dialog-title',
content: '.mat-dialog-content',
passwordInput: 'input[type="Password"]',
actionButtons: '.mat-dialog-actions',
errorMessage: '.mat-error'
errorMessage: '.mat-error',
closeButton: by.css('[data-automation-id="adf-password-dialog-close"]'),
submitButton: by.css('[data-automation-id="adf-password-dialog-submit"]')
};
title: ElementFinder = this.component.element(by.css(PasswordDialog.selectors.title));
content: ElementFinder = this.component.element(by.css(PasswordDialog.selectors.content));
passwordInput: ElementFinder = this.component.element(by.css(PasswordDialog.selectors.passwordInput));
errorMessage: ElementFinder = this.component.element(by.css(PasswordDialog.selectors.errorMessage));
closeButton: ElementFinder = this.component.element(by.buttonText('Close'));
submitButton: ElementFinder = this.component.element(by.buttonText('Submit'));
passwordInput: ElementFinder = this.rootElem.element(by.css(PasswordDialog.selectors.passwordInput));
errorMessage: ElementFinder = this.rootElem.element(by.css(PasswordDialog.selectors.errorMessage));
constructor(ancestor?: string) {
super(PasswordDialog.selectors.root, ancestor);
constructor() {
super(PasswordDialog.selectors.root);
}
async waitForDialogToClose() {
await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT);
async isCloseEnabled(): Promise<boolean> {
return this.isButtonEnabled(PasswordDialog.selectors.closeButton);
}
async waitForDialogToOpen() {
await browser.wait(EC.presenceOf(this.title), BROWSER_WAIT_TIMEOUT);
async isSubmitEnabled(): Promise<boolean> {
return this.isButtonEnabled(PasswordDialog.selectors.submitButton);
}
async isDialogOpen() {
try {
const dialog = await browser.wait(until.elementLocated(by.css(PasswordDialog.selectors.root)), BROWSER_WAIT_TIMEOUT, '------- timeout waiting for dialog')
return dialog.isDisplayed();
} catch (error) {
return false;
}
async clickClose(): Promise<void> {
await this.clickButton(PasswordDialog.selectors.closeButton);
}
async getTitle() {
return this.title.getText();
async clickSubmit(): Promise<void> {
await this.clickButton(PasswordDialog.selectors.submitButton);
}
async isCloseEnabled() {
return this.closeButton.isEnabled();
}
async isSubmitEnabled() {
return this.submitButton.isEnabled();
}
async clickClose() {
await this.closeButton.click();
}
async clickSubmit() {
await this.submitButton.click();
}
async isPasswordInputDisplayed() {
async isPasswordInputDisplayed(): Promise<boolean> {
const present = await browser.isElementPresent(this.passwordInput);
if (present) {
return this.passwordInput.isDisplayed();
@@ -96,19 +70,19 @@ export class PasswordDialog extends Component {
}
}
async isErrorDisplayed() {
async isErrorDisplayed(): Promise<boolean> {
const elem = await browser.wait(until.elementLocated(by.css(PasswordDialog.selectors.errorMessage)), BROWSER_WAIT_TIMEOUT, '------- timeout waiting for error message to appear')
return browser.isElementPresent(elem);
return (await browser.isElementPresent(elem)) && (await elem.isDisplayed());
}
async getErrorMessage() {
async getErrorMessage(): Promise<string> {
if (await this.isErrorDisplayed()) {
return this.errorMessage.getText();
}
return '';
}
async enterPassword(password: string) {
async enterPassword(password: string): Promise<void> {
await this.passwordInput.clear();
await this.passwordInput.sendKeys(password);
}

View File

@@ -23,64 +23,41 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser, ExpectedConditions as EC } from 'protractor';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { Component } from '../component';
import { by } from 'protractor';
import { GenericDialog } from '../dialog/generic-dialog';
import { DropDownBreadcrumb } from '../breadcrumb/dropdown-breadcrumb';
import { DataTable } from '../data-table/data-table';
export class SelectTemplateDialog extends Component {
export class SelectTemplateDialog extends GenericDialog {
private static selectors = {
root: '.aca-template-node-selector-dialog',
title: '.mat-dialog-title',
button: '.mat-dialog-actions button'
};
title: ElementFinder = this.component.element(by.css(SelectTemplateDialog.selectors.title));
nextButton: ElementFinder = this.component.element(by.cssContainingText(SelectTemplateDialog.selectors.button, 'Next'));
cancelButton: ElementFinder = this.component.element(by.cssContainingText(SelectTemplateDialog.selectors.button, 'Cancel'));
nextButton: by.css('[data-automation-id="content-node-selector-actions-choose"]'),
cancelButton: by.css('[data-automation-id="content-node-selector-actions-cancel"]')
};
breadcrumb: DropDownBreadcrumb = new DropDownBreadcrumb();
dataTable: DataTable = new DataTable(SelectTemplateDialog.selectors.root);
constructor(ancestor?: string) {
super(SelectTemplateDialog.selectors.root, ancestor);
constructor() {
super(SelectTemplateDialog.selectors.root);
}
async waitForDialogToOpen(): Promise<void> {
await browser.wait(EC.presenceOf(this.title), BROWSER_WAIT_TIMEOUT, 'timeout waiting for dialog title');
await browser.wait(EC.presenceOf(browser.element(by.css('.cdk-overlay-backdrop'))), BROWSER_WAIT_TIMEOUT, 'timeout waiting for overlay backdrop');
}
async waitForDialogToClose(): Promise<void> {
await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT, '---- timeout waiting for dialog to close ----');
}
async isDialogOpen(): Promise<boolean> {
return browser.isElementPresent(by.css(SelectTemplateDialog.selectors.root));
}
async getTitle(): Promise<string> {
return this.title.getText();
}
// action buttons
async isCancelButtonEnabled(): Promise<boolean> {
return this.cancelButton.isEnabled();
return this.isButtonEnabled(SelectTemplateDialog.selectors.cancelButton);
}
async isNextButtonEnabled(): Promise<boolean> {
return this.nextButton.isEnabled();
return this.isButtonEnabled(SelectTemplateDialog.selectors.nextButton);
}
async clickCancel(): Promise<void> {
await this.cancelButton.click();
await this.clickButton(SelectTemplateDialog.selectors.cancelButton);
await this.waitForDialogToClose();
}
async clickNext(): Promise<void> {
await this.nextButton.click();
await this.clickButton(SelectTemplateDialog.selectors.nextButton);
await this.waitForDialogToClose();
}
}

View File

@@ -23,16 +23,15 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, ElementArrayFinder, by, browser, ExpectedConditions as EC } from 'protractor';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { ElementFinder, ElementArrayFinder, by } from 'protractor';
import { DateTimePicker } from '../../components/datetime-picker/datetime-picker';
import { Component } from '../component';
import { GenericDialog } from '../dialog/generic-dialog';
export class ShareDialog extends Component {
export class ShareDialog extends GenericDialog {
private static selectors = {
root: '.adf-share-dialog',
title: `[data-automation-id='adf-share-dialog-title']`,
dialogTitle: `[data-automation-id='adf-share-dialog-title']`,
info: '.adf-share-link__info',
label: '.adf-share-link__label',
shareToggle: `[data-automation-id='adf-share-toggle']`,
@@ -41,118 +40,106 @@ export class ShareDialog extends Component {
expireToggle: `[data-automation-id='adf-expire-toggle']`,
datetimePickerButton: '.mat-datetimepicker-toggle',
expirationInput: 'input[formcontrolname="time"]',
button: `[data-automation-id='adf-share-dialog-close']`
closeButton: by.css(`[data-automation-id='adf-share-dialog-close']`)
};
dateTimePicker = new DateTimePicker();
title: ElementFinder = this.component.element(by.css(ShareDialog.selectors.title));
infoText: ElementFinder = this.component.element(by.css(ShareDialog.selectors.info));
labels: ElementArrayFinder = this.component.all(by.css(ShareDialog.selectors.label));
shareToggle: ElementFinder = this.component.element(by.css(ShareDialog.selectors.shareToggle));
url: ElementFinder = this.component.element(by.css(ShareDialog.selectors.linkUrl));
urlAction: ElementFinder = this.component.element(by.css(ShareDialog.selectors.inputAction));
expireToggle: ElementFinder = this.component.element(by.css(ShareDialog.selectors.expireToggle));
expireInput: ElementFinder = this.component.element(by.css(ShareDialog.selectors.expirationInput));
datetimePickerButton: ElementFinder = this.component.element(by.css(ShareDialog.selectors.datetimePickerButton));
closeButton: ElementFinder = this.component.element(by.css(ShareDialog.selectors.button));
dialogTitle: ElementFinder = this.rootElem.element(by.css(ShareDialog.selectors.dialogTitle));
infoText: ElementFinder = this.rootElem.element(by.css(ShareDialog.selectors.info));
labels: ElementArrayFinder = this.rootElem.all(by.css(ShareDialog.selectors.label));
shareToggle: ElementFinder = this.rootElem.element(by.css(ShareDialog.selectors.shareToggle));
url: ElementFinder = this.rootElem.element(by.css(ShareDialog.selectors.linkUrl));
urlAction: ElementFinder = this.rootElem.element(by.css(ShareDialog.selectors.inputAction));
expireToggle: ElementFinder = this.rootElem.element(by.css(ShareDialog.selectors.expireToggle));
expireInput: ElementFinder = this.rootElem.element(by.css(ShareDialog.selectors.expirationInput));
datetimePickerButton: ElementFinder = this.rootElem.element(by.css(ShareDialog.selectors.datetimePickerButton));
constructor(ancestor?: string) {
super(ShareDialog.selectors.root, ancestor);
constructor() {
super(ShareDialog.selectors.root);
}
async waitForDialogToClose() {
await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT, 'share dialog did not close');
async getTitle(): Promise<string> {
return this.dialogTitle.getText();
}
async waitForDialogToOpen() {
await browser.wait(EC.presenceOf(this.title), BROWSER_WAIT_TIMEOUT);
}
async isDialogOpen() {
return browser.isElementPresent(by.css(ShareDialog.selectors.root));
}
async getTitle() {
return this.title.getText();
}
async getInfoText() {
async getInfoText(): Promise<string> {
return this.infoText.getText();
}
getLabels() {
getLabels(): ElementArrayFinder {
return this.labels;
}
async getLinkUrl() {
async getLinkUrl(): Promise<string> {
return this.url.getAttribute('value');
}
async isUrlReadOnly() {
return this.url.getAttribute('readonly');
async isUrlReadOnly(): Promise<boolean> {
const urlAttr = await this.url.getAttribute('readonly');
return urlAttr === 'true';
}
async isCloseEnabled() {
return this.closeButton.isEnabled();
async isCloseEnabled(): Promise<boolean> {
return this.isButtonEnabled(ShareDialog.selectors.closeButton);
}
async clickClose() {
await this.closeButton.click();
async clickClose(): Promise<void> {
await this.clickButton(ShareDialog.selectors.closeButton);
await this.waitForDialogToClose();
}
getShareToggle() {
getShareToggle(): ElementFinder {
return this.shareToggle;
}
getExpireToggle() {
getExpireToggle(): ElementFinder {
return this.expireToggle;
}
getExpireInput() {
getExpireInput(): ElementFinder {
return this.expireInput;
}
async isShareToggleChecked() {
async isShareToggleChecked(): Promise<boolean> {
const toggleClass = await this.getShareToggle().getAttribute('class');
return toggleClass.includes('checked');
}
async isShareToggleDisabled() {
async isShareToggleDisabled(): Promise<boolean> {
const toggleClass = await this.getShareToggle().getAttribute('class');
return toggleClass.includes('mat-disabled');
}
async isExpireToggleEnabled() {
async isExpireToggleEnabled(): Promise<boolean> {
const toggleClass = await this.getExpireToggle().getAttribute('class');
return toggleClass.includes('checked');
}
async copyUrl() {
async copyUrl(): Promise<void> {
await this.urlAction.click();
}
async openDatetimePicker() {
async openDatetimePicker(): Promise<void> {
await this.datetimePickerButton.click();
}
async closeDatetimePicker() {
async closeDatetimePicker(): Promise<void> {
if (await this.dateTimePicker.isCalendarOpen()) {
await this.datetimePickerButton.click();
}
}
async getExpireDate() {
async getExpireDate(): Promise<string> {
return this.getExpireInput().getAttribute('value');
}
async clickExpirationToggle() {
async clickExpirationToggle(): Promise<void> {
await this.expireToggle.click();
}
async clickShareToggle() {
async clickShareToggle(): Promise<void> {
await this.shareToggle.click();
}
}

View File

@@ -23,98 +23,71 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser, ExpectedConditions as EC } from 'protractor';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { Component } from '../component';
import { Utils } from '../../utilities/utils';
import { ElementFinder, by } from 'protractor';
import { GenericDialog } from '../dialog/generic-dialog';
export class UploadNewVersionDialog extends Component {
export class UploadNewVersionDialog extends GenericDialog {
private static selectors = {
root: '.aca-node-version-upload-dialog',
title: '.mat-dialog-title',
content: '.mat-dialog-content',
button: '.mat-button',
cancelButton: by.cssContainingText('.mat-button', 'Cancel'),
uploadButton: by.cssContainingText('.mat-button', 'Upload'),
radioButton: `.mat-radio-label`,
descriptionTextArea: 'textarea'
};
title: ElementFinder = this.component.element(by.css(UploadNewVersionDialog.selectors.title));
content: ElementFinder = this.component.element(by.css(UploadNewVersionDialog.selectors.content));
cancelButton: ElementFinder = this.component.element(by.cssContainingText(UploadNewVersionDialog.selectors.button, 'Cancel'));
uploadButton: ElementFinder = this.component.element(by.cssContainingText(UploadNewVersionDialog.selectors.button, 'Upload'));
majorOption: ElementFinder = this.component.element(by.cssContainingText(UploadNewVersionDialog.selectors.radioButton, 'Major'));
minorOption: ElementFinder = this.component.element(by.cssContainingText(UploadNewVersionDialog.selectors.radioButton, 'Minor'));
majorOption: ElementFinder = this.rootElem.element(by.cssContainingText(UploadNewVersionDialog.selectors.radioButton, 'Major'));
minorOption: ElementFinder = this.rootElem.element(by.cssContainingText(UploadNewVersionDialog.selectors.radioButton, 'Minor'));
description: ElementFinder = this.component.element(by.css(UploadNewVersionDialog.selectors.descriptionTextArea));
description: ElementFinder = this.rootElem.element(by.css(UploadNewVersionDialog.selectors.descriptionTextArea));
constructor(ancestor?: string) {
super(UploadNewVersionDialog.selectors.root, ancestor);
constructor() {
super(UploadNewVersionDialog.selectors.root);
}
async waitForDialogToClose() {
await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT);
}
async isDialogOpen() {
return browser.$(UploadNewVersionDialog.selectors.root).isDisplayed();
}
async getTitle() {
return this.title.getText();
}
async getText() {
return this.content.getText();
}
async isDescriptionDisplayed() {
async isDescriptionDisplayed(): Promise<boolean> {
return this.description.isDisplayed();
}
async isMinorOptionDisplayed() {
async isMinorOptionDisplayed(): Promise<boolean> {
return this.minorOption.isDisplayed();
}
async isMajorOptionDisplayed() {
async isMajorOptionDisplayed(): Promise<boolean> {
return this.majorOption.isDisplayed();
}
async isCancelButtonEnabled() {
return this.cancelButton.isEnabled();
async isCancelButtonEnabled(): Promise<boolean> {
return this.isButtonEnabled(UploadNewVersionDialog.selectors.cancelButton);
}
async isUploadButtonEnabled() {
return this.uploadButton.isEnabled();
async isUploadButtonEnabled(): Promise<boolean> {
return this.isButtonEnabled(UploadNewVersionDialog.selectors.uploadButton);
}
async clickCancel() {
await this.cancelButton.click();
async clickCancel(): Promise<void> {
await this.clickButton(UploadNewVersionDialog.selectors.cancelButton);
await this.waitForDialogToClose();
}
async clickUpload() {
await this.uploadButton.click();
async clickUpload(): Promise<void> {
await this.clickButton(UploadNewVersionDialog.selectors.uploadButton);
}
async clickMajor() {
async clickMajor(): Promise<void> {
await this.majorOption.click();
}
async clickMinor() {
async clickMinor(): Promise<void> {
await this.minorOption.click();
}
async enterDescription(description: string) {
async enterDescription(description: string): Promise<void> {
await this.description.clear();
await Utils.typeInField(this.description, description);
await this.description.sendKeys(description);
}
}