Skip to content

Commit

Permalink
test: fix e2e and acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Dec 1, 2023
1 parent 45726f1 commit f878188
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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] })"
>
<oc-icon :name="action.icon" fill-type="line" />
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const collaboratorAction = {
handler: jest.fn(),
icon: 'group-add',
id: 'collaborators',
name: 'show-shares',
label: () => 'Add people'
}

Expand All @@ -25,6 +26,7 @@ const quicklinkAction = {
handler: jest.fn(),
icon: 'link-add',
id: 'quicklink',
name: 'quicklink',
label: () => 'Create and copy quicklink'
}

Expand All @@ -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()
})
Expand Down
9 changes: 3 additions & 6 deletions tests/acceptance/pageObjects/FilesPageElement/filesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,7 @@ module.exports = {
* @return {Promise<module.exports.commands>}
*/
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

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/pageObjects/FilesPageElement/filesRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/support/objects/app-files/share/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit f878188

Please sign in to comment.