feat(core,view): input cards with change tracking (plan B1 · C2)
- Three values per pier: defaults (as imported), input (generated), draft (current cards). Overrides = draft vs defaults; pending = draft vs input. - Editable now: 코핑 폭, 코핑 길이, 말뚝 길이. Changing a card does not touch the 3D view until 다시 생성; the header and the card show 변경 n. - Revert puts a field back to its imported default. - Project files store defaults and draft (optional; v1 files still open). - Tests: 코핑 폭 3100 → 3300 gives one override and one pending change; regenerating clears pending but keeps the override; revert; file round trip. - Not verified in a browser (no debuggable Chrome in this session). Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f5303e4c2b
commit
0b62f694c5
7 files changed
+239
-9
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { buildPier } from '../src/core/geometry';
|
||||
import { overrideKeys, pendingKeys, revertDraft, type PierValues } from '../src/core/changes';
|
||||
import { loadP1 } from './helpers';
|
||||
|
||||
function fresh(): PierValues {
|
||||
const input = loadP1();
|
||||
return { defaults: input, input, draft: input };
|
||||
}
|
||||
|
||||
describe('input change tracking (plan B1 · C2)', () => {
|
||||
it('a new pier has no overrides and nothing pending', () => {
|
||||
const p = fresh();
|
||||
expect(overrideKeys(p)).toEqual([]);
|
||||
expect(pendingKeys(p)).toEqual([]);
|
||||
});
|
||||
|
||||
it('coping width 3100 → 3300: one override and one pending change', () => {
|
||||
const p = fresh();
|
||||
const next = { ...p, draft: { ...p.draft, copingWidthMm: 3300 } };
|
||||
expect(overrideKeys(next)).toEqual(['copingWidthMm']);
|
||||
expect(pendingKeys(next)).toEqual(['copingWidthMm']);
|
||||
});
|
||||
|
||||
it('regenerating clears the pending change but keeps the override', () => {
|
||||
const p = fresh();
|
||||
const edited = { ...p, draft: { ...p.draft, copingWidthMm: 3300 } };
|
||||
const regenerated: PierValues = { ...edited, input: edited.draft };
|
||||
expect(pendingKeys(regenerated)).toEqual([]);
|
||||
expect(overrideKeys(regenerated)).toEqual(['copingWidthMm']);
|
||||
expect(buildPier(regenerated.input).copingB).toBeCloseTo(3.3, 9);
|
||||
});
|
||||
|
||||
it('reverting to the default removes the override', () => {
|
||||
const p = fresh();
|
||||
const edited = { ...p, draft: { ...p.draft, copingWidthMm: 3300 } };
|
||||
const reverted = { ...edited, draft: revertDraft(edited, 'copingWidthMm') };
|
||||
expect(overrideKeys(reverted)).toEqual([]);
|
||||
// The draft is back to the generated value, so nothing is pending either.
|
||||
expect(pendingKeys(reverted)).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user