Initial commit — Drive, an S3 file browser with WOPI editing
Lightweight replacement for the upstream La Suite Numérique drive (Django/Celery/Next.js) built as a single Deno binary. Server (Deno + Hono): - S3 file operations via AWS SigV4 (no SDK) with pre-signed URLs - WOPI host for Collabora Online (CheckFileInfo, GetFile, PutFile, locks) - Ory Kratos session auth + CSRF protection - Ory Keto permission model (OPL namespaces, not yet wired to routes) - PostgreSQL metadata with recursive folder sizes - S3 backfill API for registering files uploaded outside the UI - OpenTelemetry tracing + metrics (opt-in via OTEL_ENABLED) Frontend (React 19 + Cunningham v4 + react-aria): - File browser with GridList, keyboard nav, multi-select - Collabora editor iframe (full-screen, form POST, postMessage) - Profile menu, waffle menu, drag-drop upload, asset type badges - La Suite integration service theming (runtime CSS) Testing (549 tests): - 235 server unit tests (Deno) — 90%+ coverage - 278 UI unit tests (Vitest) — 90%+ coverage - 11 E2E tests (Playwright) - 12 integration service tests (Playwright) - 13 WOPI integration tests (Playwright + Docker Compose + Collabora) MIT licensed.
This commit is contained in:
66
ui/src/pages/__tests__/Recent.test.tsx
Normal file
66
ui/src/pages/__tests__/Recent.test.tsx
Normal file
@@ -0,0 +1,66 @@
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import { MemoryRouter } from 'react-router-dom'
|
||||
import Recent from '../Recent'
|
||||
|
||||
vi.mock('../../api/files', () => ({
|
||||
useRecentFiles: vi.fn(() => ({
|
||||
data: [
|
||||
{
|
||||
id: 'file-1',
|
||||
filename: 'recent-doc.docx',
|
||||
mimetype: 'application/msword',
|
||||
size: 2048,
|
||||
owner_id: 'user-12345678',
|
||||
parent_id: null,
|
||||
is_folder: false,
|
||||
created_at: '2026-03-20T10:00:00Z',
|
||||
updated_at: '2026-03-20T10:00:00Z',
|
||||
deleted_at: null,
|
||||
s3_key: 's3/file-1',
|
||||
},
|
||||
],
|
||||
isLoading: false,
|
||||
})),
|
||||
}))
|
||||
|
||||
vi.mock('../../components/FileBrowser', () => ({
|
||||
default: ({ files, isLoading }: any) => (
|
||||
<div data-testid="file-browser">
|
||||
{isLoading ? 'Loading...' : `${files.length} files`}
|
||||
</div>
|
||||
),
|
||||
}))
|
||||
|
||||
describe('Recent page', () => {
|
||||
it('renders heading', () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<Recent />
|
||||
</MemoryRouter>
|
||||
)
|
||||
expect(screen.getByText('Recent Files')).toBeDefined()
|
||||
})
|
||||
|
||||
it('renders FileBrowser with data', () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<Recent />
|
||||
</MemoryRouter>
|
||||
)
|
||||
expect(screen.getByTestId('file-browser')).toBeDefined()
|
||||
expect(screen.getByText('1 files')).toBeDefined()
|
||||
})
|
||||
|
||||
it('passes isLoading to FileBrowser', async () => {
|
||||
const { useRecentFiles } = await import('../../api/files') as any
|
||||
useRecentFiles.mockReturnValue({ data: undefined, isLoading: true })
|
||||
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<Recent />
|
||||
</MemoryRouter>
|
||||
)
|
||||
expect(screen.getByText('Loading...')).toBeDefined()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user