[ADF-3706] Creation of Check List filter automated tests (#3958)

* [ADF-3706] Creation of Check List filter automated tests

* Fixing the tests

* Refactoring the search files/ removing json

* Adding whitespaces and changing double quotes
This commit is contained in:
jdosti
2018-11-21 16:49:34 +00:00
committed by Eugenio Romano
parent b6b31373a0
commit 49c69c58f0
3 changed files with 424 additions and 1 deletions

View File

@@ -0,0 +1,367 @@
/*!
* @license
* Copyright 2016 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 { LoginPage } from '../../../pages/adf/loginPage';
import { SearchFiltersPage } from '../../../pages/adf/searchFiltersPage';
import ContentList = require('../../../pages/adf/dialog/contentList');
import { ConfigEditorPage } from '../../../pages/adf/configEditorPage';
import { NavigationBarPage } from '../../../pages/adf/navigationBarPage';
import SearchDialog = require('../../../pages/adf/dialog/searchDialog');
import AcsUserModel = require('../../../models/ACS/acsUserModel');
import TestConfig = require('../../../test.config');
import { SearchConfiguration } from '../search.config';
import AlfrescoApi = require('alfresco-js-api-node');
import { UploadActions } from '../../../actions/ACS/upload.actions';
import { browser } from 'protractor';
describe('Search Radio Component', () => {
const loginPage = new LoginPage();
const searchFiltersPage = new SearchFiltersPage();
const contentList = new ContentList();
const configEditorPage = new ConfigEditorPage();
const navigationBarPage = new NavigationBarPage();
const searchDialog = new SearchDialog();
let acsUser = new AcsUserModel();
let uploadActions = new UploadActions();
let filterType = {
folder: 'Folder',
document: 'Document',
custom: 'TEST_NAME'
};
let nodeNames = {
document: 'this_is_a_unique_name.txt',
folder: 'this_is_a_unique_name'
};
let createdFile, createdFolder;
beforeAll(async (done) => {
this.alfrescoJsApi = new AlfrescoApi({
provider: 'ECM',
hostEcm: TestConfig.adf.url
});
await this.alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword);
await this.alfrescoJsApi.core.peopleApi.addPerson(acsUser);
await this.alfrescoJsApi.login(acsUser.id, acsUser.password);
createdFolder = await this.alfrescoJsApi.nodes.addNode('-my-', {name: nodeNames.folder, nodeType: 'cm:folder'});
createdFile = await this.alfrescoJsApi.nodes.addNode('-my-', {name: nodeNames.document, nodeType: 'cm:content'});
await browser.driver.sleep(15000);
loginPage.loginToContentServicesUsingUserModel(acsUser);
browser.get(TestConfig.adf.url + '/search;q=' + nodeNames.folder + '');
done();
});
afterAll(async (done) => {
await this.alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword);
await uploadActions.deleteFilesOrFolder(this.alfrescoJsApi, createdFile.entry.id);
await uploadActions.deleteFilesOrFolder(this.alfrescoJsApi, createdFolder.entry.id);
done();
});
it('[C276991] Should be able to click between options and Clear All button', () => {
searchFiltersPage.checkCheckListFilterIsDisplayed();
searchFiltersPage.checkCheckListFilterIsCollapsed();
searchFiltersPage.clickCheckListFilter();
searchFiltersPage.checkListFiltersPage().checkCheckListOptionIsDisplayed(filterType.folder);
searchFiltersPage.checkListFiltersPage().checkCheckListOptionIsDisplayed(filterType.document);
searchFiltersPage.checkListFiltersPage().checkClearAllButtonIsDisplayed();
searchFiltersPage.checkListFiltersPage().checkCheckListOptionIsNotSelected(filterType.folder);
searchFiltersPage.checkListFiltersPage().checkCheckListOptionIsNotSelected(filterType.document);
searchFiltersPage.checkListFiltersPage().clickCheckListOption(filterType.folder);
searchFiltersPage.checkListFiltersPage().checkCheckListOptionIsSelected(filterType.folder);
contentList.checkContentIsDisplayed(nodeNames.folder);
contentList.checkContentIsNotDisplayed(nodeNames.document);
searchFiltersPage.checkListFiltersPage().clickClearAllButton();
searchFiltersPage.checkListFiltersPage().checkCheckListOptionIsNotSelected(filterType.folder);
contentList.checkContentIsDisplayed(nodeNames.folder);
contentList.checkContentIsDisplayed(nodeNames.document);
searchFiltersPage.checkListFiltersPage().clickCheckListOption(filterType.folder);
searchFiltersPage.checkListFiltersPage().clickCheckListOption(filterType.document);
searchFiltersPage.checkListFiltersPage().checkCheckListOptionIsSelected(filterType.folder);
searchFiltersPage.checkListFiltersPage().checkCheckListOptionIsSelected(filterType.document);
contentList.checkContentIsDisplayed(nodeNames.folder);
contentList.checkContentIsDisplayed(nodeNames.document);
searchFiltersPage.checkListFiltersPage().clickCheckListOption(filterType.folder);
searchFiltersPage.checkListFiltersPage().checkCheckListOptionIsSelected(filterType.document);
searchFiltersPage.checkListFiltersPage().checkCheckListOptionIsNotSelected(filterType.folder);
contentList.checkContentIsDisplayed(nodeNames.document);
contentList.checkContentIsNotDisplayed(nodeNames.folder);
});
describe('configuration change', () => {
let jsonFile;
beforeEach(() => {
let searchConfiguration = new SearchConfiguration();
jsonFile = searchConfiguration.getConfiguration();
});
it('[C277143] Should be able to click show more/less button with pageSize set as default', () => {
navigationBarPage.clickConfigEditorButton();
for (let numberOfOptions = 0; numberOfOptions < 8; numberOfOptions++) {
jsonFile.categories[1].component.settings.options.push({ 'name': 'Folder', 'value': "TYPE:'cm:folder'" });
}
configEditorPage.clickSearchConfiguration();
configEditorPage.clickClearButton();
configEditorPage.enterBigConfigurationText(JSON.stringify(jsonFile));
configEditorPage.clickSaveButton();
searchDialog.clickOnSearchIcon().checkSearchBarIsVisible().enterTextAndPressEnter(nodeNames.folder);
searchFiltersPage.clickCheckListFilter();
expect(searchFiltersPage.checkListFiltersPage().getCheckListOptionsNumberOnPage()).toBe(5);
searchFiltersPage.checkListFiltersPage().checkShowMoreButtonIsDisplayed();
searchFiltersPage.checkListFiltersPage().checkShowLessButtonIsNotDisplayed();
searchFiltersPage.checkListFiltersPage().clickShowMoreButton();
expect(searchFiltersPage.checkListFiltersPage().getCheckListOptionsNumberOnPage()).toBe(10);
searchFiltersPage.checkListFiltersPage().checkShowMoreButtonIsNotDisplayed();
searchFiltersPage.checkListFiltersPage().checkShowLessButtonIsDisplayed();
searchFiltersPage.checkListFiltersPage().clickShowLessButton();
expect(searchFiltersPage.checkListFiltersPage().getCheckListOptionsNumberOnPage()).toBe(5);
searchFiltersPage.checkListFiltersPage().checkShowMoreButtonIsDisplayed();
searchFiltersPage.checkListFiltersPage().checkShowLessButtonIsNotDisplayed();
browser.refresh();
});
it('[C277144] Should be able to click show more/less button with pageSize set with a custom value', () => {
navigationBarPage.clickConfigEditorButton();
jsonFile.categories[1].component.settings.pageSize = 10;
for (let numberOfOptions = 0; numberOfOptions < 8; numberOfOptions++) {
jsonFile.categories[1].component.settings.options.push({ 'name': 'Folder', 'value': "TYPE:'cm:folder'" });
}
configEditorPage.clickSearchConfiguration();
configEditorPage.clickClearButton();
configEditorPage.enterBigConfigurationText(JSON.stringify(jsonFile));
configEditorPage.clickSaveButton();
searchDialog.clickOnSearchIcon().checkSearchBarIsVisible().enterTextAndPressEnter(nodeNames.folder);
searchFiltersPage.clickCheckListFilter();
expect(searchFiltersPage.checkListFiltersPage().getCheckListOptionsNumberOnPage()).toBe(10);
searchFiltersPage.checkListFiltersPage().checkShowMoreButtonIsNotDisplayed();
browser.refresh();
navigationBarPage.clickConfigEditorButton();
jsonFile.categories[1].component.settings.pageSize = 11;
configEditorPage.clickSearchConfiguration();
configEditorPage.clickClearButton();
configEditorPage.enterBigConfigurationText(JSON.stringify(jsonFile));
configEditorPage.clickSaveButton();
searchDialog.clickOnSearchIcon().checkSearchBarIsVisible().enterTextAndPressEnter(nodeNames.folder);
searchFiltersPage.clickCheckListFilter();
expect(searchFiltersPage.checkListFiltersPage().getCheckListOptionsNumberOnPage()).toBe(10);
searchFiltersPage.checkListFiltersPage().checkShowMoreButtonIsNotDisplayed();
browser.refresh();
navigationBarPage.clickConfigEditorButton();
jsonFile.categories[1].component.settings.pageSize = 9;
configEditorPage.clickSearchConfiguration();
configEditorPage.clickClearButton();
configEditorPage.enterBigConfigurationText(JSON.stringify(jsonFile));
configEditorPage.clickSaveButton();
searchDialog.clickOnSearchIcon().checkSearchBarIsVisible().enterTextAndPressEnter(nodeNames.folder);
searchFiltersPage.clickCheckListFilter();
expect(searchFiltersPage.checkListFiltersPage().getCheckListOptionsNumberOnPage()).toBe(9);
searchFiltersPage.checkListFiltersPage().checkShowMoreButtonIsDisplayed();
browser.refresh();
});
it('[C277145] Should be able to click show more/less button with pageSize set to zero', () => {
navigationBarPage.clickConfigEditorButton();
jsonFile.categories[1].component.settings.pageSize = 0;
for (let numberOfOptions = 0; numberOfOptions < 8; numberOfOptions++) {
jsonFile.categories[1].component.settings.options.push({ 'name': 'Folder', 'value': "TYPE:'cm:folder'" });
}
configEditorPage.clickSearchConfiguration();
configEditorPage.clickClearButton();
configEditorPage.enterBigConfigurationText(JSON.stringify(jsonFile));
configEditorPage.clickSaveButton();
searchDialog.clickOnSearchIcon().checkSearchBarIsVisible().enterTextAndPressEnter(nodeNames.folder);
searchFiltersPage.clickCheckListFilter();
expect(searchFiltersPage.checkListFiltersPage().getCheckListOptionsNumberOnPage()).toBe(5);
searchFiltersPage.checkListFiltersPage().checkShowMoreButtonIsDisplayed();
searchFiltersPage.checkListFiltersPage().checkShowLessButtonIsNotDisplayed();
searchFiltersPage.checkListFiltersPage().clickShowMoreButton();
expect(searchFiltersPage.checkListFiltersPage().getCheckListOptionsNumberOnPage()).toBe(10);
searchFiltersPage.checkListFiltersPage().checkShowMoreButtonIsNotDisplayed();
searchFiltersPage.checkListFiltersPage().checkShowLessButtonIsDisplayed();
browser.refresh();
navigationBarPage.clickConfigEditorButton();
delete jsonFile.categories[1].component.settings.pageSize;
configEditorPage.clickSearchConfiguration();
configEditorPage.clickClearButton();
configEditorPage.enterBigConfigurationText(JSON.stringify(jsonFile));
configEditorPage.clickSaveButton();
searchDialog.clickOnSearchIcon().checkSearchBarIsVisible().enterTextAndPressEnter(nodeNames.folder);
searchFiltersPage.clickCheckListFilter();
expect(searchFiltersPage.checkListFiltersPage().getCheckListOptionsNumberOnPage()).toBe(5);
searchFiltersPage.checkListFiltersPage().checkShowMoreButtonIsDisplayed();
searchFiltersPage.checkListFiltersPage().checkShowLessButtonIsNotDisplayed();
searchFiltersPage.checkListFiltersPage().clickShowMoreButton();
expect(searchFiltersPage.checkListFiltersPage().getCheckListOptionsNumberOnPage()).toBe(10);
searchFiltersPage.checkListFiltersPage().checkShowMoreButtonIsNotDisplayed();
searchFiltersPage.checkListFiltersPage().checkShowLessButtonIsDisplayed();
});
});
describe('Properties', () => {
let jsonFile;
beforeEach(() => {
let searchConfiguration = new SearchConfiguration();
jsonFile = searchConfiguration.getConfiguration();
});
beforeAll(async (done) => {
loginPage.loginToContentServicesUsingUserModel(acsUser);
done();
});
it('[C277018] Should be able to change the operator', () => {
navigationBarPage.clickConfigEditorButton();
jsonFile.categories[1].component.settings.operator = 'AND';
configEditorPage.clickSearchConfiguration();
configEditorPage.clickClearButton();
configEditorPage.enterBigConfigurationText(JSON.stringify(jsonFile));
configEditorPage.clickSaveButton();
searchDialog.clickOnSearchIcon().checkSearchBarIsVisible().enterTextAndPressEnter(nodeNames.folder);
searchFiltersPage.clickCheckListFilter();
searchFiltersPage.checkListFiltersPage().clickCheckListOption(filterType.folder);
searchFiltersPage.checkListFiltersPage().checkCheckListOptionIsSelected(filterType.folder);
contentList.checkContentIsDisplayed(nodeNames.folder);
contentList.checkContentIsNotDisplayed(nodeNames.document);
searchFiltersPage.checkListFiltersPage().clickCheckListOption(filterType.document);
contentList.checkContentIsNotDisplayed(nodeNames.folder);
contentList.checkContentIsNotDisplayed(nodeNames.document);
browser.refresh();
});
it('[C277019] Should be able to add new properties with different types', () => {
navigationBarPage.clickConfigEditorButton();
jsonFile.categories[1].component.settings.options.push({ 'name': filterType.custom, 'value': "TYPE:'cm:auditable'" });
configEditorPage.clickSearchConfiguration();
configEditorPage.clickClearButton();
configEditorPage.enterBigConfigurationText(JSON.stringify(jsonFile));
configEditorPage.clickSaveButton();
searchDialog.clickOnSearchIcon().checkSearchBarIsVisible().enterTextAndPressEnter(nodeNames.folder);
searchFiltersPage.clickCheckListFilter();
searchFiltersPage.checkListFiltersPage().checkCheckListOptionIsDisplayed(filterType.folder);
searchFiltersPage.checkListFiltersPage().checkCheckListOptionIsDisplayed(filterType.document);
searchFiltersPage.checkListFiltersPage().checkCheckListOptionIsDisplayed(filterType.custom);
searchFiltersPage.checkListFiltersPage().clickCheckListOption(filterType.custom);
contentList.checkContentIsNotDisplayed(nodeNames.folder);
contentList.checkContentIsNotDisplayed(nodeNames.document);
searchFiltersPage.checkListFiltersPage().clickCheckListOption(filterType.document);
searchFiltersPage.checkListFiltersPage().clickCheckListOption(filterType.folder);
contentList.checkContentIsDisplayed(nodeNames.folder);
contentList.checkContentIsDisplayed(nodeNames.document);
});
});
});

View File

@@ -24,6 +24,7 @@ export class SearchCheckListPage {
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) {
this.filter = filter;
@@ -89,6 +90,11 @@ export class SearchCheckListPage {
return this;
}
checkShowMoreButtonIsNotDisplayed() {
Util.waitUntilElementIsNotVisible(this.filter.element(this.showMoreBy));
return this;
}
clickShowMoreButtonUntilIsNotDisplayed() {
this.filter.element(this.showMoreBy).isDisplayed().then(async (visible) => {
if (visible) {
@@ -125,4 +131,51 @@ export class SearchCheckListPage {
return bucketNumber;
}
checkCheckListOptionIsDisplayed(option) {
Util.waitUntilElementIsVisible(this.filter);
let result = this.filter.element(by.css(`mat-checkbox[data-automation-id*='-${option}']`));
return Util.waitUntilElementIsVisible(result);
}
checkCheckListOptionIsNotSelected(option) {
Util.waitUntilElementIsVisible(this.filter);
let result = this.filter.element(by.css(`mat-checkbox[data-automation-id*='-${option}'][class*='checked']`));
return Util.waitUntilElementIsNotVisible(result);
}
checkCheckListOptionIsSelected(option) {
Util.waitUntilElementIsVisible(this.filter);
let result = this.filter.element(by.css(`mat-checkbox[data-automation-id*='-${option}'][class*='checked']`));
return Util.waitUntilElementIsVisible(result);
}
checkClearAllButtonIsDisplayed() {
Util.waitUntilElementIsVisible(this.filter);
let result = this.filter.element(this.clearAllButton);
return Util.waitUntilElementIsVisible(result);
}
clickClearAllButton() {
Util.waitUntilElementIsVisible(this.filter);
let result = this.filter.element(this.clearAllButton);
Util.waitUntilElementIsVisible(result);
return result.click();
}
getCheckListOptionsNumberOnPage() {
Util.waitUntilElementIsVisible(this.filter);
let checkListOptions = this.filter.all(by.css('div[class="checklist"] mat-checkbox'));
return checkListOptions.count();
}
clickShowMoreButton() {
Util.waitUntilElementIsVisible(this.filter.element(this.showMoreBy));
return this.filter.element(this.showMoreBy).click();
}
clickShowLessButton() {
Util.waitUntilElementIsVisible(this.filter.element(this.showLessBy));
return this.filter.element(this.showLessBy).click();
}
}

View File

@@ -31,7 +31,6 @@ export class SearchFiltersPage {
checkListFilter = element(by.css('mat-expansion-panel[data-automation-id="expansion-panel-Check List"]'));
createdDateRangeFilter = element(by.css('mat-expansion-panel[data-automation-id="expansion-panel-Created Date (range)"]'));
typeFilter = element(by.css('mat-expansion-panel[data-automation-id="expansion-panel-Type"]'));
createdDateRangeFilter = element(by.css('mat-expansion-panel[data-automation-id="expansion-panel-Created Date (range)"]'));
checkSearchFiltersIsDisplayed() {
Util.waitUntilElementIsVisible(this.searchFilters);
@@ -107,6 +106,10 @@ export class SearchFiltersPage {
return this;
}
checkCheckListFilterIsCollapsed() {
this.searchCategoriesPage.checkFilterIsCollapsed(this.checkListFilter);
}
checkCreatedRangeFilterIsDisplayed() {
this.searchCategoriesPage.checkFilterIsDisplayed(this.createdDateRangeFilter);
return this;