From 03e8ab4b1e2a52d76b4b37b9ceef540e1138b7d4 Mon Sep 17 00:00:00 2001 From: Suzana Dirla Date: Tue, 23 Oct 2018 14:46:13 +0300 Subject: [PATCH] [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 --- cspell.json | 4 +- e2e/components/dialog/share-dialog.ts | 2 +- e2e/components/menu/menu.ts | 49 +- e2e/configs.ts | 3 +- .../context-submenus-ext.json | 1225 +++++++++++++++++ e2e/suites/actions/unshare-file.test.ts | 10 + .../extensions/ext-context-submenus.test.ts | 114 ++ 7 files changed, 1403 insertions(+), 4 deletions(-) create mode 100644 e2e/resources/extensibility-configs/context-submenus-ext.json create mode 100644 e2e/suites/extensions/ext-context-submenus.test.ts diff --git a/cspell.json b/cspell.json index 478081a32..c0c95e14f 100644 --- a/cspell.json +++ b/cspell.json @@ -52,7 +52,9 @@ "cardview", "webm", "keycodes", - "denysvuika" + "denysvuika", + "submenu", + "submenus" ], "dictionaries": ["html", "en-gb", "en_US"] } diff --git a/e2e/components/dialog/share-dialog.ts b/e2e/components/dialog/share-dialog.ts index 75ea20b28..827fae15a 100755 --- a/e2e/components/dialog/share-dialog.ts +++ b/e2e/components/dialog/share-dialog.ts @@ -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() { diff --git a/e2e/components/menu/menu.ts b/e2e/components/menu/menu.ts index f8d338ecc..59d5fd23e 100755 --- a/e2e/components/menu/menu.ts +++ b/e2e/components/menu/menu.ts @@ -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); diff --git a/e2e/configs.ts b/e2e/configs.ts index 4a3173209..acb00f33c 100755 --- a/e2e/configs.ts +++ b/e2e/configs.ts @@ -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' }; diff --git a/e2e/resources/extensibility-configs/context-submenus-ext.json b/e2e/resources/extensibility-configs/context-submenus-ext.json new file mode 100644 index 000000000..cfb41c8e9 --- /dev/null +++ b/e2e/resources/extensibility-configs/context-submenus-ext.json @@ -0,0 +1,1225 @@ +{ + "$schema": "../../extension.schema.json", + "$name": "app", + "$version": "1.0.0", + "$references": [ + "plugin1.json", + "dev.tools.json", + "app.header.json", + "app.create.json", + "metadata-plugin.json" + ], + + "rules": [ + { + "id": "app.toolbar.favorite.canToggle", + "comment": "workaround for recent files and search api issue", + "type": "core.every", + "parameters": [ + { + "type": "rule", + "value": "core.some", + "parameters": [ + { + "type": "rule", + "value": "app.selection.canAddFavorite" + }, + { + "type": "rule", + "value": "app.selection.canRemoveFavorite" + } + ] + }, + { + "type": "rule", + "value": "core.some", + "parameters": [ + { + "type": "rule", + "value": "app.navigation.isRecentFiles" + }, + { + "type": "rule", + "value": "app.navigation.isSharedFiles" + }, + { + "type": "rule", + "value": "app.navigation.isSearchResults" + }, + { + "type": "rule", + "value": "app.navigation.isFavorites" + } + ] + } + ] + }, + { + "id": "app.toolbar.favorite.canAdd", + "type": "core.every", + "parameters": [ + { "type": "rule", "value": "app.selection.canAddFavorite" }, + { "type": "rule", "value": "app.navigation.isNotRecentFiles" }, + { "type": "rule", "value": "app.navigation.isNotSharedFiles" }, + { + "type": "rule", + "value": "app.navigation.isNotSearchResults" + }, + { "type": "rule", "value": "app.navigation.isNotFavorites" } + ] + }, + { + "id": "app.toolbar.favorite.canRemove", + "type": "core.every", + "parameters": [ + { "type": "rule", "value": "app.selection.canRemoveFavorite" }, + { "type": "rule", "value": "app.navigation.isNotRecentFiles" }, + { "type": "rule", "value": "app.navigation.isNotSharedFiles" }, + { + "type": "rule", + "value": "app.navigation.isNotSearchResults" + }, + { "type": "rule", "value": "app.navigation.isNotFavorites" } + ] + }, + { + "id": "app.toolbar.info", + "type": "core.every", + "parameters": [ + { "type": "rule", "value": "app.selection.notEmpty" }, + { "type": "rule", "value": "app.navigation.isNotLibraries" }, + { "type": "rule", "value": "app.navigation.isNotTrashcan" } + ] + }, + { + "id": "app.toolbar.canCopyNode", + "type": "core.every", + "parameters": [ + { "type": "rule", "value": "app.selection.notEmpty" }, + { "type": "rule", "value": "app.navigation.isNotTrashcan" }, + { "type": "rule", "value": "app.navigation.isNotLibraries" } + ] + }, + { + "id": "app.toolbar.permissions", + "type": "core.every", + "parameters": [ + { "type": "rule", "value": "app.selection.first.canUpdate" }, + { "type": "rule", "value": "app.navigation.isNotTrashcan" } + ] + }, + { + "id": "app.toolbar.versions", + "type": "core.every", + "parameters": [ + { "type": "rule", "value": "app.selection.file" }, + { "type": "rule", "value": "app.navigation.isNotTrashcan" } + ] + }, + { + "id": "app.trashcan.hasSelection", + "type": "core.every", + "parameters": [ + { "type": "rule", "value": "app.selection.notEmpty" }, + { "type": "rule", "value": "app.navigation.isTrashcan" } + ] + }, + { + "id": "app.toolbar.canEditFolder", + "type": "core.every", + "parameters": [ + { "type": "rule", "value": "app.selection.folder" }, + { "type": "rule", "value": "app.selection.folder.canUpdate" }, + { "type": "rule", "value": "app.navigation.isNotTrashcan" } + ] + }, + { + "id": "app.toolbar.canViewFile", + "type": "core.every", + "parameters": [ + { + "type": "rule", + "value": "app.selection.file" + }, + { + "type": "rule", + "value": "core.not", + "parameters": [ + { "type": "rule", "value": "app.navigation.isTrashcan" } + ] + } + ] + }, + { + "id": "app.toolbar.canDownload", + "type": "core.every", + "parameters": [ + { "type": "rule", "value": "app.selection.canDownload" }, + { "type": "rule", "value": "app.navigation.isNotTrashcan" } + ] + } + ], + + "features": { + "create": [ + { + "id": "app.create.uploadFile", + "order": 100, + "icon": "file_upload", + "title": "APP.NEW_MENU.MENU_ITEMS.UPLOAD_FILE", + "description": "APP.NEW_MENU.TOOLTIPS.UPLOAD_FILES", + "description-disabled": "APP.NEW_MENU.TOOLTIPS.UPLOAD_FILES_NOT_ALLOWED", + "actions": { + "click": "UPLOAD_FILES" + }, + "rules": { + "enabled": "app.navigation.folder.canUpload" + } + }, + { + "id": "app.create.uploadFolder", + "order": 200, + "icon": "file_upload", + "title": "APP.NEW_MENU.MENU_ITEMS.UPLOAD_FOLDER", + "description": "APP.NEW_MENU.TOOLTIPS.UPLOAD_FOLDERS", + "description-disabled": "APP.NEW_MENU.TOOLTIPS.UPLOAD_FOLDERS_NOT_ALLOWED", + "actions": { + "click": "UPLOAD_FOLDER" + }, + "rules": { + "enabled": "app.navigation.folder.canUpload" + } + }, + { + "id": "app.create.separator.1", + "type": "separator", + "order": 300 + }, + { + "id": "app.create.folder", + "order": 400, + "icon": "create_new_folder", + "title": "APP.NEW_MENU.MENU_ITEMS.CREATE_FOLDER", + "description": "APP.NEW_MENU.TOOLTIPS.CREATE_FOLDER", + "description-disabled": "APP.NEW_MENU.TOOLTIPS.CREATE_FOLDER_NOT_ALLOWED", + "actions": { + "click": "CREATE_FOLDER" + }, + "rules": { + "enabled": "app.navigation.folder.canCreate" + } + }, + { + "id": "app.create.library", + "order": 600, + "title": "APP.NEW_MENU.MENU_ITEMS.CREATE_LIBRARY", + "description": "APP.NEW_MENU.TOOLTIPS.CREATE_LIBRARY", + "icon": "create_new_folder", + "actions": { + "click": "CREATE_LIBRARY" + } + } + ], + "navbar": [ + { + "id": "app.navbar.primary", + "items": [ + { + "id": "app.navbar.personalFiles", + "order": 100, + "icon": "folder", + "title": "APP.BROWSE.PERSONAL.SIDENAV_LINK.LABEL", + "description": "APP.BROWSE.PERSONAL.SIDENAV_LINK.TOOLTIP", + "route": "personal-files" + }, + { + "id": "app.navbar.libraries", + "order": 200, + "icon": "group_work", + "title": "APP.BROWSE.LIBRARIES.SIDENAV_LINK.LABEL", + "description": "APP.BROWSE.LIBRARIES.SIDENAV_LINK.TOOLTIP", + "route": "libraries" + } + ] + }, + { + "id": "app.navbar.secondary", + "items": [ + { + "id": "app.navbar.shared", + "order": 100, + "icon": "people", + "title": "APP.BROWSE.SHARED.SIDENAV_LINK.LABEL", + "description": "APP.BROWSE.SHARED.SIDENAV_LINK.TOOLTIP", + "route": "shared", + "rules": { + "visible": "repository.isQuickShareEnabled" + } + }, + { + "id": "app.navbar.recentFiles", + "order": 200, + "icon": "schedule", + "title": "APP.BROWSE.RECENT.SIDENAV_LINK.LABEL", + "description": "APP.BROWSE.RECENT.SIDENAV_LINK.TOOLTIP", + "route": "recent-files" + }, + { + "id": "app.navbar.favorites", + "order": 300, + "icon": "star", + "title": "APP.BROWSE.FAVORITES.SIDENAV_LINK.LABEL", + "description": "APP.BROWSE.FAVORITES.SIDENAV_LINK.TOOLTIP", + "route": "favorites" + }, + { + "id": "app.navbar.trashcan", + "order": 400, + "icon": "delete", + "title": "APP.BROWSE.TRASHCAN.SIDENAV_LINK.LABEL", + "description": "APP.BROWSE.TRASHCAN.SIDENAV_LINK.TOOLTIP", + "route": "trashcan" + } + ] + } + ], + "toolbar": [ + { + "id": "app.toolbar.preview", + "order": 100, + "title": "APP.ACTIONS.VIEW", + "icon": "open_in_browser", + "actions": { + "click": "VIEW_FILE" + }, + "rules": { + "visible": "app.toolbar.canViewFile" + } + }, + { + "id": "app.toolbar.download", + "order": 200, + "title": "APP.ACTIONS.DOWNLOAD", + "icon": "get_app", + "actions": { + "click": "DOWNLOAD_NODES" + }, + "rules": { + "visible": "app.toolbar.canDownload" + } + }, + { + "id": "app.toolbar.editFolder", + "order": 300, + "title": "APP.ACTIONS.EDIT", + "icon": "create", + "actions": { + "click": "EDIT_FOLDER" + }, + "rules": { + "visible": "app.toolbar.canEditFolder" + } + }, + { + "id": "app.toolbar.purgeDeletedNodes", + "order": 400, + "title": "APP.ACTIONS.DELETE_PERMANENT", + "icon": "delete_forever", + "actions": { + "click": "PURGE_DELETED_NODES" + }, + "rules": { + "visible": "app.trashcan.hasSelection" + } + }, + { + "id": "app.toolbar.restoreDeletedNodes", + "order": 500, + "title": "APP.ACTIONS.RESTORE", + "icon": "restore", + "actions": { + "click": "RESTORE_DELETED_NODES" + }, + "rules": { + "visible": "app.trashcan.hasSelection" + } + }, + { + "id": "app.toolbar.info", + "type": "custom", + "order": 700, + "component": "app.toolbar.toggleInfoDrawer", + "rules": { + "visible": "app.toolbar.info" + } + }, + { + "id": "app.toolbar.more", + "type": "menu", + "order": 10000, + "icon": "more_vert", + "title": "APP.ACTIONS.MORE", + "children": [ + { + "id": "app.toolbar.favorite", + "comment": "workaround for Recent Files and Search API issue", + "type": "custom", + "order": 100, + "component": "app.toolbar.toggleFavorite", + "rules": { + "visible": "app.toolbar.favorite.canToggle" + } + }, + { + "id": "app.toolbar.favorite.add", + "order": 200, + "title": "APP.ACTIONS.FAVORITE", + "icon": "star_border", + "actions": { + "click": "ADD_FAVORITE" + }, + "rules": { + "visible": "app.toolbar.favorite.canAdd" + } + }, + { + "id": "app.toolbar.favorite.remove", + "order": 300, + "title": "APP.ACTIONS.FAVORITE", + "icon": "star", + "actions": { + "click": "REMOVE_FAVORITE" + }, + "rules": { + "visible": "app.toolbar.favorite.canRemove" + } + }, + { + "id": "app.toolbar.copy", + "order": 400, + "title": "APP.ACTIONS.COPY", + "icon": "content_copy", + "actions": { + "click": "COPY_NODES" + }, + "rules": { + "visible": "app.toolbar.canCopyNode" + } + }, + { + "id": "app.toolbar.move", + "order": 500, + "title": "APP.ACTIONS.MOVE", + "icon": "library_books", + "actions": { + "click": "MOVE_NODES" + }, + "rules": { + "visible": "app.selection.canDelete" + } + }, + { + "id": "app.toolbar.share", + "type": "custom", + "order": 600, + "component": "app.shared-link.toggleSharedLink", + "rules": { + "visible": "app.selection.file.canShare" + } + }, + { + "id": "app.toolbar.delete", + "order": 800, + "title": "APP.ACTIONS.DELETE", + "icon": "delete", + "actions": { + "click": "DELETE_NODES" + }, + "rules": { + "visible": "app.selection.canDelete" + } + }, + { + "id": "app.toolbar.deleteLibrary", + "order": 900, + "title": "APP.ACTIONS.DELETE", + "icon": "delete", + "actions": { + "click": "DELETE_LIBRARY" + }, + "rules": { + "visible": "app.selection.library" + } + }, + { + "id": "app.toolbar.versions", + "order": 1000, + "title": "APP.ACTIONS.VERSIONS", + "icon": "history", + "actions": { + "click": "MANAGE_VERSIONS" + }, + "rules": { + "visible": "app.toolbar.versions" + } + }, + { + "id": "app.toolbar.permissions", + "order": 1100, + "title": "APP.ACTIONS.PERMISSIONS", + "icon": "settings_input_component", + "actions": { + "click": "MANAGE_PERMISSIONS" + }, + "rules": { + "visible": "app.toolbar.permissions" + } + } + ] + } + ], + "contextMenu": [ + { + "id": "app.context.submenu.test1", + "type": "menu", + "order": 50, + "title": "Test Menu1", + "icon": "more_vert", + "rules": { + "visible": "app.toolbar.canCopyNode" + }, + "children": [ + { + "id": "item1", + "order": 100, + "title": "Test submenu1", + "icon": "content_copy", + "actions": { + "click": "COPY_NODES" + }, + "rules": { + "visible": "app.toolbar.canCopyNode" + } + }, + { + "id": "item2", + "order": 200, + "title": "Test submenu2", + "icon": "content_copy", + "actions": { + "click": "COPY_NODES" + }, + "rules": { + "visible": "app.toolbar.canCopyNode" + } + }, + { + "id": "item3", + "type": "custom", + "order": 400, + "component": "app.shared-link.toggleSharedLink", + "rules": { + "visible": "app.selection.file.canShare" + } + } + ] + }, + { + "id": "app.context.submenu.test2", + "type": "menu", + "order": 51, + "title": "Test Menu2", + "icon": "more_vert", + "rules": { + "visible": "app.toolbar.canCopyNode" + }, + "children": [ + { + "id": "item3", + "type": "custom", + "order": 400, + "component": "app.shared-link.toggleSharedLink", + "rules": { + "visible": "app.selection.file.canShare" + } + } + ] + }, + + { + "id": "app.context.menu.download", + "order": 100, + "title": "APP.ACTIONS.DOWNLOAD", + "icon": "get_app", + "actions": { + "click": "DOWNLOAD_NODES" + }, + "rules": { + "visible": "app.toolbar.canDownload" + } + }, + { + "id": "app.context.menu.preview", + "order": 200, + "title": "APP.ACTIONS.VIEW", + "icon": "open_in_browser", + "actions": { + "click": "VIEW_FILE" + }, + "rules": { + "visible": "app.toolbar.canViewFile" + } + }, + { + "id": "app.context.menu.editFolder", + "order": 300, + "title": "APP.ACTIONS.EDIT", + "icon": "create", + "actions": { + "click": "EDIT_FOLDER" + }, + "rules": { + "visible": "app.toolbar.canEditFolder" + } + }, + { + "id": "app.context.menu.share", + "type": "custom", + "order": 400, + "component": "app.shared-link.toggleSharedLink", + "rules": { + "visible": "app.selection.file.canShare" + } + }, + { + "id": "app.context.menu.favorite.add", + "title": "APP.ACTIONS.FAVORITE", + "order": 500, + "icon": "star_border", + "actions": { + "click": "ADD_FAVORITE" + }, + "rules": { + "visible": "app.toolbar.favorite.canAdd" + } + }, + { + "id": "app.context.menu.favorite.remove", + "title": "APP.ACTIONS.FAVORITE", + "order": 600, + "icon": "star", + "actions": { + "click": "REMOVE_FAVORITE" + }, + "rules": { + "visible": "app.toolbar.favorite.canRemove" + } + }, + { + "id": "app.context.menu.favorite", + "comment": "workaround for Recent Files and Search API issue", + "type": "custom", + "order": 501, + "component": "app.toolbar.toggleFavorite", + "rules": { + "visible": "app.toolbar.favorite.canToggle" + } + }, + { + "id": "app.context.menu.copy", + "title": "APP.ACTIONS.COPY", + "order": 700, + "icon": "content_copy", + "actions": { + "click": "COPY_NODES" + }, + "rules": { + "visible": "app.toolbar.canCopyNode" + } + }, + { + "id": "app.context.menu.move", + "title": "APP.ACTIONS.MOVE", + "order": 800, + "icon": "library_books", + "actions": { + "click": "MOVE_NODES" + }, + "rules": { + "visible": "app.selection.canDelete" + } + }, + { + "id": "app.context.menu.delete", + "title": "APP.ACTIONS.DELETE", + "order": 900, + "icon": "delete", + "actions": { + "click": "DELETE_NODES" + }, + "rules": { + "visible": "app.selection.canDelete" + } + }, + { + "id": "app.context.menu.versions", + "title": "APP.ACTIONS.VERSIONS", + "order": 1000, + "icon": "history", + "actions": { + "click": "MANAGE_VERSIONS" + }, + "rules": { + "visible": "app.toolbar.versions" + } + }, + { + "id": "app.context.menu.permissions", + "title": "APP.ACTIONS.PERMISSIONS", + "icon": "settings_input_component", + "order": 1100, + "actions": { + "click": "MANAGE_PERMISSIONS" + }, + "rules": { + "visible": "app.toolbar.permissions" + } + }, + { + "id": "app.context.menu.purgeDeletedNodes", + "order": 1200, + "title": "APP.ACTIONS.DELETE_PERMANENT", + "icon": "delete_forever", + "actions": { + "click": "PURGE_DELETED_NODES" + }, + "rules": { + "visible": "app.trashcan.hasSelection" + } + }, + { + "id": "app.context.menu.restoreDeletedNodes", + "order": 1300, + "title": "APP.ACTIONS.RESTORE", + "icon": "restore", + "actions": { + "click": "RESTORE_DELETED_NODES" + }, + "rules": { + "visible": "app.trashcan.hasSelection" + } + } + ], + "viewer": { + "toolbarActions": [ + { + "id": "app.toolbar.download", + "order": 100, + "title": "APP.ACTIONS.DOWNLOAD", + "icon": "get_app", + "actions": { + "click": "DOWNLOAD_NODES" + }, + "rules": { + "visible": "app.toolbar.canDownload" + } + }, + { + "id": "app.viewer.print", + "order": 200, + "title": "APP.ACTIONS.PRINT", + "icon": "print", + "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", + "order": 100, + "title": "APP.ACTIONS.FAVORITE", + "icon": "star_border", + "actions": { + "click": "ADD_FAVORITE" + }, + "rules": { + "visible": "app.toolbar.favorite.canAdd" + } + }, + { + "id": "app.viewer.favorite.remove", + "order": 200, + "title": "APP.ACTIONS.FAVORITE", + "icon": "star", + "actions": { + "click": "REMOVE_FAVORITE" + }, + "rules": { + "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.viewer.share", + "type": "custom", + "order": 300, + "component": "app.shared-link.toggleSharedLink", + "rules": { + "visible": "app.selection.file.canShare" + } + }, + { + "id": "app.viewer.copy", + "order": 400, + "title": "APP.ACTIONS.COPY", + "icon": "content_copy", + "actions": { + "click": "COPY_NODES" + }, + "rules": { + "visible": "app.toolbar.canCopyNode" + } + }, + { + "id": "app.viewer.move", + "order": 500, + "title": "APP.ACTIONS.MOVE", + "icon": "library_books", + "actions": { + "click": "MOVE_NODES" + }, + "rules": { + "visible": "app.selection.canDelete" + } + }, + { + "id": "app.viewer.delete", + "order": 600, + "title": "APP.ACTIONS.DELETE", + "icon": "delete", + "actions": { + "click": "DELETE_NODES" + }, + "rules": { + "visible": "app.selection.canDelete" + } + }, + { + "id": "app.viewer.versions", + "order": 700, + "title": "APP.ACTIONS.VERSIONS", + "icon": "history", + "actions": { + "click": "MANAGE_VERSIONS" + }, + "rules": { + "visible": "app.toolbar.versions" + } + }, + { + "id": "app.viewer.permissions", + "order": 800, + "title": "APP.ACTIONS.PERMISSIONS", + "icon": "settings_input_component", + "actions": { + "click": "MANAGE_PERMISSIONS" + }, + "rules": { + "visible": "app.toolbar.permissions" + } + } + ], + "content": [ + { + "id": "app.viewer.pdf", + "disabled": true, + "fileExtension": "pdf", + "component": "app.components.tabs.metadata" + }, + { + "id": "app.viewer.docx", + "disabled": true, + "fileExtension": "docx", + "component": "app.components.tabs.comments" + } + ] + }, + "sidebar": [ + { + "id": "app.sidebar.properties", + "order": 100, + "title": "APP.INFO_DRAWER.TABS.PROPERTIES", + "component": "app.components.tabs.metadata" + }, + { + "id": "app.sidebar.comments", + "order": 200, + "title": "APP.INFO_DRAWER.TABS.COMMENTS", + "component": "app.components.tabs.comments" + }, + { + "id": "app.sidebar.versions", + "order": 300, + "disabled": true, + "title": "APP.INFO_DRAWER.TABS.VERSIONS", + "component": "app.components.tabs.versions" + } + ], + "content-metadata-presets": [ + { + "id": "app.content.metadata.custom", + "custom": [ + { + "id": "app.content.metadata.customGroup", + "title": "APP.CONTENT_METADATA.EXIF_GROUP_TITLE", + "items": [ + { + "id": "app.content.metadata.exifAspect", + "aspect": "exif:exif", + "properties": [ + "exif:pixelXDimension", + "exif:pixelYDimension", + "exif:dateTimeOriginal", + "exif:exposureTime", + "exif:fNumber", + "exif:flash", + "exif:focalLength", + "exif:isoSpeedRatings", + "exif:orientation", + "exif:manufacturer", + "exif:model", + "exif:software" + ] + } + ] + } + ] + } + ], + "documentList": { + "files": [ + { + "id": "app.files.thumbnail", + "key": "$thumbnail", + "type": "image", + "class": "image-table-cell", + "sortable": false, + "desktopOnly": false + }, + { + "id": "app.files.name", + "key": "name", + "title": "APP.DOCUMENT_LIST.COLUMNS.NAME", + "type": "text", + "class": "adf-data-table-cell--ellipsis__name", + "sortable": true, + "template": "app.columns.name", + "desktopOnly": false + }, + { + "id": "app.files.size", + "key": "content.sizeInBytes", + "title": "APP.DOCUMENT_LIST.COLUMNS.SIZE", + "type": "fileSize", + "sortable": true, + "desktopOnly": true + }, + { + "id": "app.files.modifiedOn", + "key": "modifiedAt", + "title": "APP.DOCUMENT_LIST.COLUMNS.MODIFIED_ON", + "type": "date", + "format": "timeAgo", + "sortable": true, + "desktopOnly": true + }, + { + "id": "app.files.modifiedBy", + "key": "modifiedByUser.displayName", + "title": "APP.DOCUMENT_LIST.COLUMNS.MODIFIED_BY", + "type": "text", + "class": "adf-data-table-cell--ellipsis", + "sortable": true, + "desktopOnly": true + } + ], + "libraries": [ + { + "id": "app.libraries.thumbnail", + "key": "$thumbnail", + "type": "image", + "class": "image-table-cell", + "sortable": false, + "desktopOnly": false + }, + { + "id": "app.libraries.name", + "key": "title", + "title": "APP.DOCUMENT_LIST.COLUMNS.TITLE", + "type": "text", + "class": "adf-data-table-cell--ellipsis__name", + "sortable": true, + "template": "app.columns.libraryName", + "desktopOnly": false + }, + { + "id": "app.libraries.visibility", + "key": "visibility", + "title": "APP.DOCUMENT_LIST.COLUMNS.STATUS", + "type": "text", + "sortable": true, + "template": "app.columns.libraryStatus", + "desktopOnly": true + } + ], + "shared": [ + { + "id": "app.shared.thumbnail", + "key": "$thumbnail", + "type": "image", + "class": "image-table-cell", + "sortable": false, + "desktopOnly": false + }, + { + "id": "app.shared.name", + "key": "name", + "title": "APP.DOCUMENT_LIST.COLUMNS.NAME", + "type": "text", + "class": "adf-data-table-cell--ellipsis__name", + "sortable": true, + "template": "app.columns.name", + "desktopOnly": false + }, + { + "id": "app.shared.location", + "key": "path.name", + "title": "APP.DOCUMENT_LIST.COLUMNS.LOCATION", + "type": "text", + "sortable": true, + "template": "app.columns.location", + "desktopOnly": true + }, + { + "id": "app.shared.size", + "key": "content.sizeInBytes", + "title": "APP.DOCUMENT_LIST.COLUMNS.SIZE", + "type": "fileSize", + "sortable": true, + "desktopOnly": true + }, + { + "id": "app.shared.modifiedOn", + "key": "modifiedAt", + "title": "APP.DOCUMENT_LIST.COLUMNS.MODIFIED_ON", + "type": "date", + "format": "timeAgo", + "sortable": true, + "desktopOnly": true + }, + { + "id": "app.shared.modifiedBy", + "key": "modifiedByUser.displayName", + "title": "APP.DOCUMENT_LIST.COLUMNS.MODIFIED_BY", + "type": "text", + "class": "adf-data-table-cell--ellipsis", + "sortable": true, + "desktopOnly": true + }, + { + "id": "app.shared.sharedBy", + "key": "sharedByUser.displayName", + "title": "APP.DOCUMENT_LIST.COLUMNS.SHARED_BY", + "type": "text", + "class": "adf-data-table-cell--ellipsis", + "sortable": true, + "desktopOnly": true + } + ], + "recent": [ + { + "id": "app.recent.thumbnail", + "key": "$thumbnail", + "type": "image", + "class": "image-table-cell", + "sortable": false, + "desktopOnly": false + }, + { + "id": "app.recent.name", + "key": "name", + "title": "APP.DOCUMENT_LIST.COLUMNS.NAME", + "type": "text", + "class": "adf-data-table-cell--ellipsis__name", + "sortable": true, + "template": "app.columns.name", + "desktopOnly": false + }, + { + "id": "app.recent.location", + "key": "path.name", + "title": "APP.DOCUMENT_LIST.COLUMNS.LOCATION", + "type": "text", + "sortable": true, + "template": "app.columns.location", + "desktopOnly": true + }, + { + "id": "app.recent.size", + "key": "content.sizeInBytes", + "title": "APP.DOCUMENT_LIST.COLUMNS.SIZE", + "type": "fileSize", + "sortable": true, + "desktopOnly": true + }, + { + "id": "app.recent.modifiedOn", + "key": "modifiedAt", + "title": "APP.DOCUMENT_LIST.COLUMNS.MODIFIED_ON", + "type": "date", + "format": "timeAgo", + "sortable": true, + "desktopOnly": true + } + ], + "favorites": [ + { + "id": "app.favorites.thumbnail", + "key": "$thumbnail", + "type": "image", + "class": "image-table-cell", + "sortable": false, + "desktopOnly": false + }, + { + "id": "app.favorites.name", + "key": "name", + "title": "APP.DOCUMENT_LIST.COLUMNS.NAME", + "type": "text", + "class": "adf-data-table-cell--ellipsis__name", + "sortable": true, + "template": "app.columns.name", + "desktopOnly": false + }, + { + "id": "app.favorites.location", + "key": "path.name", + "title": "APP.DOCUMENT_LIST.COLUMNS.LOCATION", + "type": "text", + "sortable": true, + "template": "app.columns.location", + "desktopOnly": true + }, + { + "id": "app.favorites.size", + "key": "sizeInBytes", + "title": "APP.DOCUMENT_LIST.COLUMNS.SIZE", + "type": "fileSize", + "sortable": true, + "desktopOnly": true + }, + { + "id": "app.favorites.modifiedOn", + "key": "modifiedAt", + "title": "APP.DOCUMENT_LIST.COLUMNS.MODIFIED_ON", + "type": "date", + "format": "timeAgo", + "sortable": true, + "desktopOnly": true + }, + { + "id": "app.favorites.modifiedBy", + "key": "modifiedByUser.displayName", + "title": "APP.DOCUMENT_LIST.COLUMNS.MODIFIED_BY", + "type": "text", + "class": "adf-data-table-cell--ellipsis", + "sortable": true, + "desktopOnly": true + } + ], + "trashcan": [ + { + "id": "app.trashcan.thumbnail", + "key": "$thumbnail", + "type": "image", + "class": "image-table-cell", + "sortable": false, + "desktopOnly": false + }, + { + "id": "app.trashcan.name", + "key": "name", + "title": "APP.DOCUMENT_LIST.COLUMNS.NAME", + "type": "text", + "class": "adf-data-table-cell--ellipsis__name", + "sortable": true, + "template": "app.columns.trashcanName", + "desktopOnly": false + }, + { + "id": "app.trashcan.location", + "key": "path.name", + "title": "APP.DOCUMENT_LIST.COLUMNS.LOCATION", + "type": "text", + "sortable": true, + "template": "app.columns.location", + "desktopOnly": true + }, + { + "id": "app.trashcan.size", + "key": "content.sizeInBytes", + "title": "APP.DOCUMENT_LIST.COLUMNS.SIZE", + "type": "fileSize", + "sortable": true, + "desktopOnly": true + }, + { + "id": "app.trashcan.deletedOn", + "key": "archivedAt", + "title": "APP.DOCUMENT_LIST.COLUMNS.DELETED_ON", + "type": "date", + "format": "timeAgo", + "sortable": true, + "desktopOnly": true + } + ] + } + } +} diff --git a/e2e/suites/actions/unshare-file.test.ts b/e2e/suites/actions/unshare-file.test.ts index 16591a9f9..11279c523 100755 --- a/e2e/suites/actions/unshare-file.test.ts +++ b/e2e/suites/actions/unshare-file.test.ts @@ -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`); diff --git a/e2e/suites/extensions/ext-context-submenus.test.ts b/e2e/suites/extensions/ext-context-submenus.test.ts new file mode 100644 index 000000000..a191e7d74 --- /dev/null +++ b/e2e/suites/extensions/ext-context-submenus.test.ts @@ -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 . + */ + +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}`); + }); +});