[ACA-1897] context submenu extension e2e (#745)

* [ACA-1897] e2e for context submenu - needs some fixes

* fix

* [ACA-1897] test refactoring

* [ACA-1897] specify TestRail ids

* [ACA-1897] fix spell check issue

* [ACA-1897] custom message on share dialog fail to close -  e2e tests
This commit is contained in:
Suzana Dirla 2018-10-23 14:46:13 +03:00 committed by Adina Parpalita
parent 6e3f128121
commit 03e8ab4b1e
7 changed files with 1403 additions and 4 deletions

View File

@ -52,7 +52,9 @@
"cardview",
"webm",
"keycodes",
"denysvuika"
"denysvuika",
"submenu",
"submenus"
],
"dictionaries": ["html", "en-gb", "en_US"]
}

View File

@ -63,7 +63,7 @@ export class ShareDialog extends Component {
}
async waitForDialogToClose() {
await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT);
await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT, 'share dialog did not close');
}
async waitForDialogToOpen() {

View File

@ -33,12 +33,15 @@ export class Menu extends Component {
root: '.mat-menu-panel',
item: '.mat-menu-item',
icon: '.mat-icon',
uploadFiles: 'app-upload-files'
uploadFiles: 'app-upload-files',
submenu: 'app-context-menu-item .mat-menu-item'
};
items: ElementArrayFinder = this.component.all(by.css(Menu.selectors.item));
backdrop: ElementFinder = browser.element(by.css('.cdk-overlay-backdrop'));
uploadFiles: ElementFinder = browser.element(by.id(Menu.selectors.uploadFiles));
submenus: ElementArrayFinder = browser.element.all(by.css(Menu.selectors.submenu));
constructor(ancestor?: ElementFinder) {
super(Menu.selectors.root, ancestor);
@ -71,6 +74,10 @@ export class Menu extends Component {
return this.component.element(by.cssContainingText(Menu.selectors.item, menuItem));
}
getSubItemByLabel(subMenuItem: string) {
return this.component.element(by.cssContainingText(Menu.selectors.submenu, subMenuItem));
}
getItemById(id: string) {
return this.component.element(by.id(id));
}
@ -108,10 +115,50 @@ export class Menu extends Component {
}
}
async mouseOverMenuItem(menuItem: string) {
try {
const elem = this.getItemByLabel(menuItem);
await browser.wait(EC.elementToBeClickable(elem), BROWSER_WAIT_TIMEOUT);
await browser.actions().mouseMove(elem).perform();
await browser.sleep(500);
} catch (error) {
console.log('----- mouse over error: ', error);
}
}
async hasSubMenu(menuItem: string) {
try {
const elem = this.getItemByLabel(menuItem);
await browser.wait(EC.elementToBeClickable(elem), BROWSER_WAIT_TIMEOUT);
const elemClass = await elem.getAttribute('class');
return elemClass.includes('mat-menu-item-submenu-trigger');
} catch (error) {
console.log('---- has submenu error: ', error);
}
}
async clickSubMenuItem(subMenuItem: string) {
try {
const elem = this.getSubItemByLabel(subMenuItem);
await browser.wait(EC.elementToBeClickable(elem), BROWSER_WAIT_TIMEOUT);
await elem.click();
} catch (e) {
console.log('___click submenu item catch___', e);
}
}
async isMenuItemPresent(title: string) {
return await this.component.element(by.cssContainingText(Menu.selectors.item, title)).isPresent();
}
async isSubMenuItemPresent(title: string) {
return await browser.element(by.cssContainingText(Menu.selectors.submenu, title)).isPresent();
}
async getSubmenuItemsCount() {
return await this.submenus.count();
}
async isMenuItemDisabled(title: string) {
try {
const item = this.getItemByLabel(title);

View File

@ -99,5 +99,6 @@ export const EXTENSIBILITY_CONFIGS = {
VIEWER: 'viewer-ext.json',
HEADER: 'header-ext.json',
METADATA_PRESETS: 'metadata-ext.json',
DOCUMENT_LIST_PRESETS: 'document-presets-ext.json'
DOCUMENT_LIST_PRESETS: 'document-presets-ext.json',
CONTEXT_SUBMENUS: 'context-submenus-ext.json'
};

File diff suppressed because it is too large Load Diff

View File

@ -135,6 +135,7 @@ describe('Unshare a file', () => {
await confirmDialog.clickButton('Remove');
await confirmDialog.waitForDialogToClose();
await shareDialog.waitForDialogToClose();
expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open');
expect(await apis.user.nodes.isFileShared(file2Id)).toBe(false, `${file2} is shared`);
@ -176,6 +177,7 @@ describe('Unshare a file', () => {
await confirmDialog.clickButton('Remove');
await confirmDialog.waitForDialogToClose();
await shareDialog.waitForDialogToClose();
expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open');
expect(await apis.user.nodes.isFileShared(file4Id)).toBe(false, `${file4} is shared`);
@ -266,6 +268,7 @@ describe('Unshare a file', () => {
await confirmDialog.clickButton('Remove');
await confirmDialog.waitForDialogToClose();
await shareDialog.waitForDialogToClose();
expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open');
expect(await apis.user.nodes.isFileShared(file2Id)).toBe(false, `${file2} is shared`);
@ -307,6 +310,7 @@ describe('Unshare a file', () => {
await confirmDialog.clickButton('Remove');
await confirmDialog.waitForDialogToClose();
await shareDialog.waitForDialogToClose();
expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open');
expect(await apis.user.nodes.isFileShared(file4Id)).toBe(false, `${file4} is shared`);
@ -389,6 +393,7 @@ describe('Unshare a file', () => {
await confirmDialog.clickButton('Remove');
await confirmDialog.waitForDialogToClose();
await shareDialog.waitForDialogToClose();
expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open');
expect(await apis.user.nodes.isFileShared(file2Id)).toBe(false, `${file2} is shared`);
@ -430,6 +435,7 @@ describe('Unshare a file', () => {
await confirmDialog.clickButton('Remove');
await confirmDialog.waitForDialogToClose();
await shareDialog.waitForDialogToClose();
expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open');
expect(await apis.user.nodes.isFileShared(file4Id)).toBe(false, `${file4} is shared`);
@ -512,6 +518,7 @@ describe('Unshare a file', () => {
await confirmDialog.clickButton('Remove');
await confirmDialog.waitForDialogToClose();
await shareDialog.waitForDialogToClose();
expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open');
expect(await apis.user.nodes.isFileShared(file2Id)).toBe(false, `${file2} is shared`);
@ -552,6 +559,7 @@ describe('Unshare a file', () => {
await confirmDialog.clickButton('Remove');
await confirmDialog.waitForDialogToClose();
await shareDialog.waitForDialogToClose();
expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open');
expect(await apis.user.nodes.isFileShared(file4Id)).toBe(false, `${file4} is shared`);
@ -640,6 +648,7 @@ describe('Unshare a file', () => {
await confirmDialog.clickButton('Remove');
await confirmDialog.waitForDialogToClose();
await shareDialog.waitForDialogToClose();
expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open');
expect(await apis.user.nodes.isFileShared(file2Id)).toBe(false, `${file2} is shared`);
@ -681,6 +690,7 @@ describe('Unshare a file', () => {
await confirmDialog.clickButton('Remove');
await confirmDialog.waitForDialogToClose();
await shareDialog.waitForDialogToClose();
expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open');
expect(await apis.user.nodes.isFileShared(file4Id)).toBe(false, `${file4} is shared`);

View File

@ -0,0 +1,114 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 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 { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { EXTENSIBILITY_CONFIGS, SIDEBAR_LABELS } from '../../configs';
import { RepoClient } from '../../utilities/repo-client/repo-client';
import { Utils } from '../../utilities/utils';
describe('Extensions - Context submenu', () => {
const username = `user-${Utils.random()}`;
const file = `file-${Utils.random()}.txt`;
let fileId;
const folder = `folder-${Utils.random()}`;
let folderId;
const restrictedPermissionsItem = 'Share';
const menuItem1 = {
label: 'Test Menu1',
submenu: [ 'Test submenu1', 'Test submenu2', restrictedPermissionsItem ]
};
const menuItem2 = {
label: 'Test Menu2',
submenu: [ restrictedPermissionsItem ]
};
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const personalFilesPage = new BrowsingPage();
const {dataTable} = personalFilesPage;
const contextMenu = dataTable.menu;
beforeAll(async (done) => {
await apis.admin.people.createUser({username});
fileId = (await apis.user.nodes.createFile(file)).entry.id;
folderId = (await apis.user.nodes.createFolder(folder)).entry.id;
await loginPage.load();
await Utils.setSessionStorageFromConfig('"aca.extension.config"', EXTENSIBILITY_CONFIGS.CONTEXT_SUBMENUS);
await loginPage.loginWith(username);
done();
});
beforeEach(async (done) => {
await Utils.pressEscape();
await dataTable.clearSelection();
await personalFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES);
await dataTable.waitForHeader();
done();
});
afterAll(async (done) => {
await apis.user.nodes.deleteNodeById(fileId, true);
await apis.user.nodes.deleteNodeById(folderId, true);
await logoutPage.load();
done();
});
it('Displays the submenu actions set from config - [C286717]', async () => {
await dataTable.rightClickOnItem(file);
expect(await contextMenu.isMenuItemPresent(menuItem1.label)).toBe(true, `${menuItem1.label} is not displayed for ${file}`);
expect(await contextMenu.hasSubMenu(menuItem1.label)).toBe(true, 'Menu does not have submenu');
await contextMenu.mouseOverMenuItem(menuItem1.label);
expect(await contextMenu.getSubmenuItemsCount()).toBe(3, 'submenu has wrong number of items');
expect(await contextMenu.isSubMenuItemPresent(menuItem1.submenu[0])).toBe(true, `${menuItem1.submenu[0]} is not displayed for ${file}`);
expect(await contextMenu.isSubMenuItemPresent(menuItem1.submenu[1])).toBe(true, `${menuItem1.submenu[1]} is not displayed for ${file}`);
expect(await contextMenu.isSubMenuItemPresent(menuItem1.submenu[2])).toBe(true, `${restrictedPermissionsItem} is not displayed for ${file}`);
});
it('Does not display submenu actions without permissions - [C286718]', async () => {
await dataTable.rightClickOnItem(folder);
expect(await contextMenu.isMenuItemPresent(menuItem1.label)).toBe(true, `${menuItem1.label} is not displayed for ${folder}`);
await contextMenu.mouseOverMenuItem(menuItem1.label);
expect(await contextMenu.getSubmenuItemsCount()).toBe(2, 'submenu has wrong number of items');
expect(await contextMenu.isSubMenuItemPresent(menuItem1.submenu[0])).toBe(true, `${menuItem1.submenu[0]} is not displayed for ${file}`);
expect(await contextMenu.isSubMenuItemPresent(menuItem1.submenu[1])).toBe(true, `${menuItem1.submenu[1]} is not displayed for ${file}`);
expect(await contextMenu.isSubMenuItemPresent(menuItem1.submenu[2])).toBe(false, `no permission submenu ${restrictedPermissionsItem} is displayed`);
});
it('The parent item is not displayed if all its children have no permission to be displayed - [C287784]', async () => {
await dataTable.rightClickOnItem(folder);
expect(await contextMenu.isMenuItemPresent(menuItem2.label)).toBe(false, `${menuItem2.label} menu is displayed for ${folder}`);
});
});