-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1529 from nextcloud-libraries/feat/keyboard-shortcut
- Loading branch information
Showing
8 changed files
with
175 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* eslint-disable no-unused-expressions */ | ||
/** | ||
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
// dist file might not be built when running eslint only | ||
// eslint-disable-next-line import/no-unresolved,n/no-missing-import | ||
import { Folder, Permission, addNewFileMenuEntry, type Entry } from '@nextcloud/files' | ||
import { generateRemoteUrl } from '@nextcloud/router' | ||
import { UploadPicker } from '../../../lib/index.ts' | ||
|
||
describe('UploadPicker: hotkeys testing', () => { | ||
const propsData = { | ||
content: () => [], | ||
destination: new Folder({ | ||
id: 56, | ||
owner: 'user', | ||
source: generateRemoteUrl('dav/files/user/Folder'), | ||
permissions: Permission.ALL, | ||
root: '/files/user', | ||
}), | ||
} | ||
|
||
before(() => { | ||
addNewFileMenuEntry({ | ||
id: 'test', | ||
displayName: 'Test', | ||
iconSvgInline: '<svg></svg>', | ||
handler: (...args) => console.debug(args), | ||
} as Entry) | ||
}) | ||
|
||
it('opens the upload menu when pressing shift+u', () => { | ||
cy.mount(UploadPicker, { propsData }) | ||
|
||
// Check and init aliases | ||
cy.get('[data-cy-upload-picker] [data-cy-upload-picker-input]').as('input').should('exist') | ||
cy.get('[data-cy-upload-picker] .upload-picker__progress').as('progress').should('exist') | ||
|
||
cy.get('[role="menu"]').should('not.exist') | ||
|
||
cy.get('body').type('{shift}u') | ||
cy.get('[role="menu"]').should('be.visible') | ||
}) | ||
|
||
it('closes the upload menu when pressing escape', () => { | ||
cy.mount(UploadPicker, { propsData }) | ||
.then(({ component }) => { | ||
// force the menu to be opened | ||
component.openedMenu = true | ||
}) | ||
|
||
cy.get('[data-cy-upload-picker] [data-cy-upload-picker-input]').as('input').should('exist') | ||
cy.get('[data-cy-upload-picker] .upload-picker__progress').as('progress').should('exist') | ||
|
||
cy.get('[role="menu"]').should('be.visible') | ||
|
||
cy.get('body').type('{esc}') | ||
cy.get('[role="menu"]').should('not.be.visible') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.