[ADF-3557] Automated test for removing search filter using chip remove button (#3790)

This commit is contained in:
Marouan Bentaleb
2018-09-14 12:50:40 +01:00
committed by Eugenio Romano
parent 8fee6e217a
commit 9f00c923e9
3 changed files with 104 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
/*!
* @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 = require('../pages/adf/loginPage');
import SearchDialog = require('../pages/adf/dialog/searchDialog');
import SearchFiltersPage = require('../pages/adf/searchFiltersPage');
import AcsUserModel = require('../models/ACS/acsUserModel');
import FileModel = require('../models/ACS/fileModel');
import TestConfig = require('../test.config');
import Util = require('../util/util');
import AlfrescoApi = require('alfresco-js-api-node');
import { UploadActions } from '../actions/ACS/upload.actions';
import { browser } from 'protractor';
describe('Search Filters', () => {
let loginPage = new LoginPage();
let searchDialog = new SearchDialog();
let searchFiltersPage = new SearchFiltersPage();
let uploadActions = new UploadActions();
let acsUser = new AcsUserModel();
let filename = Util.generateRandomString(16);
let fileModel = new FileModel({
'name': filename, 'shortName': filename.substring(0, 8)
});
let fileUploaded;
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);
fileUploaded = await uploadActions.uploadFile(this.alfrescoJsApi, fileModel.location, fileModel.name, '-my-');
loginPage.loginToContentServicesUsingUserModel(acsUser);
await browser.driver.sleep(15000); // wait search index previous file/folder uploaded
searchDialog.checkSearchIconIsVisible();
searchDialog.clickOnSearchIcon();
searchDialog.enterTextAndPressEnter(fileUploaded.entry.name);
searchFiltersPage.checkSearchFiltersIsDisplayed();
done();
});
afterAll(async (done) => {
await this.alfrescoJsApi.login(acsUser.id, acsUser.password);
await uploadActions.deleteFilesOrFolder(this.alfrescoJsApi, fileUploaded.entry.id);
done();
});
it('[C286298] Should be able to cancel a filter using "x" button from the toolbar', () => {
searchFiltersPage.filterByCreator(acsUser.firstName, acsUser.lastName);
searchFiltersPage.checkCreatorChipIsDisplayed(acsUser.firstName, acsUser.lastName);
searchFiltersPage.removeCreatorFilter(acsUser.firstName, acsUser.lastName);
searchFiltersPage.checkCreatorChipIsNotDisplayed(acsUser.firstName, acsUser.lastName);
});
});

View File

@@ -94,5 +94,19 @@ var SearchFiltersPage = function () {
this.searchInCreatorFilter(`${creatorFirstName} ${creatorLastName}`); this.searchInCreatorFilter(`${creatorFirstName} ${creatorLastName}`);
this.selectCreator(`${creatorFirstName} ${creatorLastName}`); this.selectCreator(`${creatorFirstName} ${creatorLastName}`);
}; };
this.removeCreatorFilter = function (creatorFirstName, creatorLastName) {
let cancelChipButton = element(by.cssContainingText('mat-chip',` ${creatorFirstName} ${creatorLastName} `)).element(by.css('mat-icon'));
Util.waitUntilElementIsClickable(cancelChipButton);
return cancelChipButton.click();
};
this.checkCreatorChipIsDisplayed = function (creatorFirstName, creatorLastName) {
return Util.waitUntilElementIsVisible(element(by.cssContainingText('mat-chip',` ${creatorFirstName} ${creatorLastName} `)).element(by.css('mat-icon')));
};
this.checkCreatorChipIsNotDisplayed = function (creatorFirstName, creatorLastName) {
return Util.waitUntilElementIsNotOnPage(element(by.cssContainingText('mat-chip',` ${creatorFirstName} ${creatorLastName} `)).element(by.css('mat-icon')));
};
}; };
module.exports = SearchFiltersPage; module.exports = SearchFiltersPage;

Binary file not shown.