Files
Aislo/B07_DesignDetail/openwebcad/src/integration/guide-area.test.ts
T
eomsangdonandClaude Opus 5.5 a2c3c0fc1f fix(526-1): B07 횡단 장 인쇄 칸선 지움 · 칸마다 안내선 · 처음 맞춤 작도 영역까지
- 횡단 장 칸 격자선(도각 층 인쇄 개체) 지움 — 칸은 화면 안내선 겹판(guide.cells · 단면마다 점선)
  · 안내선 숨기기에 함께 꺼짐 · 넘친 칸 붉은 틀은 그대로
- 옛 확정 · 저장본 장은 열 때 칸선만 걷고 칸 안내선은 지금 배치로(refresh_saved_sheet)
- CAD 처음 맞춤 · 전체 맞춤 = 내용 + 작도 영역(가이드) — 표준 횡단도가 내용에만 확대돼
  도면 한 장 안 자리가 안 보이던 흠
- 낡은 시험 고침: test_169 칸선 단언 → 칸선 없음 + 칸 안내선 · test_212_3 「남는 검은 선 =
  인쇄 칸선 지우지 않음」(212-3 결정) → 요구 343-4 로 칸선 지움 · guide-area 시험 칸 그리기

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 14:39:18 +09:00

98 lines
3.4 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest';
import {
GUIDE_MIN_MM,
type GuideArea,
dragGuideArea,
drawGuide,
getGuide,
isGuideVisible,
pickGuideHandle,
setGuide,
setGuideArea,
setGuideVisible,
} from './guide-area.ts';
import type { ScreenCanvasDrawController } from '../drawControllers/screenCanvas.drawController.ts';
const AREA: GuideArea = [42, 47, 812, 567];
describe('작도 영역 가이드(169-1 · 169-3)', () => {
it('싣기 — 어긋난 영역은 가이드 없음 · 갈기는 가이드가 있을 때만', () => {
setGuide({ area: [10, 10, 5, 20] });
expect(getGuide()).toBeNull();
setGuideArea(AREA);
expect(getGuide()).toBeNull();
setGuide({
area: AREA,
marks: [[0, 0, 1, 1], 'x'],
cells: [
[0, 0, 2, 2],
[3, 3, 1, 1],
],
editable: true,
});
expect(getGuide()).toEqual({
area: AREA,
marks: [[0, 0, 1, 1]],
cells: [[0, 0, 2, 2]],
editable: true,
});
setGuideArea([0, 0, 100, 50]);
expect(getGuide()?.area).toEqual([0, 0, 100, 50]);
setGuide(null);
expect(getGuide()).toBeNull();
});
it('손잡이 — 모서리가 변보다 먼저 · 허용 거리 밖은 없음', () => {
expect(pickGuideHandle(AREA, { x: 812, y: 567 }, 2)).toBe('ne');
expect(pickGuideHandle(AREA, { x: 43, y: 46 }, 2)).toBe('sw');
expect(pickGuideHandle(AREA, { x: 400, y: 566 }, 2)).toBe('n');
expect(pickGuideHandle(AREA, { x: 811, y: 300 }, 2)).toBe('e');
expect(pickGuideHandle(AREA, { x: 400, y: 300 }, 2)).toBeNull();
expect(pickGuideHandle(AREA, { x: 900, y: 567 }, 2)).toBeNull();
});
it('끌기 — 반대편 그대로 · 0.1 mm 반올림 · 최소 크기', () => {
expect(dragGuideArea(AREA, 'ne', { x: 800.04, y: 560.06 })).toEqual([42, 47, 800, 560.1]);
expect(dragGuideArea(AREA, 'w', { x: 50, y: 0 })).toEqual([50, 47, 812, 567]);
expect(dragGuideArea(AREA, 's', { x: 0, y: 9999 })).toEqual([42, 567 - GUIDE_MIN_MM, 812, 567]);
expect(dragGuideArea(AREA, 'e', { x: -100, y: 0 })).toEqual([42, 47, 42 + GUIDE_MIN_MM, 567]);
});
it('안내선 보이기 / 숨기기(180-3) — 숨김이면 점선 영역 · 붉은 틀 안 그림 · 싣기를 거쳐도 이어짐', () => {
const lines = vi.fn();
const controller = {
setOpacity: vi.fn(),
setLineStyles: vi.fn(),
worldToTarget: (point: unknown) => point,
drawLineScreen: lines,
fillRectScreen: vi.fn(),
} as unknown as ScreenCanvasDrawController;
// 횡단 칸(526-1) 둘 — 단면마다 점선 4 변
const cells = [[0, 0, 5, 5] as GuideArea, [5, 0, 10, 5] as GuideArea];
const guide = { area: AREA, marks: [[0, 0, 5, 5] as GuideArea], cells, editable: false };
setGuide(guide);
expect(isGuideVisible()).toBe(true); // 기본 = 보임
drawGuide(controller);
expect(lines).toHaveBeenCalledTimes(16); // 점선 영역 4 변 + 칸 2 × 4 변 + 붉은 틀 4 변
setGuideVisible(false);
lines.mockClear();
drawGuide(controller);
expect(lines).not.toHaveBeenCalled();
setGuide(guide); // 장을 다시 실어도 숨김 유지
setGuideArea([0, 0, 100, 50]);
drawGuide(controller);
expect(isGuideVisible()).toBe(false);
expect(lines).not.toHaveBeenCalled();
expect(getGuide()?.marks).toHaveLength(1); // 값은 그대로 — 그리기만 거름
setGuideVisible(true);
drawGuide(controller);
expect(lines).toHaveBeenCalledTimes(16);
setGuideVisible('x'); // 어긋난 값 = 보임
expect(isGuideVisible()).toBe(true);
setGuide(null);
});
});