Files
DOSSIER/e2e/sectionGrips.spec.ts
T
Claude 515abf6b34 [187] Schnitt/Ansicht: Höhen-Griffe für Decke (OK/UK), Wand (OK/UK) und Öffnung (Brüstung/Sturz)
Angewählte Bauteile bekommen im Schnitt-/Ansichts-Tab Griffe an ihren Kanten. Die Rechnung liegt im Kern
(`sheet_height.rs`, Griff-Anfrage `sheetHeight`): Decke OK = Höhenlage über die `top`-Bindung (bei gebundener UK
ändert sie die Dicke), Decke UK = Dicke über den Deckentyp bzw. UK-Bindung; Wand UK hält die OK; Mindestmasse,
gesperrte Bauteile ohne Griffe, ein Undo-Schritt je Zug. Fang auf Geschoss-Koten und Schnitt-Geometrie, Tab tippt
die Kote. Griffe folgen den asynchron erneuerten Schnitt-Umrissen (useSyncExternalStore) und sitzen an den
Modell-Höhen statt am Umriss-Rest. Import `fieldOps` in useSelectionCommands nachgetragen (fehlte nach dem Merge).

Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
2026-11-11 23:01:38 +00:00

170 lines
8.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// [187] Höhen-Griffe im Schnitt: angewählte Decken, Wände und Fenster haben im Schnitt Fasspunkte (Archicad-Art).
// Musterhaus komplex, Schnitt A-A (x = 3): Decke EG → OK-Griff (Höhenlage) und UK-Griff (Dicke), Fenster eg-f1 →
// Brüstung und Sturz, Wand eg-aw-s → Ober-/Unterkante; je Zug ein Undo-Schritt; Tab tippt die Kote.
import type { Page } from "@playwright/test";
import { blurFocus, discardIfAsked, expect, fileMenu, showSnapshot, test } from "./app";
import type {} from "../src/state/testHooks";
test.use({ viewport: { width: 1600, height: 1000 } });
const heights = (page: Page) => page.evaluate(() => window.__dossierTest!.heights());
const ceiling = async (page: Page, id: string) => (await heights(page)).ceilings.find((c) => c.id === id)!;
const opening = async (page: Page, id: string) => (await heights(page)).openings.find((o) => o.id === id)!;
const wall = async (page: Page, id: string) => (await heights(page)).walls.find((w) => w.id === id)!;
const r3 = (x: number) => Math.round(x * 1000) / 1000;
/** Griffe lesen, sobald sie ruhen: nach Undo rechnet der Schnitt asynchron neu, bis dahin stehen sie an alter Stelle. */
async function gripCentres(page: Page): Promise<{ x: number; y: number }[]> {
const read = async () =>
(
await page.locator(".plan-grip").evaluateAll((els) =>
els.map((e) => {
const r = e.getBoundingClientRect();
return { x: Math.round(r.x + r.width / 2), y: Math.round(r.y + r.height / 2) };
}),
)
).sort((a, b) => a.x - b.x || a.y - b.y);
let prev = JSON.stringify(await read());
let same = 0;
for (let i = 0; i < 60 && same < 6; i++) {
await page.waitForTimeout(300);
const cur = JSON.stringify(await read());
same = cur === prev ? same + 1 : 0;
prev = cur;
}
return JSON.parse(prev);
}
/** Griff ziehen: er bleibt nach dem Loslassen bewaffnet und folgt dem Zeiger, bis ein Klick ihn setzt. */
async function dragGrip(page: Page, from: { x: number; y: number }, dy: number): Promise<void> {
await page.mouse.move(from.x, from.y);
await page.mouse.down();
await page.mouse.move(from.x, from.y + dy, { steps: 8 });
await page.mouse.up();
await page.mouse.click(from.x, from.y + dy);
}
/** Rückgängig; der Schnitt rechnet danach asynchron neu, bis dahin stehen die Griffe an alter Stelle. */
async function undo(page: Page) {
await blurFocus(page);
await page.keyboard.press("ControlOrMeta+z");
await page.waitForTimeout(4000);
}
async function select(page: Page, patch: Record<string, string[]>) {
await blurFocus(page);
// setSelection mischt: die anderen Arten leeren, sonst bleibt z. B. das Fenster gewählt
await page.evaluate((p) => window.__dossierTest!.select({ walls: [], openings: [], ceilings: [], ...p }), patch);
}
test("Schnitt A-A: Decke, Fenster und Wand haben Höhen-Griffe, Zug = ein Undo-Schritt", async ({ page }) => {
test.setTimeout(180_000);
await page.goto("/?dossierTest");
await page.getByRole("button", { name: /Neues Projekt/ }).first().click();
await expect(page.getByRole("group", { name: "Befehlszeile" })).toBeVisible();
await fileMenu(page, /Musterhaus \(komplex\)/);
await discardIfAsked(page);
await expect(page.locator(".project-name")).toHaveText("Musterhaus komplex", { timeout: 30_000 });
await showSnapshot(page, "Schnitt A-A");
await expect(page.locator("svg.plan-svg").first()).toBeVisible({ timeout: 30_000 });
await page.waitForTimeout(1000);
// Decke EG: zwei Griffe nebeneinander (OK links, UK rechts).
const c0 = await ceiling(page, "c-eg");
await select(page, { ceilings: ["c-eg"] });
await expect(page.locator(".plan-grip")).toHaveCount(2);
const [ok, uk] = await gripCentres(page);
expect(ok.x).toBeLessThan(uk.x);
// OK nach oben: Höhenlage ändert sich, die Dicke bleibt (ohne UK-Bindung wandert die Platte).
await dragGrip(page, ok, -30);
const c1 = await ceiling(page, "c-eg");
expect(c1.zTop).toBeGreaterThan(c0.zTop + 0.05);
expect(r3(c1.thickness)).toBe(r3(c0.thickness));
await undo(page);
await expect.poll(async () => (await ceiling(page, "c-eg")).zTop).toBe(c0.zTop);
// UK nach unten: die Decke wird dicker, die OK bleibt; ein Undo-Schritt stellt alles her.
await select(page, { ceilings: ["c-eg"] });
await expect(page.locator(".plan-grip")).toHaveCount(2);
const [, uk2] = await gripCentres(page);
await dragGrip(page, uk2, 25);
const c2 = await ceiling(page, "c-eg");
expect(c2.thickness).toBeGreaterThan(c0.thickness + 0.03);
expect(c2.zTop).toBe(c0.zTop);
await undo(page);
await expect.poll(async () => r3((await ceiling(page, "c-eg")).thickness)).toBe(r3(c0.thickness));
expect((await ceiling(page, "c-eg")).zTop).toBe(c0.zTop);
// Fenster eg-f1 (x 1.6–3.4, vom Schnitt getroffen): Sturz und Brüstung.
const f0 = await opening(page, "eg-f1");
await select(page, { openings: ["eg-f1"] });
await expect(page.locator(".plan-grip")).toHaveCount(2);
const [top, bottom] = (await gripCentres(page)).sort((a, b) => a.y - b.y);
await dragGrip(page, top, -20);
expect((await opening(page, "eg-f1")).height).toBeGreaterThan(f0.height + 0.05);
await undo(page);
await expect.poll(async () => (await opening(page, "eg-f1")).height).toBe(f0.height);
await select(page, { openings: ["eg-f1"] });
await expect(page.locator(".plan-grip")).toHaveCount(2);
const [, bottom2] = (await gripCentres(page)).sort((a, b) => a.y - b.y);
await dragGrip(page, bottom2, 20);
const f1 = await opening(page, "eg-f1");
expect(f1.sillHeight).toBeLessThan(f0.sillHeight - 0.05);
// Oberkante bleibt: Brüstung + Höhe unverändert.
expect(r3(f1.sillHeight + f1.height)).toBe(r3(f0.sillHeight + f0.height));
await undo(page);
await expect.poll(async () => (await opening(page, "eg-f1")).sillHeight).toBe(f0.sillHeight);
void bottom;
// Wand eg-aw-s: Oberkante und Unterkante.
const w0 = await wall(page, "eg-aw-s");
await select(page, { walls: ["eg-aw-s"] });
await expect(page.locator(".plan-grip")).toHaveCount(2);
const [wt, wb] = (await gripCentres(page)).sort((a, b) => a.y - b.y);
await dragGrip(page, wt, -45);
expect((await wall(page, "eg-aw-s")).zTop).toBeGreaterThan(w0.zTop + 0.05);
await undo(page);
await expect.poll(async () => (await wall(page, "eg-aw-s")).zTop).toBe(w0.zTop);
await select(page, { walls: ["eg-aw-s"] });
const [, wb2] = (await gripCentres(page)).sort((a, b) => a.y - b.y);
await dragGrip(page, wb2, 20);
const w1 = await wall(page, "eg-aw-s");
expect(w1.zBottom).toBeLessThan(w0.zBottom - 0.05);
expect(r3(w1.zTop)).toBe(r3(w0.zTop)); // Oberkante bleibt
await undo(page);
await expect.poll(async () => (await wall(page, "eg-aw-s")).zBottom).toBe(w0.zBottom);
void wb;
});
test("Schnitt A-A: Tab tippt die Kote der Decken-Oberkante", async ({ page }) => {
test.setTimeout(180_000);
await page.goto("/?dossierTest");
await page.getByRole("button", { name: /Neues Projekt/ }).first().click();
await expect(page.getByRole("group", { name: "Befehlszeile" })).toBeVisible();
await fileMenu(page, /Musterhaus \(komplex\)/);
await discardIfAsked(page);
await expect(page.locator(".project-name")).toHaveText("Musterhaus komplex", { timeout: 30_000 });
await showSnapshot(page, "Schnitt A-A");
await expect(page.locator("svg.plan-svg").first()).toBeVisible({ timeout: 30_000 });
await page.waitForTimeout(1000);
const c0 = await ceiling(page, "c-eg");
await select(page, { ceilings: ["c-eg"] });
await expect(page.locator(".plan-grip")).toHaveCount(2);
const [ok] = await gripCentres(page);
await page.mouse.move(ok.x, ok.y);
await page.mouse.down();
await page.mouse.move(ok.x, ok.y - 15, { steps: 5 });
await page.mouse.up();
// Tab friert die Kote ein und öffnet das Feld „Kote“; die getippte Zahl setzt die Oberkante exakt.
await page.keyboard.press("Tab");
const target = r3(c0.zTop + 0.4);
await page.keyboard.type(String(target));
await page.keyboard.press("Enter");
await page.mouse.click(ok.x, ok.y - 15);
await expect.poll(async () => r3((await ceiling(page, "c-eg")).zTop)).toBe(target);
await undo(page);
await expect.poll(async () => (await ceiling(page, "c-eg")).zTop).toBe(c0.zTop);
});