diff options
author | Hamza <hamzamahjoubi221@gmail.com> | 2025-07-11 12:56:55 +0200 |
---|---|---|
committer | Hamza <hamzamahjoubi221@gmail.com> | 2025-07-11 14:33:07 +0200 |
commit | a4a6869d78e1787b26e6cb0cc34e9e47c65ec992 (patch) | |
tree | 504164bd31f187cab60adc81972b5f8b63fc849f | |
parent | 4c19c815cad59b31e1b107835e9d269155977eac (diff) | |
download | nextcloud-server-a4a6869d78e1787b26e6cb0cc34e9e47c65ec992.tar.gz nextcloud-server-a4a6869d78e1787b26e6cb0cc34e9e47c65ec992.zip |
fix: adapt rename action tests to check for parent permissions
Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
-rw-r--r-- | apps/files/src/actions/renameAction.spec.ts | 22 | ||||
-rw-r--r-- | apps/files/src/services/HotKeysService.spec.ts | 9 |
2 files changed, 22 insertions, 9 deletions
diff --git a/apps/files/src/actions/renameAction.spec.ts b/apps/files/src/actions/renameAction.spec.ts index 954eca5820f..1f9c9209d41 100644 --- a/apps/files/src/actions/renameAction.spec.ts +++ b/apps/files/src/actions/renameAction.spec.ts @@ -3,15 +3,23 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ import { action } from './renameAction' -import { File, Permission, View, FileAction } from '@nextcloud/files' +import { File, Folder, Permission, View, FileAction } from '@nextcloud/files' import * as eventBus from '@nextcloud/event-bus' -import { describe, expect, test, vi } from 'vitest' +import { describe, expect, test, vi, beforeEach } from 'vitest' +import { useFilesStore } from '../store/files' +import { getPinia } from '../store/index.ts' const view = { id: 'files', name: 'Files', } as View +beforeEach(() => { + const root = new Folder({ owner: 'test', source: 'https://cloud.domain.com/remote.php/dav/files/admin/', id: 1, permissions: Permission.CREATE }) + const files = useFilesStore(getPinia()) + files.setRoot({ service: 'files', root }) +}) + describe('Rename action conditions tests', () => { test('Default values', () => { expect(action).toBeInstanceOf(FileAction) @@ -26,7 +34,7 @@ describe('Rename action conditions tests', () => { describe('Rename action enabled tests', () => { test('Enabled for node with UPDATE permission', () => { const file = new File({ - id: 1, + id: 2, source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt', owner: 'admin', mime: 'text/plain', @@ -39,7 +47,7 @@ describe('Rename action enabled tests', () => { test('Disabled for node without DELETE permission', () => { const file = new File({ - id: 1, + id: 2, source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt', owner: 'admin', mime: 'text/plain', @@ -54,13 +62,13 @@ describe('Rename action enabled tests', () => { window.OCA = { Files: { Sidebar: {} } } const file1 = new File({ - id: 1, + id: 2, source: 'https://cloud.domain.com/remote.php/dav/files/admin/foo.txt', owner: 'admin', mime: 'text/plain', }) const file2 = new File({ - id: 1, + id: 2, source: 'https://cloud.domain.com/remote.php/dav/files/admin/bar.txt', owner: 'admin', mime: 'text/plain', @@ -76,7 +84,7 @@ describe('Rename action exec tests', () => { vi.spyOn(eventBus, 'emit') const file = new File({ - id: 1, + id: 2, source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt', owner: 'admin', mime: 'text/plain', diff --git a/apps/files/src/services/HotKeysService.spec.ts b/apps/files/src/services/HotKeysService.spec.ts index d9a8ad659de..92430c8e6ad 100644 --- a/apps/files/src/services/HotKeysService.spec.ts +++ b/apps/files/src/services/HotKeysService.spec.ts @@ -2,13 +2,14 @@ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ -import { File, Permission, View } from '@nextcloud/files' +import { File, Folder, Permission, View } from '@nextcloud/files' import { describe, it, vi, expect, beforeEach, beforeAll, afterEach } from 'vitest' import { nextTick } from 'vue' import axios from '@nextcloud/axios' import { getPinia } from '../store/index.ts' import { useActiveStore } from '../store/active.ts' +import { useFilesStore } from '../store/files' import { action as deleteAction } from '../actions/deleteAction.ts' import { action as favoriteAction } from '../actions/favoriteAction.ts' @@ -49,13 +50,17 @@ describe('HotKeysService testing', () => { // Make sure the file is reset before each test file = new File({ - id: 1, + id: 2, source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt', owner: 'admin', mime: 'text/plain', permissions: Permission.ALL, }) + const root = new Folder({ owner: 'test', source: 'https://cloud.domain.com/remote.php/dav/files/admin/', id: 1, permissions: Permission.CREATE }) + const files = useFilesStore(getPinia()) + files.setRoot({ service: 'files', root }) + // Setting the view first as it reset the active node activeStore.activeView = view activeStore.activeNode = file |