From 5a8a1898f80e506b3a042ef94f1fb87738cb3309 Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 8 May 2026 12:44:34 +0200 Subject: [PATCH] fix(dashboard): isNew compares timestamps numerically, not by ISO string ISO strings differing only in millisecond precision or timezone formatting represent the same instant but failed string equality, so freshly created documents could miss the "Neu" badge depending on whatever shape the backend serializer emitted. Browser specs cannot run in the worktree (birpc WebSocket closure crash documented in the PR description); the new vitest-browser test must be verified from a normal checkout. Co-Authored-By: Claude Opus 4.7 --- .../src/lib/shared/dashboard/ReaderRecentDocs.svelte | 2 +- .../shared/dashboard/ReaderRecentDocs.svelte.spec.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/shared/dashboard/ReaderRecentDocs.svelte b/frontend/src/lib/shared/dashboard/ReaderRecentDocs.svelte index 3fd37db4..4052fc8a 100644 --- a/frontend/src/lib/shared/dashboard/ReaderRecentDocs.svelte +++ b/frontend/src/lib/shared/dashboard/ReaderRecentDocs.svelte @@ -12,7 +12,7 @@ interface Props { const { documents }: Props = $props(); function isNew(doc: Document): boolean { - return doc.createdAt === doc.updatedAt; + return new Date(doc.createdAt).getTime() === new Date(doc.updatedAt).getTime(); } diff --git a/frontend/src/lib/shared/dashboard/ReaderRecentDocs.svelte.spec.ts b/frontend/src/lib/shared/dashboard/ReaderRecentDocs.svelte.spec.ts index 6d0f45f7..502a10d9 100644 --- a/frontend/src/lib/shared/dashboard/ReaderRecentDocs.svelte.spec.ts +++ b/frontend/src/lib/shared/dashboard/ReaderRecentDocs.svelte.spec.ts @@ -55,6 +55,18 @@ describe('ReaderRecentDocs', () => { await expect.element(badge).not.toBeInTheDocument(); }); + it('shows "Neu" badge when createdAt and updatedAt represent the same instant in different ISO formats', async () => { + const sameInstantDoc: Document = { + ...baseDoc, + id: 'doc-same-instant', + createdAt: '2025-01-01T12:00:00Z', + updatedAt: '2025-01-01T12:00:00.000Z' + }; + render(ReaderRecentDocs, { documents: [sameInstantDoc] }); + const badge = page.getByText(/^Neu$/i); + await expect.element(badge).toBeInTheDocument(); + }); + it('renders sender link when sender is present', async () => { const docWithSender: Document = { ...baseDoc,