fix ordering e2e failing test (#4825)

* ordering fix use common method in datatable

* ordering fix use common method in datatable

* fix sorting ps e2e

* fix ordering

* move search page in testing and fix sorting boolean flag

* fix import

* fix moment

* use common sort method in document list test

* use common sort method in document list test

* remove unnecesary sort control

* remove duplicate test

* remove e2e suspended removed status

* documentation
This commit is contained in:
Eugenio Romano
2019-06-11 07:34:16 +01:00
committed by GitHub
parent c85df84a01
commit 990fa4625b
43 changed files with 951 additions and 477 deletions

View File

@@ -18,3 +18,5 @@
export * from './like.page';
export * from './rate.page';
export * from './document-list.page';
export * from './search/public-api';

View File

@@ -0,0 +1,162 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { by, browser, protractor } from 'protractor';
import { DatePickerPage } from '../../../material/pages/date-picker.page';
import { BrowserVisibility } from '../../../core/utils/browser-visibility';
export class DateRangeFilterPage {
fromField = by.css('input[data-automation-id="date-range-from-input"]');
fromDateToggle = by.css('mat-datepicker-toggle[data-automation-id="date-range-from-date-toggle"]');
toField = by.css('input[data-automation-id="date-range-to-input"]');
toDateToggle = by.css('mat-datepicker-toggle[data-automation-id="date-range-to-date-toggle"]');
applyButton = by.css('button[data-automation-id="date-range-apply-btn"]');
clearButton = by.css('button[data-automation-id="date-range-clear-btn"]');
fromErrorMessage = by.css('mat-error[data-automation-id="date-range-from-error"]');
toErrorMessage = by.css('mat-error[data-automation-id="date-range-to-error"]');
filter;
constructor(filter) {
this.filter = filter;
}
getFromDate() {
return this.filter.element(this.fromField).getAttribute('value');
}
putFromDate(date) {
this.checkFromFieldIsDisplayed();
this.filter.element(this.fromField).clear();
this.filter.element(this.fromField).sendKeys(date);
this.filter.element(this.fromField).sendKeys(protractor.Key.ENTER);
return this;
}
getFromCalendarSelectedDate() {
const selectedDate = this.openFromDatePicker().getSelectedDate();
new DatePickerPage().closeDatePicker();
return selectedDate;
}
openFromDatePicker() {
BrowserVisibility.waitUntilElementIsClickable(this.filter.element(this.fromDateToggle));
this.filter.element(this.fromDateToggle).click();
return new DatePickerPage().checkDatePickerIsDisplayed();
}
openToDatePicker() {
BrowserVisibility.waitUntilElementIsClickable(this.filter.element(this.toDateToggle));
this.filter.element(this.toDateToggle).click();
return new DatePickerPage().checkDatePickerIsDisplayed();
}
clickFromField() {
BrowserVisibility.waitUntilElementIsClickable(this.filter.element(this.fromField));
this.filter.element(this.fromField).click();
return this;
}
checkFromErrorMessageIsDisplayed(msg: string) {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.fromErrorMessage));
browser.controlFlow().execute(async () => {
await expect(this.filter.element(this.fromErrorMessage).getText()).toEqual(msg);
});
return this;
}
checkFromErrorMessageIsNotDisplayed() {
BrowserVisibility.waitUntilElementIsNotVisible(this.filter.element(this.fromErrorMessage));
return this;
}
checkFromFieldIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.fromField));
return this;
}
checkFromDateToggleIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.fromDateToggle));
return this;
}
getToDate() {
return this.filter.element(this.toField).getAttribute('value');
}
putToDate(date) {
this.checkToFieldIsDisplayed();
this.filter.element(this.toField).clear();
this.filter.element(this.toField).sendKeys(date);
this.filter.element(this.toField).sendKeys(protractor.Key.ENTER);
return this;
}
clickToField() {
BrowserVisibility.waitUntilElementIsClickable(this.filter.element(this.toField));
this.filter.element(this.toField).click();
return this;
}
checkToErrorMessageIsDisplayed(msg) {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.toErrorMessage));
browser.controlFlow().execute(async () => {
await expect(this.filter.element(this.toErrorMessage).getText()).toEqual(msg);
});
return this;
}
checkToFieldIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.toField));
return this;
}
checkToDateToggleIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.toDateToggle));
return this;
}
clickApplyButton() {
BrowserVisibility.waitUntilElementIsClickable(this.filter.element(this.applyButton));
this.filter.element(this.applyButton).click();
return this;
}
checkApplyButtonIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.applyButton));
return this;
}
checkApplyButtonIsEnabled() {
browser.controlFlow().execute(async () => {
await expect(this.filter.element(this.applyButton).isEnabled()).toBe(true);
});
return this;
}
checkApplyButtonIsDisabled() {
browser.controlFlow().execute(async () => {
await expect(this.filter.element(this.applyButton).isEnabled()).toBe(false);
});
return this;
}
checkClearButtonIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.clearButton));
return this;
}
}

