mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACA-1797] add tests for viewer actions extension (#666)
This commit is contained in:
committed by
Denys Vuika
parent
8f0ae1a917
commit
b2b0da4c86
@@ -69,6 +69,10 @@ export class Menu extends Component {
|
|||||||
return this.component.element(by.cssContainingText(Menu.selectors.item, menuItem));
|
return this.component.element(by.cssContainingText(Menu.selectors.item, menuItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getItemById(id: string) {
|
||||||
|
return this.component.element(by.id(id));
|
||||||
|
}
|
||||||
|
|
||||||
getItemTooltip(menuItem: string): promise.Promise<string> {
|
getItemTooltip(menuItem: string): promise.Promise<string> {
|
||||||
return this.getItemByLabel(menuItem).getAttribute('title');
|
return this.getItemByLabel(menuItem).getAttribute('title');
|
||||||
}
|
}
|
||||||
@@ -78,6 +82,10 @@ export class Menu extends Component {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getItemIdAttribute(menuItem: string) {
|
||||||
|
return this.getItemByLabel(menuItem).getAttribute('id');
|
||||||
|
}
|
||||||
|
|
||||||
getItemsCount(): promise.Promise<number> {
|
getItemsCount(): promise.Promise<number> {
|
||||||
return this.items.count();
|
return this.items.count();
|
||||||
}
|
}
|
||||||
|
@@ -56,6 +56,10 @@ export class Toolbar extends Component {
|
|||||||
return this.component.element(by.css(`${Toolbar.selectors.button}[title="${title}"]`));
|
return this.component.element(by.css(`${Toolbar.selectors.button}[title="${title}"]`));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getButtonById(id: string) {
|
||||||
|
return this.component.element(by.id(id));
|
||||||
|
}
|
||||||
|
|
||||||
async openMoreMenu() {
|
async openMoreMenu() {
|
||||||
await this.getButtonByTitleAttribute('More actions').click();
|
await this.getButtonByTitleAttribute('More actions').click();
|
||||||
await this.menu.waitForMenuToOpen();
|
await this.menu.waitForMenuToOpen();
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -628,7 +628,70 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"viewer": {
|
"viewer": {
|
||||||
"toolbar": [
|
"toolbarActions": [
|
||||||
|
{
|
||||||
|
"id": "app.toolbar.download",
|
||||||
|
"order": 100,
|
||||||
|
"title": "My custom title",
|
||||||
|
"icon": "get_app",
|
||||||
|
"actions": {
|
||||||
|
"click": "DOWNLOAD_NODES"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"visible": "app.toolbar.canDownload"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "app.toolbar.my-action",
|
||||||
|
"order": 150,
|
||||||
|
"title": "My action",
|
||||||
|
"icon": "http",
|
||||||
|
"actions": {
|
||||||
|
"click": "SHARE_NODE"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"visible": "app.selection.file.canShare"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "app.viewer.print",
|
||||||
|
"order": 200,
|
||||||
|
"title": "APP.ACTIONS.PRINT",
|
||||||
|
"icon": "print",
|
||||||
|
"disabled": true,
|
||||||
|
"actions": {
|
||||||
|
"click": "PRINT_FILE"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"visible": "app.toolbar.canViewFile"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "app.viewer.share",
|
||||||
|
"order": 300,
|
||||||
|
"title": "APP.ACTIONS.SHARE",
|
||||||
|
"icon": "share",
|
||||||
|
"actions": {
|
||||||
|
"click": "SHARE_NODE"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"visible": "app.selection.file.canShare"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "app.viewer.fullscreen",
|
||||||
|
"order": 400,
|
||||||
|
"title": "APP.ACTIONS.FULLSCREEN",
|
||||||
|
"icon": "fullscreen",
|
||||||
|
"actions": {
|
||||||
|
"click": "FULLSCREEN_VIEWER"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"visible": "app.toolbar.canViewFile"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"toolbarMoreMenu": [
|
||||||
{
|
{
|
||||||
"id": "app.viewer.favorite.add",
|
"id": "app.viewer.favorite.add",
|
||||||
"order": 100,
|
"order": 100,
|
||||||
@@ -653,6 +716,28 @@
|
|||||||
"visible": "app.toolbar.favorite.canRemove"
|
"visible": "app.toolbar.favorite.canRemove"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "app.viewer.favorite",
|
||||||
|
"comment": "workaround for Recent Files and Search API issue",
|
||||||
|
"type": "custom",
|
||||||
|
"order": 101,
|
||||||
|
"component": "app.toolbar.toggleFavorite",
|
||||||
|
"rules": {
|
||||||
|
"visible": "app.toolbar.favorite.canToggle"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "app.toolbar.my-secondary-action",
|
||||||
|
"order": 150,
|
||||||
|
"title": "My secondary action",
|
||||||
|
"icon": "alarm",
|
||||||
|
"actions": {
|
||||||
|
"click": "PRINT_FILE"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"visible": "app.toolbar.canViewFile"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "app.viewer.share",
|
"id": "app.viewer.share",
|
||||||
"order": 300,
|
"order": 300,
|
||||||
@@ -680,7 +765,7 @@
|
|||||||
{
|
{
|
||||||
"id": "app.viewer.move",
|
"id": "app.viewer.move",
|
||||||
"order": 500,
|
"order": 500,
|
||||||
"title": "APP.ACTIONS.MOVE",
|
"title": "My new title",
|
||||||
"icon": "library_books",
|
"icon": "library_books",
|
||||||
"actions": {
|
"actions": {
|
||||||
"click": "MOVE_NODES"
|
"click": "MOVE_NODES"
|
||||||
@@ -717,6 +802,7 @@
|
|||||||
"id": "app.viewer.permissions",
|
"id": "app.viewer.permissions",
|
||||||
"order": 800,
|
"order": 800,
|
||||||
"title": "APP.ACTIONS.PERMISSIONS",
|
"title": "APP.ACTIONS.PERMISSIONS",
|
||||||
|
"disabled": true,
|
||||||
"icon": "settings_input_component",
|
"icon": "settings_input_component",
|
||||||
"actions": {
|
"actions": {
|
||||||
"click": "MANAGE_PERMISSIONS"
|
"click": "MANAGE_PERMISSIONS"
|
||||||
|
@@ -44,6 +44,28 @@ describe('Extensions - Viewer', () => {
|
|||||||
};
|
};
|
||||||
let docxFileId;
|
let docxFileId;
|
||||||
|
|
||||||
|
const customAction = {
|
||||||
|
id: 'app.toolbar.my-action',
|
||||||
|
title: 'My action',
|
||||||
|
icon: 'http'
|
||||||
|
};
|
||||||
|
|
||||||
|
const customSecondaryAction = {
|
||||||
|
id: 'app.toolbar.my-secondary-action',
|
||||||
|
title: 'My secondary action',
|
||||||
|
icon: 'alarm'
|
||||||
|
};
|
||||||
|
|
||||||
|
const downloadButton = {
|
||||||
|
id: 'app.toolbar.download',
|
||||||
|
title: 'My custom title'
|
||||||
|
};
|
||||||
|
|
||||||
|
const moveAction = {
|
||||||
|
id: 'app.viewer.move',
|
||||||
|
title: 'My new title'
|
||||||
|
}
|
||||||
|
|
||||||
const apis = {
|
const apis = {
|
||||||
admin: new RepoClient(),
|
admin: new RepoClient(),
|
||||||
user: new RepoClient(username, username)
|
user: new RepoClient(username, username)
|
||||||
@@ -54,6 +76,7 @@ describe('Extensions - Viewer', () => {
|
|||||||
const page = new BrowsingPage();
|
const page = new BrowsingPage();
|
||||||
|
|
||||||
const viewer = new Viewer();
|
const viewer = new Viewer();
|
||||||
|
const { toolbar } = viewer;
|
||||||
|
|
||||||
beforeAll(async (done) => {
|
beforeAll(async (done) => {
|
||||||
await apis.admin.people.createUser({ username });
|
await apis.admin.people.createUser({ username });
|
||||||
@@ -80,17 +103,78 @@ describe('Extensions - Viewer', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Insert new component in a content viewer - [C284659]', async () => {
|
afterEach(async (done) => {
|
||||||
await page.dataTable.doubleClickOnRowByName(pdfFile.file_name);
|
await Utils.pressEscape();
|
||||||
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
|
done();
|
||||||
expect(await viewer.isCustomContentPresent()).toBe(true, 'Custom content is not present');
|
})
|
||||||
expect(await viewer.getComponentIdOfView()).toEqual(pdfFile.component);
|
|
||||||
await viewer.clickClose();
|
|
||||||
|
|
||||||
await page.dataTable.doubleClickOnRowByName(docxFile.file_name);
|
xit('');
|
||||||
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
|
|
||||||
expect(await viewer.isCustomContentPresent()).toBe(true, 'Custom content is not present');
|
describe('content', () => {
|
||||||
expect(await viewer.getComponentIdOfView()).toEqual(docxFile.component);
|
it('Insert new component in a content viewer - [C284659]', async () => {
|
||||||
|
await page.dataTable.doubleClickOnRowByName(pdfFile.file_name);
|
||||||
|
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
|
||||||
|
expect(await viewer.isCustomContentPresent()).toBe(true, 'Custom content is not present');
|
||||||
|
expect(await viewer.getComponentIdOfView()).toEqual(pdfFile.component);
|
||||||
|
await viewer.clickClose();
|
||||||
|
|
||||||
|
await page.dataTable.doubleClickOnRowByName(docxFile.file_name);
|
||||||
|
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
|
||||||
|
expect(await viewer.isCustomContentPresent()).toBe(true, 'Custom content is not present');
|
||||||
|
expect(await viewer.getComponentIdOfView()).toEqual(docxFile.component);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('toolbar actions', () => {
|
||||||
|
it('Add a new action in the toolbar - [C286416]', async () => {
|
||||||
|
await page.dataTable.doubleClickOnRowByName(pdfFile.file_name);
|
||||||
|
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
|
||||||
|
|
||||||
|
expect(await toolbar.isButtonPresent(customAction.title)).toBe(true, 'Custom action is not present');
|
||||||
|
expect(await toolbar.getButtonByTitleAttribute(customAction.title).getAttribute('id')).toEqual(customAction.id);
|
||||||
|
expect(await toolbar.getButtonByTitleAttribute(customAction.title).getText()).toEqual(customAction.icon);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Modify title of action from toolbar - [C286417]', async () => {
|
||||||
|
await page.dataTable.doubleClickOnRowByName(pdfFile.file_name);
|
||||||
|
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
|
||||||
|
|
||||||
|
expect(await toolbar.getButtonById(downloadButton.id).getAttribute('title')).toEqual(downloadButton.title);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Remove action from toolbar - [C286419]', async () => {
|
||||||
|
await page.dataTable.doubleClickOnRowByName(pdfFile.file_name);
|
||||||
|
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
|
||||||
|
|
||||||
|
expect(await toolbar.isButtonPresent('Print')).toBe(false, 'Print button is still displayed');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('toolbar More actions menu', () => {
|
||||||
|
it('Add a new action - [C286420]', async () => {
|
||||||
|
await page.dataTable.doubleClickOnRowByName(pdfFile.file_name);
|
||||||
|
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
|
||||||
|
|
||||||
|
await toolbar.openMoreMenu();
|
||||||
|
expect(await toolbar.menu.isMenuItemPresent(customSecondaryAction.title)).toBe(true, 'action is not present');
|
||||||
|
expect(await toolbar.menu.getItemIconText(customSecondaryAction.title)).toEqual(customSecondaryAction.icon);
|
||||||
|
expect(await toolbar.menu.getItemIdAttribute(customSecondaryAction.title)).toEqual(customSecondaryAction.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Modify title of action from More actions menu - [C286421]', async () => {
|
||||||
|
await page.dataTable.doubleClickOnRowByName(pdfFile.file_name);
|
||||||
|
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
|
||||||
|
|
||||||
|
await toolbar.openMoreMenu();
|
||||||
|
expect(await toolbar.menu.getItemById(moveAction.id).getAttribute('title')).toEqual(moveAction.title);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Remove action from More actions menu - [C286423]', async () => {
|
||||||
|
await page.dataTable.doubleClickOnRowByName(pdfFile.file_name);
|
||||||
|
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
|
||||||
|
|
||||||
|
await toolbar.openMoreMenu();
|
||||||
|
expect(await toolbar.menu.isMenuItemPresent('Permissions')).toBe(false, 'Action is still displayed');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user