[119] Merge: Referenz-Ausgaben (golden) für Grundriss, Schnitt, Ansicht, 3D der Musterprojekte
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
21 files changed
+337
-2
No files matched your search
@@ -14,6 +14,7 @@ Anzeige nur über die zwei Rust-Engines `render2d` und `render3d` (WebGPU/Metal)
|
||||
ansehen") — Zahlen allein reichen nicht.
|
||||
5. **Abschliessen:** kleine Commits, Nachricht deutsch, beginnt mit den IDs (`[63] Baurecht: …`), ohne
|
||||
Co-Authored-By-Zeile. `TODO.md` im selben Commit nachführen (Stand + Datum + was offen bleibt).
|
||||
Gewollte Änderung an Plan/Schnitt/Ansicht/3D: `npx vitest run -u src/plan/golden.test.ts`, Diff in `src/plan/__golden__` im Commit prüfen ([119]).
|
||||
6. **Ehrlich berichten:** was geprüft wurde und was nicht (z. B. „nicht in der Tauri-App getestet").
|
||||
|
||||
```
|
||||
|
||||
@@ -1051,8 +1051,9 @@ Prüfung des ganzen Programms (Rust-Kern, TS-Hülle, Build/Sicherheit), nur Code
|
||||
`connect-src` = netFetch-Hosts + ipc). Rich-Text-`innerHTML` prüfen. · S
|
||||
- ○ **[118] Wiederanlauf nach Kern-Panic.** Dokument + Verlauf im selben WASM wie alle Geometrie
|
||||
(`web/document.rs`); TS hält Op-Log seit letztem Laden, baut Instanz nach Trap neu auf. · M
|
||||
- ○ **[119] Referenz-Ausgaben (golden).** Plan-Puffer/SVG/Schnitt/Ansicht der Musterprojekte als Snapshot;
|
||||
seit TS gelöscht ist, fehlt die Bitgleich-Referenz. · M
|
||||
- ✅ **[119] Referenz-Ausgaben (golden).** 3.11.: `src/plan/golden.test.ts` — beide Musterprojekte: Grundriss je Geschoss
|
||||
(1:100, 1:50), Schnitt, Ansicht, 3D-Zusammenfassung als Digest (Zähler, Rahmen, Hash gerundeter Zahlen) in
|
||||
`src/plan/__golden__/`; Update mit `vitest -u`. Nur Linux geprüft; Hash deckt Detailabweichungen ab, Diff zeigt nur Zähler. · M
|
||||
- ○ **[120] macOS in CI.** `cargo check --features native2d`, Bildvergleich Metal ↔ WebGPU. · M
|
||||
- ○ **[121] App.tsx zerlegen, Neurendern stoppen.** `App.tsx:365` abonniert ganzes Projekt, 0× `memo`;
|
||||
Abschnitte in Hooks/Komponenten, Panels lesen den Store selbst; Nebenfenster bekommen Ops statt Projekt. · L
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
viewBox -4.2 0 37.045 17.778
|
||||
bytes 344306
|
||||
circle 4
|
||||
line 1261
|
||||
polygon 1529
|
||||
rect 1
|
||||
svg 1
|
||||
text 4
|
||||
hash ac47902c2752e848
|
||||
@@ -0,0 +1,10 @@
|
||||
viewBox -16.5 0 49 35.22
|
||||
bytes 339680
|
||||
circle 14
|
||||
line 3498
|
||||
path 8
|
||||
polygon 91
|
||||
rect 1
|
||||
svg 1
|
||||
text 36
|
||||
hash 30888ca0d5cb84be
|
||||
@@ -0,0 +1,10 @@
|
||||
viewBox -16.5 0 49 35.22
|
||||
bytes 343059
|
||||
circle 14
|
||||
line 3498
|
||||
path 8
|
||||
polygon 91
|
||||
rect 1
|
||||
svg 1
|
||||
text 36
|
||||
hash f96ebde7ba7f7e74
|
||||
@@ -0,0 +1,10 @@
|
||||
viewBox -41.5 0 95 63.6
|
||||
bytes 148973
|
||||
circle 16
|
||||
line 861
|
||||
path 68
|
||||
polygon 260
|
||||
rect 1
|
||||
svg 1
|
||||
text 123
|
||||
hash aefdd0fe3c4658bd
|
||||
@@ -0,0 +1,10 @@
|
||||
viewBox -41.5 0 95 63.6
|
||||
bytes 149368
|
||||
circle 16
|
||||
line 861
|
||||
path 68
|
||||
polygon 260
|
||||
rect 1
|
||||
svg 1
|
||||
text 123
|
||||
hash 65c62fa0ef5ee339
|
||||
@@ -0,0 +1,10 @@
|
||||
viewBox -16.5 0 49 35.22
|
||||
bytes 425217
|
||||
circle 14
|
||||
line 4040
|
||||
path 40
|
||||
polygon 236
|
||||
rect 1
|
||||
svg 1
|
||||
text 93
|
||||
hash 961473ba9c3e6937
|
||||
@@ -0,0 +1,10 @@
|
||||
viewBox -16.5 0 49 35.22
|
||||
bytes 428731
|
||||
circle 14
|
||||
line 4040
|
||||
path 40
|
||||
polygon 236
|
||||
rect 1
|
||||
svg 1
|
||||
text 93
|
||||
hash 6f37dfa59b4e84a0
|
||||
@@ -0,0 +1,10 @@
|
||||
viewBox -16.5 0 49 38.11
|
||||
bytes 86366
|
||||
circle 14
|
||||
line 501
|
||||
path 29
|
||||
polygon 113
|
||||
rect 1
|
||||
svg 1
|
||||
text 74
|
||||
hash cd3c20b2431eec2e
|
||||
@@ -0,0 +1,10 @@
|
||||
viewBox -16.5 0 49 38.11
|
||||
bytes 86522
|
||||
circle 14
|
||||
line 501
|
||||
path 29
|
||||
polygon 113
|
||||
rect 1
|
||||
svg 1
|
||||
text 74
|
||||
hash 53435c6a8ca1a431
|
||||
@@ -0,0 +1,53 @@
|
||||
meshes [1849]
|
||||
meshes[].color [3] x1849
|
||||
meshes[].indices [108] x6
|
||||
meshes[].indices [156648]
|
||||
meshes[].indices [348] x6
|
||||
meshes[].indices [36] x1816
|
||||
meshes[].indices [372]
|
||||
meshes[].indices [4032]
|
||||
meshes[].indices [60] x9
|
||||
meshes[].indices [72]
|
||||
meshes[].indices [84] x2
|
||||
meshes[].indices [96] x6
|
||||
meshes[].positions [1044] x6
|
||||
meshes[].positions [108] x30
|
||||
meshes[].positions [180] x9
|
||||
meshes[].positions [192]
|
||||
meshes[].positions [216]
|
||||
meshes[].positions [24] x1781
|
||||
meshes[].positions [252] x2
|
||||
meshes[].positions [2688]
|
||||
meshes[].positions [288] x6
|
||||
meshes[].positions [324] x6
|
||||
meshes[].positions [72] x5
|
||||
meshes[].positions [78840]
|
||||
roofLayers [59]
|
||||
roofLayers[].color [3] x59
|
||||
roofLayers[].normal [3] x59
|
||||
roofLayers[].polygon [4] x53
|
||||
roofLayers[].polygon [5] x6
|
||||
roofLayers[].polygon[] [3] x242
|
||||
slabs [102]
|
||||
slabs[].color [3] x102
|
||||
slabs[].outline [12]
|
||||
slabs[].outline [14] x5
|
||||
slabs[].outline [21] x4
|
||||
slabs[].outline [24]
|
||||
slabs[].outline [33] x5
|
||||
slabs[].outline [4] x81
|
||||
slabs[].outline [51] x5
|
||||
slabs[].outline[] [2] x934
|
||||
walls [1508]
|
||||
walls[].color [3] x1508
|
||||
walls[].end [2] x1508
|
||||
walls[].endCut [4] x1139
|
||||
walls[].holes [1] x84
|
||||
walls[].holes [2] x25
|
||||
walls[].holes [3] x14
|
||||
walls[].layers [0] x1508
|
||||
walls[].start [2] x1508
|
||||
walls[].startCut [4] x1137
|
||||
walls[].topDrop [2] x112
|
||||
walls[].topPlane [3] x268
|
||||
hash cd9596786d4adacb
|
||||
@@ -0,0 +1,9 @@
|
||||
viewBox 4.457 0 21.343 17.778
|
||||
bytes 44167
|
||||
circle 3
|
||||
line 148
|
||||
polygon 169
|
||||
rect 1
|
||||
svg 1
|
||||
text 3
|
||||
hash 3310ddbc4a0ea666
|
||||
@@ -0,0 +1,7 @@
|
||||
viewBox 0.1 0 6.8 7.586
|
||||
bytes 8483
|
||||
line 31
|
||||
polygon 42
|
||||
rect 1
|
||||
svg 1
|
||||
hash c9caba6eee20fbd9
|
||||
@@ -0,0 +1,9 @@
|
||||
viewBox -0.672 0 6.345 5.345
|
||||
bytes 15919
|
||||
line 67
|
||||
path 8
|
||||
polygon 61
|
||||
rect 1
|
||||
svg 1
|
||||
text 7
|
||||
hash 97bd11bea3bf9d08
|
||||
@@ -0,0 +1,9 @@
|
||||
viewBox -0.672 0 6.345 5.345
|
||||
bytes 15939
|
||||
line 67
|
||||
path 8
|
||||
polygon 61
|
||||
rect 1
|
||||
svg 1
|
||||
text 7
|
||||
hash 7dfca568eb0b0d41
|
||||
@@ -0,0 +1,9 @@
|
||||
viewBox -0.9 0 6.8 5.8
|
||||
bytes 7180
|
||||
line 35
|
||||
path 4
|
||||
polygon 23
|
||||
rect 1
|
||||
svg 1
|
||||
text 4
|
||||
hash 5b480a1ff81665ec
|
||||
@@ -0,0 +1,9 @@
|
||||
viewBox -0.9 0 6.8 5.8
|
||||
bytes 7202
|
||||
line 35
|
||||
path 4
|
||||
polygon 23
|
||||
rect 1
|
||||
svg 1
|
||||
text 4
|
||||
hash f1c8c391382719b8
|
||||
@@ -0,0 +1,31 @@
|
||||
meshes [44]
|
||||
meshes[].color [3] x44
|
||||
meshes[].indices [36] x42
|
||||
meshes[].indices [540]
|
||||
meshes[].indices [60]
|
||||
meshes[].positions [120]
|
||||
meshes[].positions [24] x42
|
||||
meshes[].positions [360]
|
||||
roofLayers [2]
|
||||
roofLayers[].color [3] x2
|
||||
roofLayers[].normal [3] x2
|
||||
roofLayers[].polygon [4] x2
|
||||
roofLayers[].polygon[] [3] x8
|
||||
slabs [3]
|
||||
slabs[].color [3] x3
|
||||
slabs[].cut.lineColor [3]
|
||||
slabs[].outline [4] x3
|
||||
slabs[].outline[] [2] x12
|
||||
walls [47]
|
||||
walls[].color [3] x47
|
||||
walls[].cut.lineColor [3] x11
|
||||
walls[].end [2] x47
|
||||
walls[].endCut [4] x47
|
||||
walls[].holes [1] x5
|
||||
walls[].holes [2] x5
|
||||
walls[].layers [0] x47
|
||||
walls[].start [2] x47
|
||||
walls[].startCut [4] x47
|
||||
walls[].topDrop [2] x6
|
||||
walls[].topPlane [3] x6
|
||||
hash 43431f51d1e44e8b
|
||||
@@ -0,0 +1,7 @@
|
||||
viewBox 0.1 0 6.8 7.586
|
||||
bytes 7242
|
||||
line 31
|
||||
polygon 31
|
||||
rect 1
|
||||
svg 1
|
||||
hash 64ff798e38d40dd0
|
||||
@@ -0,0 +1,101 @@
|
||||
// [119] Referenz-Ausgaben: Plan (je Geschoss, 1:100 und 1:50), ein Schnitt, eine Ansicht und die
|
||||
// 3D-Zusammenfassung beider Musterprojekte als lesbarer Digest (Zähler, Rahmen, Hash der gerundeten
|
||||
// Zahlen) gegen eingecheckte Dateien in src/plan/__golden__. Gewollte Änderung übernehmen mit
|
||||
// npx vitest run -u src/plan/golden.test.ts
|
||||
// und den Diff der Dateien im Commit ansehen. Zahlen sind gerundet (Plan 1e-3 m, 3D 1e-4 m).
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createHash } from "node:crypto";
|
||||
import { computeSection, generateElevationPlan, generatePlan, generateSectionPlan, planToSvgString, projectToModel3d } from "../core";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
|
||||
import type { Project } from "../model/types";
|
||||
|
||||
const roundNums = (s: string, dec: number): string =>
|
||||
s.replace(/-?\d+\.\d+(?:e-?\d+)?/g, (m) => {
|
||||
const v = Number(Number(m).toFixed(dec));
|
||||
return String(Object.is(v, -0) ? 0 : v);
|
||||
});
|
||||
const sha = (s: string): string => createHash("sha256").update(s).digest("hex").slice(0, 16);
|
||||
|
||||
function svgDigest(svg: string): string {
|
||||
const s = roundNums(svg, 3);
|
||||
const tags = new Map<string, number>();
|
||||
for (const m of s.matchAll(/<([a-z]+)\b/g)) tags.set(m[1], (tags.get(m[1]) ?? 0) + 1);
|
||||
const viewBox = /viewBox="([^"]*)"/.exec(s)?.[1] ?? "-";
|
||||
const lines = [`viewBox ${viewBox}`, `bytes ${s.length}`];
|
||||
for (const [k, v] of [...tags].sort()) lines.push(`${k} ${v}`);
|
||||
lines.push(`hash ${sha(s)}`);
|
||||
return lines.join("\n") + "\n";
|
||||
}
|
||||
|
||||
// Beliebige Struktur → Zähler je Feld (Länge von Listen/Puffern) + Hash der gerundeten Zahlen.
|
||||
function structDigest(o: unknown): string {
|
||||
const lines: string[] = [];
|
||||
const h = createHash("sha256");
|
||||
const walk = (v: unknown, path: string): void => {
|
||||
if (typeof v === "number") {
|
||||
h.update(path + "=" + Number(v.toFixed(4)) + ";");
|
||||
} else if (ArrayBuffer.isView(v)) {
|
||||
const a = Array.from(v as unknown as ArrayLike<number>);
|
||||
lines.push(`${path} [${a.length}]`);
|
||||
h.update(path + ":" + a.map((x) => Number(x.toFixed(4))).join(",") + ";");
|
||||
} else if (Array.isArray(v)) {
|
||||
lines.push(`${path} [${v.length}]`);
|
||||
v.forEach((x, i) => walk(x, `${path}[${i}]`));
|
||||
} else if (v && typeof v === "object") {
|
||||
for (const k of Object.keys(v).sort()) walk((v as Record<string, unknown>)[k], path ? `${path}.${k}` : k);
|
||||
} else {
|
||||
h.update(path + "=" + String(v) + ";");
|
||||
}
|
||||
};
|
||||
walk(o, "");
|
||||
// Elementweise Pfade (mit Index) nur im Hash, im Text nur die Feldzähler ohne Index
|
||||
const counts = new Map<string, number>();
|
||||
for (const l of lines) {
|
||||
const key = l.replace(/\[\d+\](?=[. ])/g, "[]");
|
||||
counts.set(key, (counts.get(key) ?? 0) + 1);
|
||||
}
|
||||
return [...counts].sort().map(([k, n]) => `${k}${n > 1 ? ` x${n}` : ""}`).join("\n") + `\nhash ${h.digest("hex").slice(0, 16)}\n`;
|
||||
}
|
||||
|
||||
const projects: [string, () => Project][] = [
|
||||
["muster", () => sampleProject],
|
||||
["komplex", buildComplexSampleProject],
|
||||
];
|
||||
|
||||
for (const [name, make] of projects) {
|
||||
describe(`Golden ${name}`, () => {
|
||||
const p = make();
|
||||
const codes = new Set(p.layers.map((l) => l.code));
|
||||
|
||||
for (const lvl of p.drawingLevels.filter((l) => l.kind === "floor")) {
|
||||
for (const scale of [100, 50]) {
|
||||
it(`Grundriss ${lvl.id} 1:${scale}`, async () => {
|
||||
const svg = planToSvgString(generatePlan(p, lvl.id, codes, undefined, "mittel", false, false, true, scale), { scaleDenominator: scale });
|
||||
await expect(svgDigest(svg)).toMatchFileSnapshot(`__golden__/${name}-grundriss-${lvl.id}-${scale}.txt`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
it("Schnitt", async () => {
|
||||
const sec = p.drawingLevels.find((l) => l.kind === "section");
|
||||
if (!sec) return;
|
||||
const out = await computeSection(p, sec);
|
||||
expect(out).toBeTruthy();
|
||||
const svg = planToSvgString(generateSectionPlan(out!, false, { visibleCodes: codes, hiddenLines: sec.hiddenLines, openings: true, scaleDenominator: 100 }), { scaleDenominator: 100 });
|
||||
await expect(svgDigest(svg)).toMatchFileSnapshot(`__golden__/${name}-schnitt-${sec.id}.txt`);
|
||||
}, 30_000);
|
||||
|
||||
it("Ansicht", async () => {
|
||||
const el = p.drawingLevels.find((l) => l.kind === "elevation");
|
||||
if (!el) return;
|
||||
const plan = generateElevationPlan(p, el, { scaleDenominator: 100 });
|
||||
expect(plan).toBeTruthy();
|
||||
await expect(svgDigest(planToSvgString(plan!, { scaleDenominator: 100 }))).toMatchFileSnapshot(`__golden__/${name}-ansicht-${el.id}.txt`);
|
||||
});
|
||||
|
||||
it("3D-Modell", async () => {
|
||||
await expect(structDigest(projectToModel3d(p))).toMatchFileSnapshot(`__golden__/${name}-model3d.txt`);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user