import { describe, expect, it } from 'vitest'; import { buildPier } from '../src/core/geometry'; import { BEARING_ELEVATION_REF, DRAWING_TOL_MM, drawingCopingCheck, withDrawingBasis, type DrawingBearing } from '../src/core/bearing-ref'; import { loadP1 } from './helpers'; const drawing: DrawingBearing[] = BEARING_ELEVATION_REF.map((r) => ({ no: r.no, elx: r.elx, h1: r.h1, h2: r.h2 })); describe('받침 기준: 도면 EL.X (Q16 option 2, 승인 2026-10-23)', () => { it('the default basis (엑셀 z) keeps the model as before: the drawing check still reports the EL.X gap', () => { const excel = buildPier(loadP1()); expect(excel.blocks.filter((b) => b.row === '전열')[0].padTop).toBeCloseTo(43.561, 3); }); it('with the drawing basis the pads sit at the drawing EL.X and the coping tops stay within the 5 mm tolerance', () => { const m = buildPier(withDrawingBasis(loadP1(), drawing)); expect(m.blocks.filter((b) => b.row === '전열')[0].padTop).toBeCloseTo(43.625, 3); for (const c of drawingCopingCheck(m, drawing)) { expect(Math.abs(c.diffMm), `No ${c.no}`).toBeLessThanOrEqual(DRAWING_TOL_MM); } }); it('with the drawing basis the front block (h1) is 164 mm and the back block 139 mm, excluding the 50 mm pad', () => { const m = buildPier(withDrawingBasis(loadP1(), drawing)); const front = m.blocks.filter((b) => b.row === '전열')[0]; const back = m.blocks.filter((b) => b.row === '후열')[0]; expect(Math.round((front.top - front.bottom) * 1000)).toBe(164); expect(Math.round((back.top - back.bottom) * 1000)).toBe(139); }); it('a drawing row that is off by more than 5 mm is flagged', () => { const bad = drawing.map((d) => (d.no === 3 ? { ...d, elx: d.elx + 0.02 } : d)); const c = drawingCopingCheck(buildPier(loadP1()), bad).find((x) => x.no === 3)!; expect(c.ok).toBe(false); }); });