e2e tests for favourite directive (#4912)

* in progress - favourite directive e2e tests

* in progress - favourite directive e2e tests

* favourite directive e2e tests

* update testcase name

* updated test case names

* remove unnecessary line spaces

* refactored favourites to favorites
This commit is contained in:
Geeta Mandakini Ayyalasomayajula
2019-07-10 09:56:28 +01:00
committed by Eugenio Romano
parent bbe22fd2a7
commit fadcc19eba
7 changed files with 263 additions and 9 deletions

View File

@@ -121,7 +121,9 @@
matTooltip="{{ 'DOCUMENT_LIST.TOOLBAR.DELETE' | translate }}"> matTooltip="{{ 'DOCUMENT_LIST.TOOLBAR.DELETE' | translate }}">
<mat-icon>delete</mat-icon> <mat-icon>delete</mat-icon>
</button> </button>
<button mat-icon-button <button
data-automation-id="favorite"
mat-icon-button
[disabled]="!documentList.selection.length" [disabled]="!documentList.selection.length"
#favorite="adfFavorite" #favorite="adfFavorite"
[adf-node-favorite]="documentList.selection" [adf-node-favorite]="documentList.selection"

View File

@@ -50,19 +50,13 @@ describe('Edit folder directive', function () {
beforeAll(async (done) => { beforeAll(async (done) => {
await this.alfrescoJsApi.login(browser.params.testConfig.adf.adminEmail, browser.params.testConfig.adf.adminPassword); await this.alfrescoJsApi.login(browser.params.testConfig.adf.adminEmail, browser.params.testConfig.adf.adminPassword);
await this.alfrescoJsApi.core.peopleApi.addPerson(acsUser); await this.alfrescoJsApi.core.peopleApi.addPerson(acsUser);
await this.alfrescoJsApi.core.peopleApi.addPerson(anotherAcsUser); await this.alfrescoJsApi.core.peopleApi.addPerson(anotherAcsUser);
await this.alfrescoJsApi.login(acsUser.id, acsUser.password); await this.alfrescoJsApi.login(acsUser.id, acsUser.password);
editFolder = await uploadActions.createFolder(StringUtil.generateRandomString(5), '-my-'); editFolder = await uploadActions.createFolder(StringUtil.generateRandomString(5), '-my-');
anotherFolder = await uploadActions.createFolder(StringUtil.generateRandomString(5), '-my-'); anotherFolder = await uploadActions.createFolder(StringUtil.generateRandomString(5), '-my-');
subFolder = await uploadActions.createFolder(StringUtil.generateRandomString(5), editFolder.entry.id); subFolder = await uploadActions.createFolder(StringUtil.generateRandomString(5), editFolder.entry.id);
filePdfNode = await uploadActions.uploadFile(pdfFile.location, pdfFile.name, '-my-'); filePdfNode = await uploadActions.uploadFile(pdfFile.location, pdfFile.name, '-my-');
await this.alfrescoJsApi.core.nodesApi.updateNode(editFolder.entry.id, await this.alfrescoJsApi.core.nodesApi.updateNode(editFolder.entry.id,

View File

@@ -0,0 +1,220 @@
/*!
* @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 { ContentNodeSelectorDialogPage, LoginPage, StringUtil, UploadActions } from '@alfresco/adf-testing';
import { ContentServicesPage } from '../../pages/adf/contentServicesPage';
import { AcsUserModel } from '../../models/ACS/acsUserModel';
import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api';
import { browser } from 'protractor';
import { FileModel } from '../../models/ACS/fileModel';
import resources = require('../../util/resources');
import { NavigationBarPage } from '../../pages/adf/navigationBarPage';
import { CustomSources } from '../../pages/adf/demo-shell/customSourcesPage';
import { TrashcanPage } from '../../pages/adf/trashcanPage';
describe('Favorite directive', function () {
const loginPage = new LoginPage();
const contentServicesPage = new ContentServicesPage();
const navigationBarPage = new NavigationBarPage();
const acsUser = new AcsUserModel();
const customSourcesPage = new CustomSources();
const trashcanPage = new TrashcanPage();
const contentListPage = contentServicesPage.getDocumentList();
const contentNodeSelector = new ContentNodeSelectorDialogPage();
this.alfrescoJsApi = new AlfrescoApi({
provider: 'ECM',
hostEcm: browser.params.testConfig.adf.url
});
const pdfFile = new FileModel({
'name': resources.Files.ADF_DOCUMENTS.PDF.file_name,
'location': resources.Files.ADF_DOCUMENTS.PDF.file_location
});
const uploadActions = new UploadActions(this.alfrescoJsApi);
let testFolder1, testFolder2, testFolder3, testFolder4, testFile;
beforeAll(async (done) => {
await this.alfrescoJsApi.login(browser.params.testConfig.adf.adminEmail, browser.params.testConfig.adf.adminPassword);
await this.alfrescoJsApi.core.peopleApi.addPerson(acsUser);
await this.alfrescoJsApi.login(acsUser.id, acsUser.password);
testFolder1 = await uploadActions.createFolder(StringUtil.generateRandomString(5), '-my-');
testFolder2 = await uploadActions.createFolder(StringUtil.generateRandomString(5), '-my-');
testFolder3 = await uploadActions.createFolder(StringUtil.generateRandomString(5), '-my-');
testFolder4 = await uploadActions.createFolder(StringUtil.generateRandomString(5), '-my-');
testFile = await uploadActions.uploadFile(pdfFile.location, pdfFile.name, '-my-');
await loginPage.loginToContentServicesUsingUserModel(acsUser);
contentServicesPage.goToDocumentList();
done();
});
afterAll(async (done) => {
await this.alfrescoJsApi.login(browser.params.testConfig.adf.adminEmail, browser.params.testConfig.adf.adminPassword);
await uploadActions.deleteFileOrFolder(testFolder1.entry.id);
await uploadActions.deleteFileOrFolder(testFolder2.entry.id);
await uploadActions.deleteFileOrFolder(testFolder3.entry.id);
await uploadActions.deleteFileOrFolder(testFolder4.entry.id);
done();
});
beforeEach(async (done) => {
navigationBarPage.clickContentServicesButton();
contentServicesPage.getContentList().dataTablePage().waitTillContentLoaded();
done();
});
it('[C260247] Should be able to mark a file as favorite', async () => {
contentServicesPage.getContentList().dataTablePage().checkContentIsDisplayed('Display name', testFile.entry.name);
contentServicesPage.getContentList().dataTablePage().selectRow('Display name', testFile.entry.name);
contentServicesPage.getContentList().dataTablePage().checkRowIsSelected('Display name', testFile.entry.name);
contentServicesPage.clickOnFavoriteButton();
contentServicesPage.checkIsMarkedFavorite();
contentServicesPage.getContentList().dataTablePage().checkRowIsSelected('Display name', testFile.entry.name);
customSourcesPage.navigateToCustomSources();
customSourcesPage.selectFavoritesSourceType();
customSourcesPage.checkRowIsDisplayed(testFile.entry.name);
navigationBarPage.clickContentServicesButton();
contentServicesPage.getContentList().dataTablePage().waitTillContentLoaded();
contentServicesPage.getContentList().dataTablePage().checkContentIsDisplayed('Display name', testFile.entry.name);
contentServicesPage.getContentList().dataTablePage().selectRow('Display name', testFile.entry.name);
contentServicesPage.getContentList().dataTablePage().checkRowIsSelected('Display name', testFile.entry.name);
contentServicesPage.clickOnFavoriteButton();
contentServicesPage.checkIsNotMarkedFavorite();
customSourcesPage.navigateToCustomSources();
customSourcesPage.selectFavoritesSourceType();
customSourcesPage.checkRowIsNotDisplayed(testFile.entry.name);
});
it('[C260249] Should be able to mark a folder as favorite', async () => {
contentServicesPage.getContentList().dataTablePage().checkContentIsDisplayed('Display name', testFolder1.entry.name);
contentServicesPage.getContentList().dataTablePage().selectRow('Display name', testFolder1.entry.name);
contentServicesPage.getContentList().dataTablePage().checkRowIsSelected('Display name', testFolder1.entry.name);
contentServicesPage.clickOnFavoriteButton();
contentServicesPage.checkIsMarkedFavorite();
customSourcesPage.navigateToCustomSources();
customSourcesPage.selectFavoritesSourceType();
customSourcesPage.checkRowIsDisplayed(testFolder1.entry.name);
navigationBarPage.clickContentServicesButton();
contentServicesPage.getContentList().dataTablePage().waitTillContentLoaded();
contentServicesPage.getContentList().dataTablePage().checkContentIsDisplayed('Display name', testFolder1.entry.name);
contentServicesPage.getContentList().dataTablePage().selectRow('Display name', testFolder1.entry.name);
contentServicesPage.getContentList().dataTablePage().checkRowIsSelected('Display name', testFolder1.entry.name);
contentServicesPage.clickOnFavoriteButton();
contentServicesPage.checkIsNotMarkedFavorite();
customSourcesPage.navigateToCustomSources();
customSourcesPage.selectFavoritesSourceType();
customSourcesPage.checkRowIsNotDisplayed(testFolder1.entry.name);
});
it('[C260251] Should retain the restored file as favorite', async () => {
contentServicesPage.getContentList().dataTablePage().checkContentIsDisplayed('Display name', testFile.entry.name);
contentServicesPage.getContentList().dataTablePage().selectRow('Display name', testFile.entry.name);
contentServicesPage.getContentList().dataTablePage().checkRowIsSelected('Display name', testFile.entry.name);
contentServicesPage.clickOnFavoriteButton();
contentServicesPage.checkIsMarkedFavorite();
contentListPage.rightClickOnRow(testFile.entry.name);
contentServicesPage.pressContextMenuActionNamed('Delete');
contentServicesPage.checkContentIsNotDisplayed(testFile.entry.name);
customSourcesPage.navigateToCustomSources();
customSourcesPage.selectFavoritesSourceType();
customSourcesPage.checkRowIsNotDisplayed(testFile.entry.name);
navigationBarPage.clickTrashcanButton();
trashcanPage.waitForTableBody();
expect(trashcanPage.numberOfResultsDisplayed()).toBe(1);
trashcanPage.getDocumentList().dataTablePage().clickRowByContent(testFile.entry.name);
trashcanPage.getDocumentList().dataTablePage().checkRowByContentIsSelected(testFile.entry.name);
trashcanPage.clickRestore();
trashcanPage.checkTrashcanIsEmpty();
navigationBarPage.clickContentServicesButton();
contentServicesPage.getContentList().dataTablePage().waitTillContentLoaded();
contentServicesPage.getContentList().dataTablePage().checkContentIsDisplayed('Display name', testFile.entry.name);
contentServicesPage.getContentList().dataTablePage().selectRow('Display name', testFile.entry.name);
contentServicesPage.getContentList().dataTablePage().checkRowIsSelected('Display name', testFile.entry.name);
contentServicesPage.checkIsMarkedFavorite();
customSourcesPage.navigateToCustomSources();
customSourcesPage.selectFavoritesSourceType();
customSourcesPage.checkRowIsDisplayed(testFile.entry.name);
});
it('[C260252] Should retain the moved file as favorite', async () => {
contentServicesPage.getContentList().dataTablePage().checkContentIsDisplayed('Display name', testFile.entry.name);
contentServicesPage.getContentList().dataTablePage().selectRow('Display name', testFile.entry.name);
contentServicesPage.getContentList().dataTablePage().checkRowIsSelected('Display name', testFile.entry.name);
contentServicesPage.clickOnFavoriteButton();
contentServicesPage.checkIsMarkedFavorite();
contentServicesPage.getDocumentList().rightClickOnRow(testFile.entry.name);
contentServicesPage.pressContextMenuActionNamed('Move');
contentNodeSelector.checkDialogIsDisplayed();
contentNodeSelector.typeIntoNodeSelectorSearchField(testFolder1.entry.name);
contentNodeSelector.clickContentNodeSelectorResult(testFolder1.entry.name);
contentNodeSelector.clickMoveCopyButton();
contentServicesPage.checkContentIsNotDisplayed(testFile.entry.name);
contentServicesPage.doubleClickRow(testFolder1.entry.name);
contentServicesPage.checkContentIsDisplayed(testFile.entry.name);
contentServicesPage.getContentList().dataTablePage().selectRow('Display name', testFile.entry.name);
contentServicesPage.getContentList().dataTablePage().checkRowIsSelected('Display name', testFile.entry.name);
contentServicesPage.checkIsMarkedFavorite();
});
it('[C217216] Should be able to mark and unmark multiple folders as favorite', async () => {
contentServicesPage.clickMultiSelectToggle();
contentServicesPage.getContentList().dataTablePage().waitTillContentLoaded();
contentServicesPage.getContentList().dataTablePage().clickCheckbox('Display name', testFolder1.entry.name);
contentServicesPage.getContentList().dataTablePage().clickCheckbox('Display name', testFolder2.entry.name);
contentServicesPage.getContentList().dataTablePage().clickCheckbox('Display name', testFolder3.entry.name);
contentServicesPage.getContentList().dataTablePage().checkRowIsSelected('Display name', testFolder1.entry.name);
contentServicesPage.getContentList().dataTablePage().checkRowIsSelected('Display name', testFolder2.entry.name);
contentServicesPage.getContentList().dataTablePage().checkRowIsSelected('Display name', testFolder3.entry.name);
expect(contentServicesPage.getContentList().dataTablePage().getNumberOfSelectedRows()).toBe(3);
contentServicesPage.clickOnFavoriteButton();
contentServicesPage.checkIsMarkedFavorite();
contentServicesPage.getContentList().dataTablePage().clickCheckbox('Display name', testFolder3.entry.name);
contentServicesPage.getContentList().dataTablePage().checkRowIsNotSelected('Display name', testFolder3.entry.name);
expect(contentServicesPage.getContentList().dataTablePage().getNumberOfSelectedRows()).toBe(2);
contentServicesPage.getContentList().dataTablePage().clickCheckbox('Display name', testFolder4.entry.name);
expect(contentServicesPage.getContentList().dataTablePage().getNumberOfSelectedRows()).toBe(3);
contentServicesPage.getContentList().dataTablePage().checkRowIsSelected('Display name', testFolder1.entry.name);
contentServicesPage.getContentList().dataTablePage().checkRowIsSelected('Display name', testFolder2.entry.name);
contentServicesPage.getContentList().dataTablePage().checkRowIsSelected('Display name', testFolder4.entry.name);
contentServicesPage.clickOnFavoriteButton();
contentServicesPage.checkIsMarkedFavorite();
contentServicesPage.clickOnFavoriteButton();
contentServicesPage.checkIsNotMarkedFavorite();
contentServicesPage.getContentList().dataTablePage().checkAllRows();
expect(contentServicesPage.getContentList().dataTablePage().getNumberOfSelectedRows()).toBeGreaterThanOrEqual(4);
contentServicesPage.getContentList().dataTablePage().uncheckAllRows();
expect(contentServicesPage.getContentList().dataTablePage().getNumberOfSelectedRows()).toBe(0);
contentServicesPage.getContentList().dataTablePage().clickCheckbox('Display name', testFolder3.entry.name);
contentServicesPage.getContentList().dataTablePage().checkRowIsSelected('Display name', testFolder3.entry.name);
expect(contentServicesPage.getContentList().dataTablePage().getNumberOfSelectedRows()).toBe(1);
contentServicesPage.checkIsMarkedFavorite();
});
});

View File

@@ -83,6 +83,9 @@ export class ContentServicesPage {
downloadContent = element(by.css('button[data-automation-id*="DOWNLOAD"]')); downloadContent = element(by.css('button[data-automation-id*="DOWNLOAD"]'));
siteListDropdown = element(by.css(`mat-select[data-automation-id='site-my-files-option']`)); siteListDropdown = element(by.css(`mat-select[data-automation-id='site-my-files-option']`));
downloadButton = element(by.css('button[title="Download"]')); downloadButton = element(by.css('button[title="Download"]'));
favoriteButton = element(by.css('button[data-automation-id="favorite"]'));
markedFavorite = element(by.cssContainingText( 'button[data-automation-id="favorite"] mat-icon', 'star'));
notMarkedFavorite = element(by.cssContainingText( 'button[data-automation-id="favorite"] mat-icon', 'star_border'));
multiSelectToggle = element(by.cssContainingText('span.mat-slide-toggle-content', ' Multiselect (with checkboxes) ')); multiSelectToggle = element(by.cssContainingText('span.mat-slide-toggle-content', ' Multiselect (with checkboxes) '));
pressContextMenuActionNamed(actionName) { pressContextMenuActionNamed(actionName) {
@@ -360,6 +363,21 @@ export class ContentServicesPage {
return this; return this;
} }
clickOnFavoriteButton() {
BrowserActions.click(this.favoriteButton);
return this;
}
checkIsMarkedFavorite() {
BrowserVisibility.waitUntilElementIsVisible(this.markedFavorite);
return this;
}
checkIsNotMarkedFavorite() {
BrowserVisibility.waitUntilElementIsVisible(this.notMarkedFavorite);
return this;
}
clickOnEditFolder() { clickOnEditFolder() {
BrowserActions.click(this.editFolderButton); BrowserActions.click(this.editFolderButton);
return this; return this;

View File

@@ -67,10 +67,19 @@ export class CustomSources {
BrowserActions.click(this.getSourceType(source.mySites)); BrowserActions.click(this.getSourceType(source.mySites));
} }
selectFavoritesSourceType() {
this.clickOnSourceType();
BrowserActions.click(this.getSourceType(source.favorites));
}
checkRowIsDisplayed(rowName) { checkRowIsDisplayed(rowName) {
return this.dataTable.checkContentIsDisplayed('Name', rowName); return this.dataTable.checkContentIsDisplayed('Name', rowName);
} }
checkRowIsNotDisplayed(rowName) {
return this.dataTable.checkContentIsNotDisplayed('Name', rowName);
}
getStatusCell(rowName) { getStatusCell(rowName) {
const cell = this.dataTable.getCellByRowContentAndColumn('Name', rowName, column.status); const cell = this.dataTable.getCellByRowContentAndColumn('Name', rowName, column.status);
return BrowserActions.getText(cell); return BrowserActions.getText(cell);

View File

@@ -15,16 +15,18 @@
* limitations under the License. * limitations under the License.
*/ */
import { BrowserVisibility } from '@alfresco/adf-testing'; import { BrowserActions, BrowserVisibility, DocumentListPage } from '@alfresco/adf-testing';
import { element, by } from 'protractor'; import { element, by } from 'protractor';
export class TrashcanPage { export class TrashcanPage {
contentList = new DocumentListPage(element(by.css('adf-document-list')));
rows = by.css('adf-document-list div[class*="adf-datatable-body"] div[class*="adf-datatable-row"]'); rows = by.css('adf-document-list div[class*="adf-datatable-body"] div[class*="adf-datatable-row"]');
tableBody = element.all(by.css('adf-document-list div[class="adf-datatable-body"]')).first(); tableBody = element.all(by.css('adf-document-list div[class="adf-datatable-body"]')).first();
pagination = element(by.css('adf-pagination')); pagination = element(by.css('adf-pagination'));
emptyTrashcan = element(by.css('adf-empty-content')); emptyTrashcan = element(by.css('adf-empty-content'));
restoreButton = element(by.css(`button[title='Restore']`));
numberOfResultsDisplayed() { numberOfResultsDisplayed() {
return element.all(this.rows).count(); return element.all(this.rows).count();
@@ -42,4 +44,13 @@ export class TrashcanPage {
BrowserVisibility.waitUntilElementIsVisible(this.emptyTrashcan); BrowserVisibility.waitUntilElementIsVisible(this.emptyTrashcan);
} }
getDocumentList() {
return this.contentList;
}
clickRestore() {
BrowserActions.click(this.restoreButton);
return this;
}
} }

View File

@@ -319,7 +319,7 @@ export class DataTableComponentPage {
} }
getCellByContent(content) { getCellByContent(content) {
const cell = this.rootElement.element(by.cssContainingText(`div[class*='adf-datatable-row'] div[class*='adf-name-location-cell-name']`, content)); const cell = this.rootElement.element(by.cssContainingText(`div[class*='adf-datatable-row'] div[class*='adf-datatable-cell']`, content));
BrowserVisibility.waitUntilElementIsVisible(cell); BrowserVisibility.waitUntilElementIsVisible(cell);
return cell; return cell;
} }