View File

@@ -0,0 +1,165 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { by, protractor } from 'protractor';
import { BrowserActions } from '../../../core/utils/browser-actions';
import { BrowserVisibility } from '../../../core/utils/browser-visibility';
export class NumberRangeFilterPage {
fromInput = by.css('input[data-automation-id="number-range-from-input"]');
toInput = by.css('input[data-automation-id="number-range-to-input"]');
applyButton = by.css('button[data-automation-id="number-range-btn-apply"]');
clearButton = by.css('button[data-automation-id="number-range-btn-clear"]');
fromErrorInvalid = by.css('mat-error[data-automation-id="number-range-from-error-invalid"]');
fromErrorRequired = by.css('mat-error[data-automation-id="number-range-from-error-required"]');
toErrorInvalid = by.css('mat-error[data-automation-id="number-range-to-error-invalid"]');
toErrorRequired = by.css('mat-error[data-automation-id="number-range-to-error-required"]');
filter;
constructor(filter) {
this.filter = filter;
}
clearFromField() {
BrowserVisibility.waitUntilElementIsClickable(this.filter.element(this.fromInput));
this.filter.element(this.fromInput).getAttribute('value').then((value) => {
for (let i = value.length; i >= 0; i--) {
this.filter.element(this.fromInput).sendKeys(protractor.Key.BACK_SPACE);
}
});
return this;
}
getFromNumber() {
return this.filter.element(this.fromInput).getAttribute('value');
}
putFromNumber(value) {
this.checkFromFieldIsDisplayed();
this.filter.element(this.fromInput).clear();
this.filter.element(this.fromInput).sendKeys(value);
this.filter.element(this.fromInput).sendKeys(protractor.Key.ENTER);
return this;
}
getFromErrorRequired() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.fromErrorRequired));
return BrowserActions.getText(this.filter.element(this.fromErrorRequired));
}
checkFromErrorRequiredIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.fromErrorRequired));
return this;
}
getFromErrorInvalid() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.fromErrorInvalid));
return BrowserActions.getText(this.filter.element(this.fromErrorInvalid));
}
checkFromErrorInvalidIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.fromErrorInvalid));
return this;
}
checkFromFieldIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.fromInput));
return this;
}
clearToField() {
BrowserVisibility.waitUntilElementIsClickable(this.filter.element(this.toInput));
this.filter.element(this.toInput).getAttribute('value').then((value) => {
for (let i = value.length; i >= 0; i--) {
this.filter.element(this.toInput).sendKeys(protractor.Key.BACK_SPACE);
}
});
return this;
}
getToNumber() {
return this.filter.element(this.toInput).getAttribute('value');
}
putToNumber(value) {
this.checkToFieldIsDisplayed();
this.filter.element(this.toInput).clear();
this.filter.element(this.toInput).sendKeys(value);
this.filter.element(this.toInput).sendKeys(protractor.Key.ENTER);
return this;
}
getToErrorRequired() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.toErrorRequired));
return BrowserActions.getText(this.filter.element(this.toErrorRequired));
}
checkToErrorRequiredIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.toErrorRequired));
return this;
}
getToErrorInvalid() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.toErrorInvalid));
return BrowserActions.getText(this.filter.element(this.toErrorInvalid));
}
checkToErrorInvalidIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.toErrorInvalid));
return this;
}
checkToFieldIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.toInput));
return this;
}
clickApplyButton() {
BrowserVisibility.waitUntilElementIsClickable(this.filter.element(this.applyButton));
this.filter.element(this.applyButton).click();
return this;
}
checkApplyButtonIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.applyButton));
return this;
}
checkApplyButtonIsEnabled() {
return this.filter.element(this.applyButton).isEnabled();
}
clickClearButton() {
BrowserVisibility.waitUntilElementIsClickable(this.filter.element(this.clearButton));
this.filter.element(this.clearButton).click();
return this;
}
checkClearButtonIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.clearButton));
return this;
}
checkNoErrorMessageIsDisplayed() {
BrowserVisibility.waitUntilElementIsNotVisible(this.filter.element(this.fromErrorInvalid));
BrowserVisibility.waitUntilElementIsNotVisible(this.filter.element(this.fromErrorRequired));
BrowserVisibility.waitUntilElementIsNotVisible(this.filter.element(this.toErrorInvalid));
BrowserVisibility.waitUntilElementIsNotVisible(this.filter.element(this.toErrorRequired));
return this;
}
}

