Files
Aislo/resources/tester/cad/fit-min-height.test.ts
T
eomsangdonandClaude Opus 5.5 5b993ddded fix(380-4): 글만 있는 상세 표 위 CAD 과확대 — 맞춤 최소 높이 곁값
- CAD 맞춤(fitView) = 범위를 위 끝에서 아래로 최소 높이까지 늘림 · 부모가 실을 때 fitMinHeight 로 보냄(안 보내면 종전 그대로)
- B06 상세 표 위 CAD = 16(원 마크 아래 끝 ~ 첫 줄 위) — 사토장 등 글만 있는 측점도 배관 측점과 같은 글 크기 · 둘째 줄 안 잘림
- 시험 resources/tester/cad/fit-min-height(종전 3배 넘는 확대 · 같은 배율 · 위 끝 같음 · 큰 범위 그대로)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VmC34fsxxbweEG3RUjs3Mn
2026-10-17 16:07:12 +09:00

47 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 380-4 맞춤 최소 높이 — 글만 있는 작은 도면(B06 상세 「표 위 CAD」 사토장 측점)이 칸 높이로 과확대되지 않음.
* 실행: cd B07_DesignDetail/openwebcad && npx vitest run --dir ../../resources/tester/cad fit-min-height
*/
import { Point } from '@flatten-js/core';
import { afterEach, describe, expect, it } from 'vitest';
import type { Entity } from '../../../B07_DesignDetail/openwebcad/src/entities/Entity';
import { fitView, setFitMinHeight } from '../../../B07_DesignDetail/openwebcad/src/drawControllers/fit-view';
const box = (xmin: number, ymin: number, xmax: number, ymax: number) =>
({ getBoundingBox: () => ({ xmin, ymin, xmax, ymax }) }) as unknown as Entity;
// 표 위 CAD 칸(가로로 긴 칸) · 원 마크 측점 = 원(−15.5 ~ −2.5) + 넉 줄 글(위 끝 +0.5)
const CANVAS = new Point(1500, 200);
const PIPE = [box(0, -15.5, 13, -2.5), box(15, -10.5, 60, 0.5)];
// 글만 있는 측점 = 두 줄(「NO.5」 · 「유용토운반작업장(사토장)」)
const TEXT_ONLY = [box(0, -4.5, 28, 0.5)];
afterEach(() => setFitMinHeight(undefined));
describe('맞춤 최소 높이(fitMinHeight)', () => {
it('안 보내면 종전 그대로 — 글만 있는 도면은 원 마크 측점보다 3배 넘게 확대', () => {
const pipe = fitView(PIPE, CANVAS).zoom;
const text = fitView(TEXT_ONLY, CANVAS).zoom;
expect(text / pipe).toBeGreaterThan(3);
});
it('16 을 보내면 글만 있는 측점도 원 마크 측점과 같은 배율 · 위 끝 그대로', () => {
setFitMinHeight(16);
const pipe = fitView(PIPE, CANVAS);
const text = fitView(TEXT_ONLY, CANVAS);
expect(text.zoom).toBeCloseTo(pipe.zoom, 6);
// 위 끝(+0.5)이 같은 화면 높이 — 화면 위 끝 월드 y = offset.y + 칸 높이 / 배율
const top = (view: { zoom: number; offset: Point }) => view.offset.y + CANVAS.y / view.zoom;
expect(top(text)).toBeCloseTo(top(pipe), 6);
});
it('범위가 최소 높이보다 크면 그대로 · 숫자 아니면 0', () => {
setFitMinHeight(16);
const tall = [box(0, -40, 50, 0.5)];
const zoom = fitView(tall, CANVAS).zoom;
setFitMinHeight('16');
expect(fitView(tall, CANVAS).zoom).toBeCloseTo(zoom, 6);
expect(fitView(TEXT_ONLY, CANVAS).zoom).toBeGreaterThan(fitView(PIPE, CANVAS).zoom * 3);
});
});