[143] Baugrube erstellen: Tests (vitest, e2e Musterhaus komplex und leeres Projekt), TODO
This commit is contained in:
3 files changed
+251
No files matched your search
@@ -2607,6 +2607,24 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]).
|
||||
„robust"/„Lösung"/„nicht nur" (Textprüfung des Pakets gilt bisher nur für die Startseite). Bilder der Fenster- und
|
||||
Türliste: das SVG von `schedule --openings --format svg` überlappt Spalten (Textbreiten), darum zeigt die Startseite dort
|
||||
einen Grundriss-Ausschnitt. Englisch: `[languages.en]`, `content.en/`. Mac-Screenshots (Metal, echtes 3D). · M
|
||||
- ◐ **[143] Baugrube erstellen.** (5.11., Mac-Befund „Die Baugrube lässt sich gar nicht erstellen“) Nachgestellt im
|
||||
Browser-Build (Musterhaus komplex, leeres Projekt). **Ursachen:** (1) der Befehl legte die Baugrube in Kategorie „02
|
||||
Gelände“ an — in den Grundriss-Ausschnitten/-Blättern (Vorlage blendet 02 aus) war sie unsichtbar; (2) die Sohle las
|
||||
eine Liste `floors`, die es im Projekt nicht gibt (Geschosse = `drawingLevels`): Sohle immer −0.30, am Hang über dem
|
||||
Gelände → nur Aufschüttung; (3) ohne Gelände, ausserhalb des Geländes oder in Schnitt/Ansicht/Blatt (floorOnly)
|
||||
geschah still nichts; (4) Befehl `terrain` wartete auf eine Eingabe und schluckte die nächsten getippten Befehle;
|
||||
(5) Gelände in m ü. M. ohne Höhenbezug: Sohle −0.30 gegen ≈ 500 m Gelände. **Neu** (Kern `cmd_solid.rs`): eigene
|
||||
Kategorie „07 Baugrube“ (unter „05 Kontext“, wird bei Bedarf angelegt, `import_context.rs`/`contextCategories.ts`),
|
||||
Sohle = tiefstes Geschoss − 0.30; Abfrage `excavationCheck` (Gelände da, Umriss über Gelände, Abtrag ja/nein,
|
||||
neuer Bezug); liegt das Gelände in m ü. M. (Median > 100 m) und fehlt `referenceElevationMasl`, setzt derselbe
|
||||
Undo-Schritt ±0.00 auf die Geländehöhe im Umriss. Befehls-Engine: `Command.precondition`, `CommandResult.notice`
|
||||
(Toast mit Platzhaltern), Hinweis bei floorOnly ohne Geschoss; `terrain` läuft sofort (`autoRun`). Tests: Rust
|
||||
(Sohle, Prüfung, Höhenbezug, Kategorie), vitest `commands/cmds/excavation.test.ts`, e2e `e2e/excavation.spec.ts`
|
||||
(Musterhaus komplex im Ausschnitt EG 1:100: Panel-Knopf, Linien im Grundriss, Undo; leeres Projekt ohne Gelände:
|
||||
Hinweise; leeres Projekt mit Höhenlinien in m ü. M.: Gelände erzeugen, Baugrube, ±0.00, Abtrag, Undo). Geprüft im
|
||||
Linux-Container (Chromium, SVG-Plan), nicht in der Tauri-App/Metal; Schnitt/3D nur über die bestehenden Rust-Tests.
|
||||
Offen: DXF-Höhenlinien landen als 2D-Zeichnung statt als `contourSet` (im leeren Projekt ohne Netz kein Weg zu
|
||||
„Gelände erzeugen“ ausser Standort-Import); Option „Baugrube aus Gebäudegrundfläche“.
|
||||
- ◐ **[137] Alles Sichtbare anwählbar.** (5.11., Mac-Befund am Musterhaus komplex: „Schatten und gewachsenes Terrain lassen sich
|
||||
nicht anwählen und bearbeiten") **Bestand** (Klick im Plan / im 3D, Objekt-Info, Bearbeiten; vorher → jetzt):
|
||||
| Element | Grundriss | Schnitt/Ansicht | 3D | Objekt-Info / Bearbeiten |
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
// [143] Baugrube erstellen wie ein Nutzer (Mac-Befund 5.11.: „Die Baugrube lässt sich gar nicht erstellen"):
|
||||
// Befehl/Panel-Knopf, Umriss tippen, Enter. Geprüft: Hinweis (Toast), Eintrag im Panel „Gelände", Linien der
|
||||
// Baugrube im Grundriss (Farbe EXCAVATION_INK, `plan/context.rs`), Schnitt mit Gelände, Rückgängig entfernt sie.
|
||||
// Ursachen vorher: Kategorie „02 Gelände" (in Grundrissen oft ausgeblendet → Baugrube unsichtbar), Sohle immer
|
||||
// −0.30 (las eine Liste `floors`, die es nicht gibt), ohne Gelände stilles Nichts.
|
||||
import type { Page } from "@playwright/test";
|
||||
import { blurFocus, commandInput, discardIfAsked, expect, fileMenu, openTab, showSnapshot, startNewProject, test, typeCommand } from "./app";
|
||||
|
||||
const ink = (page: Page) => page.locator('svg.plan-svg [stroke="#1f242c"]').count();
|
||||
const toast = (page: Page) => page.locator(".toast-message");
|
||||
const sitePanel = (page: Page) => page.locator(".site-panel");
|
||||
|
||||
async function drawExcavation(page: Page, pts: string[]): Promise<void> {
|
||||
await commandInput(page).focus();
|
||||
for (const p of pts) await typeCommand(page, p);
|
||||
await commandInput(page).press("Enter");
|
||||
await expect(page.locator(".cmdline-prompt")).toHaveText("Befehl:");
|
||||
}
|
||||
|
||||
test("Musterhaus komplex: Baugrube per Panel-Knopf im Ausschnitt EG 1:100, sichtbar im Grundriss, Rückgängig", async ({ page }) => {
|
||||
test.setTimeout(120_000);
|
||||
await startNewProject(page);
|
||||
await fileMenu(page, /Musterhaus \(komplex\)/);
|
||||
await discardIfAsked(page);
|
||||
await expect(page.locator(".project-name")).toHaveText("Musterhaus komplex", { timeout: 30_000 });
|
||||
await expect(page.locator("svg.plan-svg").first()).toBeVisible({ timeout: 30_000 });
|
||||
// Ausschnitt „EG 1:100" (Grundriss-Vorlage: Gelände „02" ausgeblendet — dort war eine neue Baugrube unsichtbar).
|
||||
await showSnapshot(page, "EG 1:100");
|
||||
await openTab(page, "Ebenen");
|
||||
await expect(page.getByRole("button", { name: /^Gelände sichtbar$/ })).toHaveAttribute("title", "Einblenden");
|
||||
// Ganzen Plan zeigen (das SVG enthält nur, was im Bild liegt).
|
||||
await page.locator('[title="Auf Plan einpassen"]').first().click();
|
||||
await expect.poll(() => ink(page), { timeout: 30_000 }).toBeGreaterThan(0);
|
||||
const before = await ink(page);
|
||||
|
||||
await openTab(page, "Gelände");
|
||||
await page.getByRole("button", { name: "Baugrube zeichnen" }).click();
|
||||
await expect(page.locator(".cmdline-prompt")).toHaveText("Erster Punkt der Baugrubensohle:");
|
||||
await drawExcavation(page, ["-25,-10", "-12,-10", "-12,0", "-25,0"]);
|
||||
|
||||
await expect(toast(page).filter({ hasText: /Baugrube angelegt: Sohle −3\.00 m/ })).toBeVisible();
|
||||
await expect(sitePanel(page)).toContainText("Baugrube 2");
|
||||
// Im Erdgeschoss-Grundriss sichtbar (Gelände „02" ist dort ausgeblendet, die Baugrube „07" nicht).
|
||||
await expect.poll(() => ink(page)).toBeGreaterThan(before);
|
||||
|
||||
// Rückgängig: weg aus Panel und Plan.
|
||||
await blurFocus(page);
|
||||
await page.keyboard.press("Control+z");
|
||||
await expect(sitePanel(page)).not.toContainText("Baugrube 2");
|
||||
await expect.poll(() => ink(page)).toBe(before);
|
||||
});
|
||||
|
||||
test("Leeres Projekt ohne Gelände: klarer Hinweis statt stillem Nichts", async ({ page }) => {
|
||||
await startNewProject(page);
|
||||
await commandInput(page).focus();
|
||||
await typeCommand(page, "baugrube");
|
||||
await expect(toast(page).filter({ hasText: "Baugrube braucht ein Gelände" })).toBeVisible();
|
||||
await expect(page.locator(".cmdline-prompt")).toHaveText("Befehl:");
|
||||
await typeCommand(page, "terrain");
|
||||
await expect(toast(page).filter({ hasText: "Kein Gelände erzeugt" })).toBeVisible();
|
||||
await expect(page.locator(".cmdline-prompt")).toHaveText("Befehl:");
|
||||
});
|
||||
|
||||
test("Leeres Projekt mit Gelände in m ü. M.: Gelände erzeugen, Baugrube, ±0.00 angenommen, Rückgängig", async ({ page }) => {
|
||||
test.setTimeout(90_000);
|
||||
await startNewProject(page);
|
||||
// Projekt mit Höhenlinien (Hang 500–512 m ü. M., kein Höhenbezug) speichern und wieder öffnen.
|
||||
const pending = page.waitForEvent("download");
|
||||
await fileMenu(page, "Projekt speichern");
|
||||
const dl = await pending;
|
||||
const { readFile } = await import("node:fs/promises");
|
||||
const json = JSON.parse((await readFile((await dl.path())!)).toString("utf8"));
|
||||
const contours = [];
|
||||
for (let i = 0; i <= 12; i++) {
|
||||
const y = -30 + i * 5;
|
||||
contours.push({ z: 500 + i, pts: [-40, -20, 0, 20, 40].map((x) => ({ x, y: y + x * 0.02 })), closed: false, layer: "HL" });
|
||||
}
|
||||
json.context = [{ type: "contourSet", id: "hl", name: "Höhenlinien", layer: "Terrain", categoryCode: "14", contours }];
|
||||
json.name = "Hang";
|
||||
const chooser = page.waitForEvent("filechooser");
|
||||
await fileMenu(page, "Projekt öffnen");
|
||||
await (await chooser).setFiles({ name: "hang.obp", mimeType: "application/json", buffer: Buffer.from(JSON.stringify(json)) });
|
||||
await discardIfAsked(page);
|
||||
await expect(page.locator(".project-name")).toHaveText("Hang", { timeout: 10_000 });
|
||||
|
||||
await openTab(page, "Gelände");
|
||||
await page.getByRole("button", { name: "Gelände erzeugen" }).click();
|
||||
await expect(page.getByRole("button", { name: "Baugrube zeichnen" })).toBeVisible();
|
||||
const before = await ink(page);
|
||||
await page.getByRole("button", { name: "Baugrube zeichnen" }).click();
|
||||
await drawExcavation(page, ["-6,-5", "6,5"]); // 2 Punkte = Rechteck
|
||||
await expect(toast(page).filter({ hasText: /±0\.00 = 50\d\.\d\d m ü\. M\. angenommen/ })).toBeVisible();
|
||||
await expect(sitePanel(page)).toContainText("Baugrube 1");
|
||||
await expect(sitePanel(page)).toContainText(/Abtrag [1-9]/);
|
||||
await expect.poll(() => ink(page)).toBeGreaterThan(before);
|
||||
|
||||
await blurFocus(page);
|
||||
await page.keyboard.press("Control+z");
|
||||
await expect(sitePanel(page)).not.toContainText("Baugrube 1");
|
||||
});
|
||||
@@ -0,0 +1,133 @@
|
||||
// [143] Baugrube erstellen: Voraussetzung Gelände, Anlegen im Musterhaus komplex (Sohle unter dem UG, Kategorie
|
||||
// „07 Baugrube", sichtbar im Grundriss), Hinweise statt stillem Scheitern, Engine meldet blockierte Befehle.
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildComplexSampleProject } from "../../model/sampleProjectComplex";
|
||||
import { sampleProject } from "../../model/sampleProject";
|
||||
import type { Project } from "../../model/types";
|
||||
import { CommandEngine, type EngineHost } from "../engine";
|
||||
import type { Command, CommandContext, CommandResult, CmdInput } from "../types";
|
||||
import { excavationCommand } from "./excavation";
|
||||
import { terrainCommand } from "./terrain";
|
||||
import { flattenCategories } from "../../model/layers";
|
||||
|
||||
const complex = buildComplexSampleProject();
|
||||
|
||||
function ctxOf(p: Project, levelId?: string): CommandContext {
|
||||
const level = p.drawingLevels.find((l) => (levelId ? l.id === levelId : l.kind === "floor"))!;
|
||||
return {
|
||||
project: p,
|
||||
level,
|
||||
defaultCategoryCode: p.layers[0].code,
|
||||
activeLineStyleId: "solid",
|
||||
activeWallTypeId: p.wallTypes[0]?.id ?? "",
|
||||
lastPoint: null,
|
||||
selection: { wallIds: [], drawingId: null, drawingIds: [] } as unknown as CommandContext["selection"],
|
||||
};
|
||||
}
|
||||
|
||||
/** Umriss klicken und mit Enter abschliessen; liefert das letzte Ergebnis. */
|
||||
function draw(cmd: Command, ctx: CommandContext, pts: [number, number][]): CommandResult {
|
||||
let st = cmd.init();
|
||||
for (const [x, y] of pts) st = cmd.onInput(st, { kind: "point", point: { x, y } } as CmdInput, ctx)[0];
|
||||
return cmd.onConfirm(st, ctx)[1];
|
||||
}
|
||||
|
||||
const excavations = (p: Project) => (p.context ?? []).filter((o) => o.type === "excavation");
|
||||
|
||||
describe("[143] Baugrube erstellen", () => {
|
||||
it("ohne Gelände startet der Befehl nicht (Hinweis)", () => {
|
||||
expect(excavationCommand.precondition?.(ctxOf(sampleProject))).toBe("cmd.excavation.noTerrain");
|
||||
expect(excavationCommand.precondition?.(ctxOf(complex, "eg"))).toBeNull();
|
||||
});
|
||||
|
||||
it("Musterhaus komplex, im EG gezeichnet: Sohle unter dem UG, Kategorie 07, Hinweis", () => {
|
||||
const ctx = ctxOf(complex, "eg");
|
||||
const res = draw(excavationCommand, ctx, [
|
||||
[-25, -10],
|
||||
[-12, -10],
|
||||
[-12, 0],
|
||||
[-25, 0],
|
||||
]);
|
||||
expect(res.done).toBe(true);
|
||||
expect(res.commit).toBeDefined();
|
||||
expect(res.notice?.key).toMatch(/^cmd\.excavation\.(created|fillOnly)$/);
|
||||
const out = res.commit!(complex);
|
||||
const added = excavations(out).filter((e) => !excavations(complex).some((o) => o.id === e.id));
|
||||
expect(added).toHaveLength(1);
|
||||
const ug = complex.drawingLevels.find((l) => l.id === "ug")!;
|
||||
expect(added[0]).toMatchObject({ categoryCode: "07", bottom: expect.closeTo((ug.baseElevation ?? 0) - 0.3, 6) });
|
||||
// Kategorie existiert (im Musterhaus schon vorhanden) und ist sichtbar.
|
||||
expect(flattenCategories(out.layers).find((c) => c.code === "07")?.visible).toBe(true);
|
||||
});
|
||||
|
||||
it("2 Punkte = Rechteck; ausserhalb des Geländes / entartet: nichts, mit Hinweis", () => {
|
||||
const ctx = ctxOf(complex, "eg");
|
||||
const rect = draw(excavationCommand, ctx, [
|
||||
[-25, -10],
|
||||
[-12, 0],
|
||||
]);
|
||||
expect(rect.commit).toBeDefined();
|
||||
const far = draw(excavationCommand, ctx, [
|
||||
[5000, 5000],
|
||||
[5010, 5010],
|
||||
]);
|
||||
expect(far.commit).toBeUndefined();
|
||||
expect(far.notice?.key).toBe("cmd.excavation.outside");
|
||||
const flat = draw(excavationCommand, ctx, [
|
||||
[0, 0],
|
||||
[5, 0],
|
||||
[10, 0],
|
||||
]);
|
||||
expect(flat.commit).toBeUndefined();
|
||||
expect(flat.notice?.key).toBe("cmd.excavation.degenerate");
|
||||
});
|
||||
|
||||
it("neues Projekt ohne Kategorie 07: der Befehl legt sie sichtbar an", () => {
|
||||
const p: Project = {
|
||||
...complex,
|
||||
layers: complex.layers.map((l) => ({ ...l, children: l.children?.filter((c) => c.code !== "07") })).filter((l) => l.code !== "07"),
|
||||
};
|
||||
expect(flattenCategories(p.layers).some((c) => c.code === "07")).toBe(false);
|
||||
const res = draw(excavationCommand, ctxOf(p, "eg"), [
|
||||
[-25, -10],
|
||||
[-12, 0],
|
||||
]);
|
||||
const out = res.commit!(p);
|
||||
expect(flattenCategories(out.layers).find((c) => c.code === "07")).toMatchObject({ name: "Baugrube", visible: true });
|
||||
});
|
||||
|
||||
it("Gelände-Befehl: ohne Höhenlinien sofort fertig mit Hinweis (schluckt keine Eingaben)", () => {
|
||||
const res = terrainCommand.autoRun!(ctxOf({ ...sampleProject, context: [] }));
|
||||
expect(res.done).toBe(true);
|
||||
expect(res.commit).toBeUndefined();
|
||||
expect(res.notice?.key).toBe("cmd.terrain.noContours");
|
||||
});
|
||||
|
||||
it("Engine: blockierte Befehle melden sich (Voraussetzung, kein Geschoss), Hinweise aus Ergebnissen", () => {
|
||||
const notes: string[] = [];
|
||||
let floor = true;
|
||||
let project: Project = sampleProject;
|
||||
const host: EngineHost = {
|
||||
context: (lastPoint) => ({ ...ctxOf(project), lastPoint }),
|
||||
snap: () => null,
|
||||
pxPerMeter: () => 50,
|
||||
setDraft: () => {},
|
||||
commit: () => {},
|
||||
isFloor: () => floor,
|
||||
notify: (key) => void notes.push(key),
|
||||
};
|
||||
const engine = new CommandEngine(host);
|
||||
expect(engine.start("baugrube")).toBe(false);
|
||||
expect(notes).toEqual(["cmd.excavation.noTerrain"]);
|
||||
floor = false;
|
||||
expect(engine.start("excavation")).toBe(false);
|
||||
expect(notes.at(-1)).toBe("cmd.needsFloor");
|
||||
floor = true;
|
||||
project = complex;
|
||||
expect(engine.start("excavation")).toBe(true);
|
||||
for (const pt of [{ x: 5000, y: 5000 }, { x: 5010, y: 5010 }]) engine.pick(pt);
|
||||
engine.confirm();
|
||||
expect(engine.isActive()).toBe(false);
|
||||
expect(notes.at(-1)).toBe("cmd.excavation.outside");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user