View File

@@ -0,0 +1,25 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './search-categories.page';
export * from './date-range-filter.page';
export * from './number-range-filter.page';
export * from './search-checkList.page';
export * from './search-radio.page';
export * from './search-slider.page';
export * from './search-sorting-picker.page';
export * from './search-text.page';

View File

@@ -0,0 +1,86 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { by, ElementFinder } from 'protractor';
import { SearchTextPage } from './search-text.page';
import { SearchCheckListPage } from './search-checkList.page';
import { SearchRadioPage } from './search-radio.page';
import { DateRangeFilterPage } from './date-range-filter.page';
import { NumberRangeFilterPage } from './number-range-filter.page';
import { SearchSliderPage } from './search-slider.page';
import { BrowserActions } from '../../../core/utils/browser-actions';
import { BrowserVisibility } from '../../../core/utils/browser-visibility';
export class SearchCategoriesPage {
checkListFiltersPage(filter: ElementFinder) {
return new SearchCheckListPage(filter);
}
textFiltersPage(filter: ElementFinder) {
return new SearchTextPage(filter);
}
radioFiltersPage(filter: ElementFinder) {
return new SearchRadioPage(filter);
}
dateRangeFilter(filter: ElementFinder) {
return new DateRangeFilterPage(filter);
}
numberRangeFilter(filter: ElementFinder) {
return new NumberRangeFilterPage(filter);
}
sliderFilter(filter: ElementFinder) {
return new SearchSliderPage(filter);
}
checkFilterIsDisplayed(filter: ElementFinder) {
BrowserVisibility.waitUntilElementIsVisible(filter);
return this;
}
clickFilter(filter: ElementFinder) {
BrowserVisibility.waitUntilElementIsVisible(filter);
filter.element(by.css('mat-expansion-panel-header')).click();
return this;
}
clickFilterHeader(filter: ElementFinder) {
const fileSizeFilterHeader = filter.element(by.css('mat-expansion-panel-header'));
BrowserVisibility.waitUntilElementIsClickable(fileSizeFilterHeader);
BrowserActions.click(fileSizeFilterHeader);
return this;
}
checkFilterIsCollapsed(filter: ElementFinder) {
filter.getAttribute('class').then((elementClass) => {
expect(elementClass).not.toContain('mat-expanded');
});
return this;
}
checkFilterIsExpanded(filter: ElementFinder) {
filter.getAttribute('class').then((elementClass) => {
expect(elementClass).toContain('mat-expanded');
});
return this;
}
}

