Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
751ede8479 |
@@ -62,4 +62,30 @@ describe('exam setup canvas serialization', () => {
|
|||||||
expect(shapes.map((s) => s.kind).sort()).toEqual(['boundary', 'furniture', 'part', 'response'])
|
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 })
|
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)
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user