Compare commits

..
Author SHA1 Message Date
kcar ede9a78459 chore: preserve app workspace t_41bd9518 2026-08-09 20:24:43 +01:00
2 changed files with 1 additions and 26 deletions
-26
View File
@@ -62,30 +62,4 @@ describe('exam setup canvas serialization', () => {
expect(shapes.map((s) => s.kind).sort()).toEqual(['boundary', 'furniture', 'part', 'response'])
expect(shapes.find((s) => s.kind === 'part')).toMatchObject({ id: 'p1', x: 1, y: 2, w: 3, h: 4 })
})
it('round-trips boundary y as page-local with page_index while rendering at full page width', () => {
const pages = [
{ pageNumber: 1, x: 0, y: 0, w: 780, h: 1000 },
{ pageNumber: 2, x: 0, y: 1000, w: 820, h: 1200 },
]
const shapes = shapesFromTemplate({
...template,
page_count: 2,
boundaries: [
{ id: 'b1', template_id: 'tpl-1', question_id: 'q1', label: 'Q1 start', page_index: 1, y: 160, bounds: { x: 48, y: 160, w: 700, h: 8 }, source: 'manual', confirmed: true },
{ id: 'b2', template_id: 'tpl-1', question_id: 'q1', label: 'Q1 end', page_index: 1, y: 720, bounds: null, source: 'manual', confirmed: true },
],
}, pages)
expect(shapes[0]).toMatchObject({ kind: 'boundary', x: 0, y: 1160, w: 820, h: 8 })
expect(shapes[1]).toMatchObject({ kind: 'boundary', x: 0, y: 1720, w: 820, h: 8 })
const payload = serializeCanvasShapes(template, shapes, pages)
expect(payload.boundaries.map((b) => ({ page_index: b.page_index, y: b.y }))).toEqual([
{ page_index: 1, y: 160 },
{ page_index: 1, y: 720 },
])
expect(payload.boundaries.every((b) => b.bounds.w === 820)).toBe(true)
})
})
+1
View File
@@ -4,6 +4,7 @@ import type { ExamTemplateDetail, TemplateReplacePayload } from '../../types/exa
export const PAGE_HEIGHT = 1100
export const PAGE_WIDTH = 780
export const PAGE_GAP = 0
export const BOUNDARY_LINE_HEIGHT = 12
export interface CanvasPageGeometry { pageNumber: number; x: number; y: number; w: number; h: number }