View File

@@ -0,0 +1,182 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { element, by, ElementFinder } from 'protractor';
import { BrowserActions } from '../../../core/utils/browser-actions';
import { BrowserVisibility } from '../../../core/utils/browser-visibility';
export class SearchCheckListPage {
filter: ElementFinder;
inputBy = by.css('div[class*="mat-expansion-panel-content"] input');
showMoreBy = by.css('button[title="Show more"]');
showLessBy = by.css('button[title="Show less"]');
clearAllButton = by.css('button');
constructor(filter: ElementFinder) {
this.filter = filter;
}
clickCheckListOption(option: string) {
BrowserVisibility.waitUntilElementIsVisible(this.filter);
const result = this.filter.all(by.css(`mat-checkbox[data-automation-id*='${option}'] .mat-checkbox-inner-container`)).first();
BrowserActions.click(result);
}
checkChipIsDisplayed(option: string) {
BrowserVisibility.waitUntilElementIsVisible(element(by.cssContainingText('mat-chip', option)).element(by.css('mat-icon')));
return this;
}
checkChipIsNotDisplayed(option: string) {
BrowserVisibility.waitUntilElementIsNotOnPage(element(by.cssContainingText('mat-chip', option)).element(by.css('mat-icon')));
return this;
}
removeFilterOption(option: string) {
const cancelChipButton = element(by.cssContainingText('mat-chip', option)).element(by.css('mat-icon'));
BrowserActions.click(cancelChipButton);
return this;
}
filterBy(option: string) {
this.checkSearchFilterInputIsDisplayed();
this.searchInFilter(option);
this.clickCheckListOption(option);
return this;
}
checkSearchFilterInputIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.all(this.inputBy).first());
return this;
}
searchInFilter(option: string) {
BrowserVisibility.waitUntilElementIsClickable(this.filter);
const inputElement = this.filter.all(this.inputBy).first();
BrowserVisibility.waitUntilElementIsClickable(inputElement);
inputElement.clear();
this.filter.all(this.inputBy).first().sendKeys(option);
return this;
}
checkShowLessButtonIsNotDisplayed() {
BrowserVisibility.waitUntilElementIsNotVisible(this.filter.element(this.showLessBy));
return this;
}
checkShowLessButtonIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.showLessBy));
return this;
}
checkShowMoreButtonIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.showMoreBy));
return this;
}
checkShowMoreButtonIsNotDisplayed() {
BrowserVisibility.waitUntilElementIsNotVisible(this.filter.element(this.showMoreBy));
return this;
}
clickShowMoreButtonUntilIsNotDisplayed() {
this.filter.element(this.showMoreBy).isDisplayed().then(async (visible) => {
if (visible) {
this.filter.element(this.showMoreBy).click();
this.clickShowMoreButtonUntilIsNotDisplayed();
}
}, () => {
});
return this;
}
clickShowLessButtonUntilIsNotDisplayed() {
this.filter.element(this.showLessBy).isDisplayed().then(async (visible) => {
if (visible) {
this.filter.element(this.showLessBy).click();
this.clickShowLessButtonUntilIsNotDisplayed();
}
}, () => {
});
return this;
}
getBucketNumberOfFilterType(option: string) {
const fileTypeFilter = this.filter.all(by.css('mat-checkbox[data-automation-id*=".' + option + '"] span')).first();
BrowserVisibility.waitUntilElementIsVisible(fileTypeFilter);
const bucketNumber = fileTypeFilter.getText().then((valueOfBucket) => {
const numberOfBucket = valueOfBucket.split('(')[1];
const totalNumberOfBucket = numberOfBucket.split(')')[0];
return totalNumberOfBucket.trim();
});
return bucketNumber;
}
checkCheckListOptionIsDisplayed(option: string) {
BrowserVisibility.waitUntilElementIsVisible(this.filter);
const result = this.filter.element(by.css(`mat-checkbox[data-automation-id*='-${option}']`));
return BrowserVisibility.waitUntilElementIsVisible(result);
}
checkCheckListOptionIsNotSelected(option: string) {
BrowserVisibility.waitUntilElementIsVisible(this.filter);
const result = this.filter.element(by.css(`mat-checkbox[data-automation-id*='-${option}'][class*='checked']`));
return BrowserVisibility.waitUntilElementIsNotVisible(result);
}
checkCheckListOptionIsSelected(option: string) {
BrowserVisibility.waitUntilElementIsVisible(this.filter);
const result = this.filter.element(by.css(`mat-checkbox[data-automation-id*='-${option}'][class*='checked']`));
return BrowserVisibility.waitUntilElementIsVisible(result);
}
checkClearAllButtonIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter);
const result = this.filter.element(this.clearAllButton);
return BrowserVisibility.waitUntilElementIsVisible(result);
}
clickClearAllButton() {
BrowserVisibility.waitUntilElementIsVisible(this.filter);
const result = this.filter.element(this.clearAllButton);
BrowserVisibility.waitUntilElementIsVisible(result);
return BrowserActions.click(result);
}
getCheckListOptionsNumberOnPage() {
BrowserVisibility.waitUntilElementIsVisible(this.filter);
const checkListOptions = this.filter.all(by.css('div[class="checklist"] mat-checkbox'));
return checkListOptions.count();
}
clickShowMoreButton() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.showMoreBy));
return this.filter.element(this.showMoreBy).click();
}
clickShowLessButton() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.showLessBy));
return this.filter.element(this.showLessBy).click();
}
}

