diff --git a/frontend/src/components/ChunkList.tsx b/frontend/src/components/ChunkList.tsx index 94d634d..4d9faee 100644 --- a/frontend/src/components/ChunkList.tsx +++ b/frontend/src/components/ChunkList.tsx @@ -1,7 +1,7 @@ import React from 'react' import { Trash2 } from 'lucide-react' import type { ChunkInfo } from '../types' -import { getChunkPdfUrl } from '../lib/api' +import { getPdfViewerUrl } from '../lib/api' interface ChunkListProps { chunks: ChunkInfo[] @@ -67,7 +67,7 @@ export const ChunkList: React.FC = ({ {chunk.chunk_file_path && ( = ({
Chunk {source.chunk_index}
{source.chunk_file_path && (
({ - getChunkPdfUrl: (path: string) => `http://localhost:8000/api/v1/chunks/${path}/pdf`, + getPdfViewerUrl: (filePath: string, page?: number) => { + const base = `/pdf-viewer?url=http://localhost:8000/api/v1/chunks/${filePath}/pdf` + return page !== undefined ? `${base}&page=${page}` : base + }, })) const mockChunks: ChunkInfo[] = [ @@ -62,7 +65,7 @@ describe('ChunkList', () => { const links = screen.getAllByTestId('view-chunk-pdf-link') expect(links).toHaveLength(2) - expect(links[0]).toHaveAttribute('href', 'http://localhost:8000/api/v1/chunks/test_page_1.pdf/pdf') + expect(links[0]).toHaveAttribute('href', expect.stringContaining('/pdf-viewer?url=')) expect(links[0]).toHaveAttribute('target', '_blank') }) diff --git a/frontend/src/test/setup.ts b/frontend/src/test/setup.ts index 88dbc9e..bdd9bbe 100644 --- a/frontend/src/test/setup.ts +++ b/frontend/src/test/setup.ts @@ -7,6 +7,21 @@ global.ResizeObserver = class ResizeObserver { } global.DOMRect = class DOMRect { - x = 0; y = 0; width = 0; height = 0; top = 0; right = 0; bottom = 0; left = 0 + x: number; y: number; width: number; height: number; top: number; right: number; bottom: number; left: number + constructor(x = 0, y = 0, width = 0, height = 0) { + this.x = x; this.y = y; this.width = width; this.height = height + this.top = y; this.right = x + width; this.bottom = y + height; this.left = x + } static fromRect() { return new DOMRect() } + toJSON() { return { x: this.x, y: this.y, width: this.width, height: this.height, top: this.top, right: this.right, bottom: this.bottom, left: this.left } } +} + +global.DOMMatrix = class DOMMatrix { + a = 1; b = 0; c = 0; d = 1; e = 0; f = 0 + is2D = true + isIdentity = true + static fromMatrix() { return new DOMMatrix() } + multiply() { return new DOMMatrix() } + translate() { return new DOMMatrix() } + scale() { return new DOMMatrix() } }