CI red on main: geschichten overview component tests crash on missing drafts mock #814

Closed
opened 2026-06-12 22:03:51 +02:00 by marcel · 0 comments
Owner

Symptom

The CI test job on main fails since PR #813 was merged: all 15 tests in frontend/src/routes/geschichten/page.svelte.test.ts crash with

TypeError: Cannot read properties of undefined (reading 'length')
 ❯ src/routes/geschichten/+page.svelte:137:29

Root cause

PR #813 added the Entwürfe (drafts) section to routes/geschichten/+page.svelte, which reads data.drafts.length. The server load (+page.server.ts) always returns a drafts array (empty for non-blog-writers), so the non-optional access is correct per the load contract.

However, the page has two test files:

  • page.svelte.spec.ts — added by PR #813 itself, mocks include drafts
  • page.svelte.test.ts — pre-existing coverage tests (b4d25620…6ba89da8); its baseData() helper builds the mock PageData without drafts

The #813 branch diverged before the coverage commits landed on main, so neither branch's CI saw the combination — a semantic merge conflict that only surfaced on main after merge.

Fix

Add drafts: [] to baseData() in page.svelte.test.ts so the mock matches what +page.server.ts always returns. Drafts rendering itself is already covered by page.svelte.spec.ts.

## Symptom The CI test job on `main` fails since PR #813 was merged: all 15 tests in `frontend/src/routes/geschichten/page.svelte.test.ts` crash with ``` TypeError: Cannot read properties of undefined (reading 'length') ❯ src/routes/geschichten/+page.svelte:137:29 ``` ## Root cause PR #813 added the Entwürfe (drafts) section to `routes/geschichten/+page.svelte`, which reads `data.drafts.length`. The server load (`+page.server.ts`) always returns a `drafts` array (empty for non-blog-writers), so the non-optional access is correct per the load contract. However, the page has **two** test files: - `page.svelte.spec.ts` — added by PR #813 itself, mocks include `drafts` ✅ - `page.svelte.test.ts` — pre-existing coverage tests (b4d25620…6ba89da8); its `baseData()` helper builds the mock `PageData` **without** `drafts` ❌ The #813 branch diverged before the coverage commits landed on main, so neither branch's CI saw the combination — a semantic merge conflict that only surfaced on main after merge. ## Fix Add `drafts: []` to `baseData()` in `page.svelte.test.ts` so the mock matches what `+page.server.ts` always returns. Drafts rendering itself is already covered by `page.svelte.spec.ts`.
marcel added the P1-highdevopstest labels 2026-06-12 22:04:02 +02:00
Sign in to join this conversation.
No Label P1-high devops test
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#814