View File

@@ -0,0 +1,75 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { element, by, browser } from 'protractor';
import { BrowserActions } from '../../../core/utils/browser-actions';
import { BrowserVisibility } from '../../../core/utils/browser-visibility';
export class SearchRadioPage {
filter;
showMoreButton = element(by.css('adf-search-radio button[title="Show more"]'));
showLessButton = element(by.css('adf-search-radio button[title="Show less"]'));
constructor(filter) {
this.filter = filter;
}
checkFilterRadioButtonIsDisplayed(filterName: string) {
const filterType = element(by.css('mat-radio-button[data-automation-id="search-radio-' + filterName + '"]'));
return BrowserVisibility.waitUntilElementIsVisible(filterType);
}
checkFilterRadioButtonIsChecked(filterName: string) {
const selectedFilterType = element(by.css('mat-radio-button[data-automation-id="search-radio-' + filterName + '"][class*="checked"]'));
return BrowserVisibility.waitUntilElementIsVisible(selectedFilterType);
}
clickFilterRadioButton(filterName: string) {
browser.executeScript(`document.querySelector('[data-automation-id="search-radio-${filterName}"] input').click();`);
}
getRadioButtonsNumberOnPage() {
const radioButtons = element.all(by.css('mat-radio-button'));
return radioButtons.count();
}
checkShowMoreButtonIsDisplayed() {
return BrowserVisibility.waitUntilElementIsVisible(this.showMoreButton);
}
checkShowLessButtonIsDisplayed() {
return BrowserVisibility.waitUntilElementIsVisible(this.showLessButton);
}
checkShowMoreButtonIsNotDisplayed() {
return BrowserVisibility.waitUntilElementIsNotVisible(this.showMoreButton);
}
checkShowLessButtonIsNotDisplayed() {
return BrowserVisibility.waitUntilElementIsNotVisible(this.showLessButton);
}
clickShowMoreButton() {
return BrowserActions.click(this.showMoreButton);
}
clickShowLessButton() {
return BrowserActions.click(this.showLessButton);
}
}

View File

