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 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-08 12:44:34 +02:00
parent ca902c3ecf
commit fa269de4d3
2 changed files with 13 additions and 1 deletions

View File

@@ -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();
}
</script>

View File

@@ -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,