|
| 1 | +/* eslint-disable no-unused-expressions */ |
| 2 | +/** |
| 3 | + * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors |
| 4 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 5 | + */ |
| 6 | +// dist file might not be built when running eslint only |
| 7 | +// eslint-disable-next-line import/no-unresolved,n/no-missing-import |
| 8 | +import { Folder, Permission, addNewFileMenuEntry, type Entry } from '@nextcloud/files' |
| 9 | +import { generateRemoteUrl } from '@nextcloud/router' |
| 10 | +import { UploadPicker } from '../../../lib/index.ts' |
| 11 | +import type { ComponentPublicInstance } from 'vue' |
| 12 | + |
| 13 | +describe('UploadPicker: hotkeys testing', () => { |
| 14 | + const propsData = { |
| 15 | + content: () => [], |
| 16 | + destination: new Folder({ |
| 17 | + id: 56, |
| 18 | + owner: 'user', |
| 19 | + source: generateRemoteUrl('dav/files/user/Folder'), |
| 20 | + permissions: Permission.ALL, |
| 21 | + root: '/files/user', |
| 22 | + }), |
| 23 | + } |
| 24 | + |
| 25 | + before(() => { |
| 26 | + addNewFileMenuEntry({ |
| 27 | + id: 'test', |
| 28 | + displayName: 'Test', |
| 29 | + iconSvgInline: '<svg></svg>', |
| 30 | + handler: (...args) => console.debug(args), |
| 31 | + } as Entry) |
| 32 | + }) |
| 33 | + |
| 34 | + it('opens the upload menu when pressing u', () => { |
| 35 | + cy.mount(UploadPicker, { propsData }) |
| 36 | + |
| 37 | + // Check and init aliases |
| 38 | + cy.get('[data-cy-upload-picker] [data-cy-upload-picker-input]').as('input').should('exist') |
| 39 | + cy.get('[data-cy-upload-picker] .upload-picker__progress').as('progress').should('exist') |
| 40 | + |
| 41 | + cy.get('[role="menu"]').should('not.exist') |
| 42 | + |
| 43 | + cy.get('body').type('u') |
| 44 | + cy.get('[role="menu"]').should('be.visible') |
| 45 | + }) |
| 46 | + |
| 47 | + it('closes the upload menu when pressing escape', () => { |
| 48 | + cy.mount(UploadPicker, { propsData }) |
| 49 | + .then(({ component }) => { |
| 50 | + // force the menu to be opened |
| 51 | + component.openedMenu = true |
| 52 | + }) |
| 53 | + |
| 54 | + cy.get('[data-cy-upload-picker] [data-cy-upload-picker-input]').as('input').should('exist') |
| 55 | + cy.get('[data-cy-upload-picker] .upload-picker__progress').as('progress').should('exist') |
| 56 | + |
| 57 | + cy.get('[role="menu"]').should('be.visible') |
| 58 | + |
| 59 | + cy.get('body').type('{esc}') |
| 60 | + cy.get('[role="menu"]').should('not.be.visible') |
| 61 | + }) |
| 62 | +}) |
0 commit comments