Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 35 additions & 26 deletions apps/files/src/services/HotKeysService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('HotKeysService testing', () => {
activeStore.setActiveNode(file)

window.OCA = { Files: { Sidebar: { open: () => {}, setActiveTab: () => {} } } }
// We only mock what needed, we do not need Files.Router.goTo or Files.Navigation
window.OCP = { Files: { Router: { goToRoute: goToRouteMock, params: {}, query: {} } } }

initialState = document.createElement('input')
Expand All @@ -73,56 +74,56 @@ describe('HotKeysService testing', () => {
})

it('Pressing d should open the sidebar once', () => {
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'd', code: 'KeyD' }))
dispatchEvent({ key: 'd', code: 'KeyD' })

// Modifier keys should not trigger the action
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'd', code: 'KeyD', ctrlKey: true }))
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'd', code: 'KeyD', altKey: true }))
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'd', code: 'KeyD', shiftKey: true }))
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'd', code: 'KeyD', metaKey: true }))
dispatchEvent({ key: 'd', code: 'KeyD', ctrlKey: true })
dispatchEvent({ key: 'd', code: 'KeyD', altKey: true })
dispatchEvent({ key: 'd', code: 'KeyD', shiftKey: true })
dispatchEvent({ key: 'd', code: 'KeyD', metaKey: true })

expect(sidebarAction.enabled).toHaveReturnedWith(true)
expect(sidebarAction.exec).toHaveBeenCalledOnce()
})

it('Pressing F2 should rename the file', () => {
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'F2', code: 'F2' }))
dispatchEvent({ key: 'F2', code: 'F2' })

// Modifier keys should not trigger the action
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'F2', code: 'F2', ctrlKey: true }))
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'F2', code: 'F2', altKey: true }))
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'F2', code: 'F2', shiftKey: true }))
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'F2', code: 'F2', metaKey: true }))
dispatchEvent({ key: 'F2', code: 'F2', ctrlKey: true })
dispatchEvent({ key: 'F2', code: 'F2', altKey: true })
dispatchEvent({ key: 'F2', code: 'F2', shiftKey: true })
dispatchEvent({ key: 'F2', code: 'F2', metaKey: true })

expect(renameAction.enabled).toHaveReturnedWith(true)
expect(renameAction.exec).toHaveBeenCalledOnce()
})

it('Pressing s should toggle favorite', () => {
vi.spyOn(axios, 'post').mockImplementationOnce(() => Promise.resolve())
window.dispatchEvent(new KeyboardEvent('keydown', { key: 's', code: 'KeyS' }))
dispatchEvent({ key: 's', code: 'KeyS' })

// Modifier keys should not trigger the action
window.dispatchEvent(new KeyboardEvent('keydown', { key: 's', code: 'KeyS', ctrlKey: true }))
window.dispatchEvent(new KeyboardEvent('keydown', { key: 's', code: 'KeyS', altKey: true }))
window.dispatchEvent(new KeyboardEvent('keydown', { key: 's', code: 'KeyS', shiftKey: true }))
window.dispatchEvent(new KeyboardEvent('keydown', { key: 's', code: 'KeyS', metaKey: true }))
dispatchEvent({ key: 's', code: 'KeyS', ctrlKey: true })
dispatchEvent({ key: 's', code: 'KeyS', altKey: true })
dispatchEvent({ key: 's', code: 'KeyS', shiftKey: true })
dispatchEvent({ key: 's', code: 'KeyS', metaKey: true })

expect(favoriteAction.enabled).toHaveReturnedWith(true)
expect(favoriteAction.exec).toHaveBeenCalledOnce()
})

