- Material {fck, fyH, fyS}, defaults 27 / 400 / 500 as assumed values (I02).
The rebar calculations take the material: the C7/C8 splice, the P2 development
length, the P3 lap, and the B2 split use it instead of fixed numbers.
- ③ screen: 공통 설정 inputs with a note that the defaults are assumed (I02).
- Project file stores the material as an optional field; older files open with
the defaults.
- Tests: fck 27 → 35 shortens the laps by √(27/35); the C7 piece follows fck;
a non-default fy drops I02; the file round trip.
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
76 lines
3.4 KiB
TypeScript
76 lines
3.4 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { buildPier } from '../src/core/geometry';
|
|
import { parseProject, serializeProject, SCHEMA_VERSION, type ProjectFile } from '../src/core/project';
|
|
import { loadP1 } from './helpers';
|
|
|
|
function sampleProject(): ProjectFile {
|
|
const p1 = loadP1();
|
|
// 20 piers: P1 plus 19 variants with different names and coping widths, so the file has a realistic size.
|
|
const piers = Array.from({ length: 20 }, (_, i) => {
|
|
const input = i === 0 ? p1 : { ...p1, name: `P${i + 1}`, copingWidthMm: 3100 + i * 10 };
|
|
return { id: `pier-${i + 1}`, input };
|
|
});
|
|
return {
|
|
schemaVersion: SCHEMA_VERSION,
|
|
project: { name: '운곡교 교각', bridge: '운곡교', client: '', author: '', crs: 'KATEC', memo: '' },
|
|
source: { fileName: '운곡교P1입력.xlsx', sheets: ['교각', 'IP', '받침'] },
|
|
piers,
|
|
history: [{ version: '0.1.00', note: '최초 저장', at: '2026-10-22T00:00:00Z' }],
|
|
};
|
|
}
|
|
|
|
describe('project file round trip (spec §8, plan B3)', () => {
|
|
it('save → open gives the same inputs, without the source workbook', () => {
|
|
const original = sampleProject();
|
|
const text = serializeProject(original);
|
|
const reopened = parseProject(text);
|
|
expect(reopened).toEqual(original);
|
|
});
|
|
|
|
it('regenerated models match the originals after reopening (20 piers)', () => {
|
|
const original = sampleProject();
|
|
const reopened = parseProject(serializeProject(original));
|
|
original.piers.forEach((p, i) => {
|
|
expect(buildPier(reopened.piers[i].input)).toEqual(buildPier(p.input));
|
|
});
|
|
});
|
|
|
|
it('refuses another schema version instead of loading it', () => {
|
|
const text = serializeProject({ ...sampleProject(), schemaVersion: 99 });
|
|
expect(() => parseProject(text)).toThrow('지원하지 않는 파일 버전');
|
|
});
|
|
|
|
it('refuses a damaged file and names the broken pier', () => {
|
|
const project = sampleProject();
|
|
const broken = { ...project, piers: [project.piers[0], { id: 'pier-2', input: null }] };
|
|
expect(() => parseProject(JSON.stringify(broken))).toThrow('교각 2');
|
|
expect(() => parseProject('{ not json')).toThrow('JSON');
|
|
});
|
|
|
|
it('keeps defaults and an unregenerated draft through save and open', () => {
|
|
const original = sampleProject();
|
|
const p1 = original.piers[0];
|
|
original.piers[0] = { ...p1, defaults: p1.input, draft: { ...p1.input, copingWidthMm: 3300 } };
|
|
const reopened = parseProject(serializeProject(original));
|
|
expect(reopened.piers[0].draft?.copingWidthMm).toBe(3300);
|
|
expect(reopened.piers[0].input.copingWidthMm).toBe(3100);
|
|
});
|
|
|
|
it('a file saved before change tracking (no defaults or draft) still opens', () => {
|
|
const legacy = sampleProject();
|
|
const text = JSON.stringify({ ...legacy, piers: legacy.piers.map((p) => ({ id: p.id, input: p.input })) });
|
|
const reopened = parseProject(text);
|
|
expect(reopened.piers[0].defaults).toBeUndefined();
|
|
expect(reopened.piers[0].draft).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe('③ 공통 설정 in the project file', () => {
|
|
it('fck and fy are kept through save and open; older files get the defaults through the app', () => {
|
|
const p = sampleProject();
|
|
const withCommon = { ...p, common: { fck: 35, fyH: 400, fyS: 500 } };
|
|
expect(parseProject(serializeProject(withCommon)).common).toEqual({ fck: 35, fyH: 400, fyS: 500 });
|
|
expect(parseProject(serializeProject(p)).common).toBeUndefined();
|
|
});
|
|
});
|