@@ -0,0 +1,76 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { browser, by } from 'protractor';
import { BrowserVisibility } from '../../../core/utils/browser-visibility';
export class SearchSliderPage {
filter;
slider = by.css('mat-slider[data-automation-id="slider-range"]');
clearButton = by.css('button[data-automation-id="slider-btn-clear"]');
sliderWithThumbLabel = by.css('mat-slider[data-automation-id="slider-range"][class*="mat-slider-thumb-label-showing"]');
constructor(filter) {
this.filter = filter;
}
getMaxValue() {
return this.filter.element(this.slider).getAttribute('aria-valuemax');
}
getMinValue() {
return this.filter.element(this.slider).getAttribute('aria-valuemin');
}
getValue() {
return this.filter.element(this.slider).getAttribute('aria-valuenow');
}
setValue(value: number) {
browser.actions().dragAndDrop(
this.filter.element(this.slider).element(by.css('div[class="mat-slider-thumb"]')),
{ x: value * 10, y: 0 }
).perform();
return this;
}
checkSliderIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.slider));
return this;
}
checkSliderWithThumbLabelIsNotDisplayed() {
BrowserVisibility.waitUntilElementIsNotVisible(this.filter.element(this.sliderWithThumbLabel));
return this;
}
clickClearButton() {
BrowserVisibility.waitUntilElementIsClickable(this.filter.element(this.clearButton));
this.filter.element(this.clearButton).click();
return this;
}
checkClearButtonIsEnabled() {
return this.filter.element(this.clearButton).isEnabled();
}
checkClearButtonIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.filter.element(this.clearButton));
return this;
}
}

View File

@@ -0,0 +1,103 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { browser, by, element, protractor } from 'protractor';
import { BrowserActions } from '../../../core/utils/browser-actions';
import { BrowserVisibility } from '../../../core/utils/browser-visibility';
export class SearchSortingPickerPage {
sortingSelector = element(by.css('adf-sorting-picker div[class="mat-select-arrow"]'));
orderArrow = element(by.css('adf-sorting-picker button mat-icon'));
optionsDropdown = element(by.css('div[class*="mat-select-panel"]'));
sortBy(sortOrder: string, sortType: string | RegExp) {
BrowserActions.click(this.sortingSelector);
const selectedSortingOption = element(by.cssContainingText('span[class="mat-option-text"]', sortType));
BrowserActions.click(selectedSortingOption);
this.sortByOrder(sortOrder);
}
/**
* Sort the list by name column.
*
* @param sortOrder : 'ASC' to sort the list ascendant and 'DESC' for descendant
*/
sortByOrder(sortOrder: string) {
BrowserVisibility.waitUntilElementIsVisible(this.orderArrow);
this.orderArrow.getText().then((result) => {
if (sortOrder.toLocaleLowerCase() === 'asc') {
if (result !== 'arrow_upward') {
browser.executeScript(`document.querySelector('adf-sorting-picker button mat-icon').click();`);
}
} else {
if (result === 'arrow_upward') {
browser.executeScript(`document.querySelector('adf-sorting-picker button mat-icon').click();`);
}
}
});
}
clickSortingOption(option) {
const selectedSortingOption = element(by.cssContainingText('span[class="mat-option-text"]', option));
BrowserActions.click(selectedSortingOption);
return this;
}
clickSortingSelector() {
BrowserActions.click(this.sortingSelector);
return this;
}
checkOptionIsDisplayed(option) {
const optionSelector = this.optionsDropdown.element(by.cssContainingText('span[class="mat-option-text"]', option));
BrowserVisibility.waitUntilElementIsVisible(optionSelector);
return this;
}
checkOptionIsNotDisplayed(option) {
const optionSelector = this.optionsDropdown.element(by.cssContainingText('span[class="mat-option-text"]', option));
BrowserVisibility.waitUntilElementIsNotVisible(optionSelector);
return this;
}
checkOptionsDropdownIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.optionsDropdown);
return this;
}
checkSortingSelectorIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.sortingSelector);
return this;
}
checkOrderArrowIsDownward() {
const deferred = protractor.promise.defer();
BrowserVisibility.waitUntilElementIsVisible(this.orderArrow);
this.orderArrow.getText().then((result) => {
deferred.fulfill(result !== 'arrow_upward');
});
return deferred.promise;
}
checkOrderArrowIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.orderArrow);
return this;
}
}