it('Pressing Delete should delete the file', async () => {
// @ts-expect-error mocking private field
// @ts-expect-error unit testing
vi.spyOn(deleteAction._action, 'exec').mockResolvedValue(() => true)

window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Delete', code: 'Delete' }))
dispatchEvent({ key: 'Delete', code: 'Delete' })

// Modifier keys should not trigger the action
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Delete', code: 'Delete', ctrlKey: true }))
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Delete', code: 'Delete', altKey: true }))
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Delete', code: 'Delete', shiftKey: true }))
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Delete', code: 'Delete', metaKey: true }))
dispatchEvent({ key: 'Delete', code: 'Delete', ctrlKey: true })
dispatchEvent({ key: 'Delete', code: 'Delete', altKey: true })
dispatchEvent({ key: 'Delete', code: 'Delete', shiftKey: true })
dispatchEvent({ key: 'Delete', code: 'Delete', metaKey: true })

expect(deleteAction.enabled).toHaveReturnedWith(true)
expect(deleteAction.exec).toHaveBeenCalledOnce()
Expand All @@ -132,7 +133,7 @@ describe('HotKeysService testing', () => {
expect(goToRouteMock).toHaveBeenCalledTimes(0)
window.OCP.Files.Router.query = { dir: '/foo/bar' }

window.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowUp', code: 'ArrowUp', altKey: true }))
dispatchEvent({ key: 'ArrowUp', code: 'ArrowUp', altKey: true })

expect(goToRouteMock).toHaveBeenCalledOnce()
expect(goToRouteMock.mock.calls[0][2].dir).toBe('/foo')
Expand All @@ -145,9 +146,7 @@ describe('HotKeysService testing', () => {
userConfigStore.userConfig.grid_view = false
expect(userConfigStore.userConfig.grid_view).toBe(false)

window.dispatchEvent(new KeyboardEvent('keydown', { key: 'v', code: 'KeyV' }))
await nextTick()

dispatchEvent({ key: 'v', code: 'KeyV' })
expect(userConfigStore.userConfig.grid_view).toBe(true)
})

Expand All @@ -164,9 +163,19 @@ describe('HotKeysService testing', () => {
userConfigStore.userConfig.grid_view = false
expect(userConfigStore.userConfig.grid_view).toBe(false)

window.dispatchEvent(new KeyboardEvent('keydown', { key: 'v', code: 'KeyV', [modifier]: true }))
dispatchEvent(new KeyboardEvent('keydown', { key: 'v', code: 'KeyV', [modifier]: true }))

await nextTick()

expect(userConfigStore.userConfig.grid_view).toBe(false)
})
})

/**
* Helper to dispatch the correct event.
*
* @param init - KeyboardEvent options
*/
function dispatchEvent(init: KeyboardEventInit) {
document.body.dispatchEvent(new KeyboardEvent('keydown', { ...init, bubbles: true }))
}
19 changes: 14 additions & 5 deletions apps/systemtags/src/services/HotKeysService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,24 @@ describe('HotKeysService testing', () => {
})

it('Pressing t should open the tag management dialog', () => {
window.dispatchEvent(new KeyboardEvent('keydown', { key: 't', code: 'KeyT' }))
dispatchEvent({ key: 't', code: 'KeyT' })

// Modifier keys should not trigger the action
window.dispatchEvent(new KeyboardEvent('keydown', { key: 't', code: 'KeyT', ctrlKey: true }))
window.dispatchEvent(new KeyboardEvent('keydown', { key: 't', code: 'KeyT', altKey: true }))
window.dispatchEvent(new KeyboardEvent('keydown', { key: 't', code: 'KeyT', shiftKey: true }))
window.dispatchEvent(new KeyboardEvent('keydown', { key: 't', code: 'KeyT', metaKey: true }))
dispatchEvent({ key: 't', code: 'KeyT', ctrlKey: true })
dispatchEvent({ key: 't', code: 'KeyT', altKey: true })
dispatchEvent({ key: 't', code: 'KeyT', shiftKey: true })
dispatchEvent({ key: 't', code: 'KeyT', metaKey: true })

expect(bulkSystemTagsAction.enabled).toHaveReturnedWith(true)
expect(bulkSystemTagsAction.exec).toHaveBeenCalledOnce()
})
})

