test(stammbaum): fix two CI-only browser-test failures (#692)
All checks were successful
CI / Unit & Component Tests (pull_request) Successful in 3m18s
CI / OCR Service Tests (pull_request) Successful in 22s
CI / Backend Unit Tests (pull_request) Successful in 3m36s
CI / fail2ban Regex (pull_request) Successful in 45s
CI / Semgrep Security Scan (pull_request) Successful in 22s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m4s

- page.svelte.test.ts mocked $app/navigation with only replaceState, dropping
  invalidateAll (imported by StammbaumSidePanel) → the module errored and failed
  all 7 tests in the file. Mock now exports invalidateAll + goto too.
- StammbaumTree viewBox 'offsets origin' test hard-coded a wrong unpanned-x; assert
  the robust relationship instead (viewBox centre − content centroid == pan).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-29 20:42:50 +02:00
parent 95d35c20b2
commit ecae789be2
2 changed files with 11 additions and 5 deletions

View File

@@ -54,10 +54,12 @@ describe('StammbaumTree viewBox', () => {
expect(w).toBe(1200); expect(w).toBe(1200);
expect(h).toBe(800); expect(h).toBe(800);
// …but the origin is shifted by the pan offset. // …but the viewBox centre is the content centroid shifted by the pan
const unpannedX = -(1200 / 2 - 160 / 2); // single 160-wide node centred // offset (at pan {0,0} the centre sits on the centroid — see the test
expect(x).toBeCloseTo(unpannedX + 100, 6); // below). This avoids hard-coding the layout's absolute coordinates.
expect(y).toBeCloseTo(-(800 / 2 - 56 / 2) + 40, 6); const c = rectsCentroid(svg);
expect(x + w / 2 - c.x).toBeCloseTo(100, 6);
expect(y + h / 2 - c.y).toBeCloseTo(40, 6);
}); });
it('uses the minimum size and centers a single node', async () => { it('uses the minimum size and centers a single node', async () => {

View File

@@ -17,7 +17,11 @@ vi.mock('$app/state', () => ({
const replaceState = vi.fn(); const replaceState = vi.fn();
vi.mock('$app/navigation', () => ({ vi.mock('$app/navigation', () => ({
replaceState: (...args: unknown[]) => replaceState(...args) replaceState: (...args: unknown[]) => replaceState(...args),
// StammbaumSidePanel (rendered transitively) imports invalidateAll/goto, so
// the mock must provide every export the module graph uses.
invalidateAll: vi.fn(),
goto: vi.fn()
})); }));
afterEach(cleanup); afterEach(cleanup);