View File

@@ -0,0 +1,41 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { protractor, by } from 'protractor';
import { BrowserVisibility } from '../../../core/utils/browser-visibility';
export class SearchTextPage {
filter;
inputBy = by.css('input');
constructor(filter) {
this.filter = filter;
}
getNamePlaceholder() {
BrowserVisibility.waitUntilElementIsVisible(this.filter);
return this.filter.element(this.inputBy).getAttribute('placeholder');
}
searchByName(name: string) {
BrowserVisibility.waitUntilElementIsVisible(this.filter);
this.filter.element(this.inputBy).clear();
this.filter.element(this.inputBy).sendKeys(name).sendKeys(protractor.Key.ENTER);
}
}

View File

@@ -132,25 +132,28 @@ export class DataTableComponentPage {
/**
* Check the list is sorted.
*
* @param sortOrder: 'true' if the list is expected to be sorted ascendant and 'false' for descendant
* @param locator: locator for column
* @param sortOrder: 'ASC' if the list is expected to be sorted ascending and 'DESC' for descending
* @param columnTitle: titleColumn column
* @return 'true' if the list is sorted as expected and 'false' if it isn't
*/
checkListIsSorted(sortOrder, locator) {
checkListIsSorted(sortOrder: string, columnTitle: string) {
const deferred = protractor.promise.defer();
const column = element.all(by.css(`div[title='${locator}'] span`));
const column = element.all(by.css(`div.adf-datatable-cell[title='${columnTitle}'] span`));
BrowserVisibility.waitUntilElementIsVisible(column.first());
const initialList = [];
column.each(function (currentElement) {
currentElement.getText().then(function (text) {
initialList.push(text);
if (text.length !== 0) {
initialList.push(text.toLowerCase());
}
});
}).then(function () {
let sortedList = initialList;
let sortedList = [...initialList];
sortedList = sortedList.sort();
if (sortOrder === false) {
if (sortOrder.toLocaleLowerCase() === 'desc') {
sortedList = sortedList.reverse();
}
deferred.fulfill(initialList.toString() === sortedList.toString());
});
return deferred.promise;
@@ -209,11 +212,16 @@ export class DataTableComponentPage {
return element.all(by.css(`adf-datatable div[title="${detail}"] span`));
}
sortByColumn(sortOrder, column) {
const locator = by.css(`div[data-automation-id="auto_id_${column}"]`);
/**
* Sort the list by name column.
*
* @param sortOrder : 'ASC' to sort the list ascendant and 'DESC' for descendant
*/
sortByColumn(sortOrder: string, titleColumn: string) {
const locator = by.css(`div[data-automation-id="auto_id_${titleColumn}"]`);
BrowserVisibility.waitUntilElementIsVisible(element(locator));
return element(locator).getAttribute('class').then(function (result) {
if (sortOrder === true) {
if (sortOrder.toLocaleLowerCase() === 'asc') {
if (!result.includes('sorted-asc')) {
if (result.includes('sorted-desc') || result.includes('sortable')) {
element(locator).click();
@@ -274,6 +282,10 @@ export class DataTableComponentPage {
return this;
}
waitTillContentLoaded() {
return BrowserVisibility.waitUntilElementIsVisible(this.contents);
}
checkColumnIsDisplayed(column) {
BrowserVisibility.waitUntilElementIsVisible(element(by.css(`div[data-automation-id="auto_id_entry.${column}"]`)));
return this;

View File

@@ -0,0 +1,29 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import moment from 'moment-es6';
export class DateUtil {
static formatDate(dateFormat: string, date: Date = new Date, days: number | string = 0): string {
return moment(date).add(days, 'days').format(dateFormat);
}
static parse(date: string, dateFormat: string = 'DD-MM-YY'): Date {
return moment(date, dateFormat).toDate();
}
}

View File

@@ -22,3 +22,4 @@ export * from './protractor.util';
export * from './local-storage.util';
export * from './file-browser.util';
export * from './form.util';
export * from './date-util';

View File

@@ -0,0 +1,78 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { element, by, browser } from 'protractor';
import { DateUtil } from '../../core/utils/date-util';
import { BrowserVisibility } from '../../core/utils/browser-visibility';
import { BrowserActions } from '../../core/utils/browser-actions';
export class DatePickerPage {
datePicker = element(by.css('mat-calendar'));
nextMonthButton = element(by.css('button[class*="mat-calendar-next-button"]'));
previousMonthButton = element(by.css('button[class*="mat-calendar-previous-button"]'));
getSelectedDate() {
return element(by.css('td[class*="mat-calendar-body-active"]')).getAttribute('aria-label');
}
checkDatesAfterDateAreDisabled(date) {
const afterDate = DateUtil.formatDate('DD-MM-YY', date, 1);
const afterCalendar = element(by.css(`td[class*="mat-calendar-body-cell"][aria-label="${afterDate}"]`));
browser.controlFlow().execute(async () => {
if (await afterCalendar.isPresent()) {
await expect(afterCalendar.getAttribute('aria-disabled')).toBe('true');
}
await expect(this.nextMonthButton.isEnabled()).toBe(false);
});
return this;
}
checkDatesBeforeDateAreDisabled(date) {
const beforeDate = DateUtil.formatDate('DD-MM-YY', date, -1);
const beforeCalendar = element(by.css(`td[class*="mat-calendar-body-cell"][aria-label="${beforeDate}"]`));
browser.controlFlow().execute(async () => {
if (await beforeCalendar.isPresent()) {
await expect(beforeCalendar.getAttribute('aria-disabled')).toBe('true');
}
await expect(this.previousMonthButton.isEnabled()).toBe(false);
});
return this;
}
selectTodayDate() {
this.checkDatePickerIsDisplayed();
const todayDate = element(by.css('.mat-calendar-body-today'));
BrowserActions.click(todayDate);
return this;
}
closeDatePicker() {
BrowserActions.closeMenuAndDialogs();
this.checkDatePickerIsNotDisplayed();
}
checkDatePickerIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.datePicker);
return this;
}
checkDatePickerIsNotDisplayed() {
BrowserVisibility.waitUntilElementIsNotVisible(this.datePicker);
return this;
}
}

View File

@@ -16,3 +16,4 @@
*/
export * from './tabs.page';
export * from './date-picker.page';

View File

@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { by, element, protractor } from 'protractor';
import { browser, by, element, protractor } from 'protractor';
import { EditProcessFilterDialogPage } from './dialog/edit-process-filter-dialog.page';
import { BrowserVisibility } from '../../core/utils/browser-visibility';
import { BrowserActions } from '../../core/utils/browser-actions';
@@ -76,6 +76,7 @@ export class EditProcessFilterCloudComponentPage {
const orderElement = element.all(by.cssContainingText('mat-option span', option)).first();
BrowserActions.click(orderElement);
browser.sleep(1000);
return this;
}

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { by, element, protractor } from 'protractor';
import { browser, by, element, protractor } from 'protractor';
import { EditTaskFilterDialogPage } from './dialog/edit-task-filter-dialog.page';
import { BrowserVisibility } from '../../core/utils/browser-visibility';
import { BrowserActions } from '../../core/utils/browser-actions';
@@ -79,6 +79,7 @@ export class EditTaskFilterCloudComponentPage {
const orderElement = element.all(by.cssContainingText('mat-option span', option)).first();
BrowserActions.click(orderElement);
browser.sleep(1000);
return this;
}