/**
* Helper to dispatch the correct event.
*
* @param init - KeyboardEvent options
*/
function dispatchEvent(init: KeyboardEventInit) {
document.body.dispatchEvent(new KeyboardEvent('keydown', { ...init, bubbles: true }))
}
2 changes: 1 addition & 1 deletion cypress/e2e/files/favorites.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('files: Favorites', { testIsolation: true }, () => {
// See action is called 'Add to favorites'
cy.get('[data-cy-files-list-row-action="favorite"] > button').last()
.should('exist')
.and('have.text', 'Add to favorites')
.and('contain.text', 'Add to favorites')
.click({ force: true })
cy.wait('@addToFavorites')
// See favorites star
Expand Down
2 changes: 1 addition & 1 deletion dist/1023-1023.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.0.1
- license: GPL-3.0-or-later
- @nextcloud/vue
- version: 8.26.1
- version: 8.27.0
- license: AGPL-3.0-or-later
- @vueuse/core
- version: 11.3.0
Expand Down
4 changes: 2 additions & 2 deletions dist/1406-1406.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/1406-1406.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.0.1
- license: GPL-3.0-or-later
- @nextcloud/vue
- version: 8.26.1
- version: 8.27.0
- license: AGPL-3.0-or-later
- @vueuse/core
- version: 11.3.0
Expand Down
2 changes: 1 addition & 1 deletion dist/1406-1406.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/1656-1656.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ This file is generated from multiple sources. Included packages:
- version: 1.10.0
- license: AGPL-3.0-or-later
- @nextcloud/vue
- version: 8.26.1
- version: 8.27.0
- license: AGPL-3.0-or-later
- @vueuse/core
- version: 11.3.0
Expand Down
2 changes: 1 addition & 1 deletion dist/3485-3485.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ This file is generated from multiple sources. Included packages:
- version: 1.10.0
- license: AGPL-3.0-or-later
- @nextcloud/vue
- version: 8.26.1
- version: 8.27.0
- license: AGPL-3.0-or-later
- @vueuse/core
- version: 11.3.0
Expand Down
2 changes: 1 addition & 1 deletion dist/3920-3920.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.0.1
- license: GPL-3.0-or-later
- @nextcloud/vue
- version: 8.26.1
- version: 8.27.0
- license: AGPL-3.0-or-later
- @vue/devtools-api
- version: 6.6.3
Expand Down
4 changes: 2 additions & 2 deletions dist/3982-3982.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/3982-3982.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.25.1
- license: MIT
- @nextcloud/vue
- version: 8.26.1
- version: 8.27.0
- license: AGPL-3.0-or-later
- @vueuse/components
- version: 11.3.0
Expand Down
2 changes: 1 addition & 1 deletion dist/3982-3982.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/4039-4039.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/4039-4039.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ This file is generated from multiple sources. Included packages:
- version: 0.2.4
- license: GPL-3.0-or-later
- @nextcloud/vue
- version: 8.26.1
- version: 8.27.0
- license: AGPL-3.0-or-later
- @vueuse/components
- version: 11.3.0
Expand Down
2 changes: 1 addition & 1 deletion dist/4039-4039.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/4040-4040.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.0.1
- license: GPL-3.0-or-later
- @nextcloud/vue
- version: 8.26.1
- version: 8.27.0
- license: AGPL-3.0-or-later
- @vueuse/core
- version: 11.3.0
Expand Down
4 changes: 2 additions & 2 deletions dist/4052-4052.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/4052-4052.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ This file is generated from multiple sources. Included packages:
- version: 0.2.4
- license: GPL-3.0-or-later
- @nextcloud/vue
- version: 8.26.1
- version: 8.27.0
- license: AGPL-3.0-or-later
- @vueuse/core
- version: 11.3.0
Expand Down
2 changes: 1 addition & 1 deletion dist/4052-4052.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/4309-4309.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/4309-4309.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ This file is generated from multiple sources. Included packages:
- version: 1.10.0
- license: AGPL-3.0-or-later
- @nextcloud/vue
- version: 8.26.1
- version: 8.27.0
- license: AGPL-3.0-or-later
- @vueuse/core
- version: 11.3.0
Expand Down
2 changes: 1 addition & 1 deletion dist/4309-4309.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/4508-4508.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion dist/4508-4508.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ SPDX-FileCopyrightText: Roeland Jago Douma
SPDX-FileCopyrightText: Paul Vorbach <[email protected]> (http://paul.vorba.ch)
SPDX-FileCopyrightText: Paul Vorbach <[email protected]> (http://vorb.de)
SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
SPDX-FileCopyrightText: Max <[email protected]>
SPDX-FileCopyrightText: Matt Zabriskie
SPDX-FileCopyrightText: Mark <[email protected]>
SPDX-FileCopyrightText: Mapbox
Expand Down Expand Up @@ -94,7 +95,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.25.1
- license: MIT
- @nextcloud/vue
- version: 8.26.1
- version: 8.27.0
- license: AGPL-3.0-or-later
- @ungap/structured-clone
- version: 1.2.0
Expand Down Expand Up @@ -171,6 +172,9 @@ This file is generated from multiple sources. Included packages:
- md5
- version: 2.3.0
- license: BSD-3-Clause
- mdast-squeeze-paragraphs
- version: 6.0.0
- license: MIT
- escape-string-regexp
- version: 5.0.0
- license: MIT
Expand Down Expand Up @@ -270,6 +274,9 @@ This file is generated from multiple sources. Included packages:
- remark-rehype
- version: 11.1.0
- license: MIT
- remark-unlink-protocols
- version: 1.0.0
- license: MIT
- space-separated-tokens
- version: 2.0.2
- license: MIT
Expand Down
2 changes: 1 addition & 1 deletion dist/459-459.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.0.1
- license: GPL-3.0-or-later
- @nextcloud/vue
- version: 8.26.1
- version: 8.27.0
- license: AGPL-3.0-or-later
- @vueuse/core
- version: 11.3.0
Expand Down
2 changes: 1 addition & 1 deletion dist/4965-4965.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.0.1
- license: GPL-3.0-or-later
- @nextcloud/vue
- version: 8.26.1
- version: 8.27.0
- license: AGPL-3.0-or-later
- @vueuse/core
- version: 11.3.0
Expand Down
4 changes: 2 additions & 2 deletions dist/5258-5258.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion dist/5258-5258.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ SPDX-FileCopyrightText: Paul Vorbach <[email protected]> (http://paul.vorba.ch)
SPDX-FileCopyrightText: Paul Vorbach <[email protected]> (http://vorb.de)
SPDX-FileCopyrightText: OpenJS Foundation and other contributors
SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
SPDX-FileCopyrightText: Max <[email protected]>
SPDX-FileCopyrightText: Matt Zabriskie
SPDX-FileCopyrightText: Mark <[email protected]>
SPDX-FileCopyrightText: Mapbox
Expand Down Expand Up @@ -98,7 +99,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.25.1
- license: MIT
- @nextcloud/vue
- version: 8.26.1
- version: 8.27.0
- license: AGPL-3.0-or-later
- @ungap/structured-clone
- version: 1.2.0
Expand Down Expand Up @@ -187,6 +188,9 @@ This file is generated from multiple sources. Included packages:
- md5
- version: 2.3.0
- license: BSD-3-Clause
- mdast-squeeze-paragraphs
- version: 6.0.0
- license: MIT
- escape-string-regexp
- version: 5.0.0
- license: MIT
Expand Down Expand Up @@ -286,6 +290,9 @@ This file is generated from multiple sources. Included packages:
- remark-rehype
- version: 11.1.0
- license: MIT
- remark-unlink-protocols
- version: 1.0.0
- license: MIT
- space-separated-tokens
- version: 2.0.2
- license: MIT
Expand Down
Loading
Loading