From f87818807b78aa5c674bab4f43e13ca86391d8db Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Fri, 1 Dec 2023 12:05:56 +0100 Subject: [PATCH] test: fix e2e and acceptance tests --- .../src/components/FilesList/QuickActions.vue | 2 +- packages/web-app-files/src/extensions.ts | 2 +- .../tests/unit/components/FilesList/QuickActions.spec.ts | 6 ++++-- .../acceptance/pageObjects/FilesPageElement/filesList.js | 9 +++------ .../acceptance/pageObjects/FilesPageElement/filesRow.js | 4 ++-- tests/e2e/support/objects/app-files/share/actions.ts | 2 +- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/web-app-files/src/components/FilesList/QuickActions.vue b/packages/web-app-files/src/components/FilesList/QuickActions.vue index c6835d335e1..a6adaefc8a2 100644 --- a/packages/web-app-files/src/components/FilesList/QuickActions.vue +++ b/packages/web-app-files/src/components/FilesList/QuickActions.vue @@ -7,7 +7,7 @@ :aria-label="action.label()" appearance="raw" class="oc-mr-xs quick-action-button oc-p-xs" - :class="`files-quick-action-${action.id}`" + :class="`files-quick-action-${action.name}`" @click="action.handler({ space, resources: [item] })" > diff --git a/packages/web-app-files/src/extensions.ts b/packages/web-app-files/src/extensions.ts index 425bc1c6222..74e7c0be3b3 100644 --- a/packages/web-app-files/src/extensions.ts +++ b/packages/web-app-files/src/extensions.ts @@ -31,7 +31,7 @@ export const extensions = ({ applicationConfig }: ApplicationSetupOptions) => { // FIXME: replace with new create link action const quickLinkAction = { - name: 'quick-action-quicklink', + name: 'quicklink', id: 'quicklink', componentType: 'button', label: () => $gettext('Copy link'), diff --git a/packages/web-app-files/tests/unit/components/FilesList/QuickActions.spec.ts b/packages/web-app-files/tests/unit/components/FilesList/QuickActions.spec.ts index 1abc717f324..dedec676f63 100644 --- a/packages/web-app-files/tests/unit/components/FilesList/QuickActions.spec.ts +++ b/packages/web-app-files/tests/unit/components/FilesList/QuickActions.spec.ts @@ -17,6 +17,7 @@ const collaboratorAction = { handler: jest.fn(), icon: 'group-add', id: 'collaborators', + name: 'show-shares', label: () => 'Add people' } @@ -25,6 +26,7 @@ const quicklinkAction = { handler: jest.fn(), icon: 'link-add', id: 'quicklink', + name: 'quicklink', label: () => 'Create and copy quicklink' } @@ -48,14 +50,14 @@ describe('QuickActions', () => { const iconEl = actionButton.find('oc-icon-stub') expect(actionButton.exists()).toBeTruthy() - expect(actionButton.attributes().class).toContain('files-quick-action-collaborators') + expect(actionButton.attributes().class).toContain('files-quick-action-show-shares') expect(iconEl.exists()).toBeTruthy() expect(iconEl.attributes().name).toBe('group-add') expect(actionButton.attributes('aria-label')).toBe('Add people') }) it('should not display action buttons where "displayed" is set to false', () => { - const linkActionButton = wrapper.find('.files-quick-action-public-link') + const linkActionButton = wrapper.find('.files-quick-action-quicklink') expect(linkActionButton.exists()).toBeFalsy() }) diff --git a/tests/acceptance/pageObjects/FilesPageElement/filesList.js b/tests/acceptance/pageObjects/FilesPageElement/filesList.js index f84770f8aaf..b1df7d433cd 100644 --- a/tests/acceptance/pageObjects/FilesPageElement/filesList.js +++ b/tests/acceptance/pageObjects/FilesPageElement/filesList.js @@ -199,10 +199,7 @@ module.exports = { * @return {Promise} */ isSharingButtonPresent: async function (resource, elementType = 'any') { - const sharingBtnSelector = util.format( - filesRow.elements.quickAction.selector, - 'collaborators' - ) + const sharingBtnSelector = util.format(filesRow.elements.quickAction.selector, 'show-shares') const resourceRowSelector = this.getFileRowSelectorByFileName(resource, elementType) let isPresent = true @@ -622,8 +619,8 @@ module.exports = { }, useQuickAction: async function (resource, action) { - action = action.replace(/\s/, '-') - const actionSelector = util.format(filesRow.elements.quickAction.selector, action) + const className = action === 'collaborators' ? 'show-shares' : 'quicklink' + const actionSelector = util.format(filesRow.elements.quickAction.selector, className) const resourceRowSelector = this.getFileRowSelectorByFileName(resource) await this.waitForFileVisible(resource) diff --git a/tests/acceptance/pageObjects/FilesPageElement/filesRow.js b/tests/acceptance/pageObjects/FilesPageElement/filesRow.js index 6ec4caae46e..d7974d1d6e2 100644 --- a/tests/acceptance/pageObjects/FilesPageElement/filesRow.js +++ b/tests/acceptance/pageObjects/FilesPageElement/filesRow.js @@ -4,8 +4,8 @@ const util = require('util') module.exports = { commands: { isQuickActionVisible: function (action) { - action = action.replace(/\s/, '-') - const actionSelector = util.format(this.elements.quickAction.selector, action) + const className = action === 'collaborators' ? 'show-shares' : 'quicklink' + const actionSelector = util.format(this.elements.quickAction.selector, className) this.useXpath().expect.element(actionSelector).to.be.visible this.useCss() diff --git a/tests/e2e/support/objects/app-files/share/actions.ts b/tests/e2e/support/objects/app-files/share/actions.ts index b76a9fa835b..cca6f070d49 100644 --- a/tests/e2e/support/objects/app-files/share/actions.ts +++ b/tests/e2e/support/objects/app-files/share/actions.ts @@ -8,7 +8,7 @@ import { config } from '../../../../config.js' import { createdLinkStore } from '../../../store' const quickShareButton = - '//*[@data-test-resource-name="%s"]/ancestor::tr//button[contains(@class, "files-quick-action-collaborators")]' + '//*[@data-test-resource-name="%s"]/ancestor::tr//button[contains(@class, "files-quick-action-show-shares")]' const noPermissionToShareLabel = '//*[@data-testid="files-collaborators-no-reshare-permissions-message"]' const actionMenuDropdownButton =