feat(drive): can move|copy to other drives

This commit is contained in:
Edouard Vanbelle
2026-06-29 21:19:51 +02:00
parent ee92d365b9
commit e81b297f68
2 changed files with 145 additions and 11 deletions
+32 -5
View File
@@ -1,11 +1,38 @@
import { it, expect, vi, beforeEach } from 'vitest';
import { render, screen, fireEvent, waitFor } from '@testing-library/svelte';
const { session, ui } = vi.hoisted(() => ({
session: { loadHomeFolder: vi.fn(async () => 'home'), homeFolderName: 'Files' },
ui: { notify: vi.fn() }
}));
vi.mock('$lib/stores/session.svelte', () => ({ session }));
// The dialog now sources its starting folder from the drives store
// (D6 drive switcher), not from `session.loadHomeFolder`. We mock a
// single default-personal drive whose `root_folder_id` is 'home' so
// the existing assertions (listFolder('home'), moveFile('f1', 'home'))
// stay valid without test churn.
const { ui, drives, driveIcon } = vi.hoisted(() => {
const homeDrive = {
id: 'drive-home',
root_folder_id: 'home',
name: 'Personal',
kind: 'personal' as const,
default_for_user: 'user-1',
caller_role: 'owner' as const,
used_bytes: 0,
quota_bytes: null
};
return {
ui: { notify: vi.fn() },
drives: {
drives: [homeDrive],
loaded: true,
load: vi.fn(async () => [homeDrive]),
findDefault: vi.fn(() => homeDrive),
findById: vi.fn((id: string) => (id === homeDrive.id ? homeDrive : null)),
findByRootFolderId: vi.fn((id: string) =>
id === homeDrive.root_folder_id ? homeDrive : null
)
},
driveIcon: vi.fn(() => 'home')
};
});
vi.mock('$lib/stores/drives.svelte', () => ({ drives, driveIcon }));
vi.mock('$lib/stores/ui.svelte', () => ({ ui }));
vi.mock('$lib/utils/errors', () => ({ errorToast: vi.fn() }));
vi.mock('$lib/api/endpoints/folders', () => ({ listFolder: vi.fn(), moveFolder: vi.fn() }));