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
@@ -44,6 +44,28 @@ describe('Extensions - Viewer', () => {
|
||||
};
|
||||
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 = {
|
||||
admin: new RepoClient(),
|
||||
user: new RepoClient(username, username)
|
||||
@@ -54,6 +76,7 @@ describe('Extensions - Viewer', () => {
|
||||
const page = new BrowsingPage();
|
||||
|
||||
const viewer = new Viewer();
|
||||
const { toolbar } = viewer;
|
||||
|
||||
beforeAll(async (done) => {
|
||||
await apis.admin.people.createUser({ username });
|
||||
@@ -80,17 +103,78 @@ describe('Extensions - Viewer', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
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();
|
||||
afterEach(async (done) => {
|
||||
await Utils.pressEscape();
|
||||
done();
|
||||
})
|
||||
|
||||
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);
|
||||
xit('');
|
||||
|
||||
describe('content', () => {
|
||||
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