Files
familienarchiv/frontend/src/lib/document/EnrichmentBlock.svelte
Marcel 9f1b8b4215 fix(enrichment-block): migrate $app/stores → $app/state to eliminate birpc race
The async vi.mock factory in EnrichmentBlock.svelte.spec.ts performed an
`await import(...)` in its body — the same mechanism #535/#546 fixed for
pdfjs-dist. Issue #553: when Chromium's playwright route handler fetches
the mocked module after the worker's birpc channel has closed, the
factory's RPC roundtrip raises `[birpc] rpc is closed, cannot call
"resolveManualMock"` and the run exits 1.

Migrate EnrichmentBlock from the deprecated `$app/stores.navigating`
(store) to the modern `$app/state.navigating` (reactive proxy). The
spec uses vi.hoisted + a sync vi.mock factory with a getter that defers
the read — no dynamic import in the factory body. Delete the now-unused
__mocks__/navigatingStore.ts.

Fix path applied: $app/state migration (Markus's recommendation /
Felix's Path 2). See ADR-012.

Refs #553

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 22:00:44 +02:00

42 lines
1.2 KiB
Svelte

<script lang="ts">
import { navigating } from '$app/state';
import DashboardNeedsMetadata from './DashboardNeedsMetadata.svelte';
import UploadSuccessBanner from './UploadSuccessBanner.svelte';
type IncompleteDoc = {
id: string;
title: string;
uploadedAt: string;
};
interface Props {
topDocs: IncompleteDoc[];
totalCount: number;
bannerCount: number;
onBannerClose: () => void;
}
let { topDocs, totalCount, bannerCount, onBannerClose }: Props = $props();
const showSkeleton = $derived(!!navigating.type && topDocs.length === 0);
const showBlock = $derived(topDocs.length > 0 || bannerCount > 0 || showSkeleton);
</script>
{#if showBlock}
<div data-testid="enrichment-block" class="flex flex-col gap-3">
{#if bannerCount > 0}
<UploadSuccessBanner count={bannerCount} onClose={onBannerClose} />
{/if}
{#if topDocs.length > 0}
<DashboardNeedsMetadata topDocs={topDocs} totalCount={totalCount} />
{:else if showSkeleton}
<div
data-testid="enrichment-block-skeleton"
class="h-[360px] animate-pulse rounded-sm border border-line bg-surface/50 motion-reduce:animate-none"
aria-busy="true"
aria-label="Lade aktualisierte Liste"
></div>
{/if}
</div>
{/if}