From 97c13809f55383d1e0b24622a6284baae7456f07 Mon Sep 17 00:00:00 2001 From: Schalli Date: Wed, 24 Jun 2026 11:30:45 +0200 Subject: [PATCH] test(05-02): add failing tests for search and note widgets - SearchWidget: provider selection, window.open with encoded query, Enter key trigger - NoteWidget: debounced autosave, rapid typing collapse, AbortController usage Co-Authored-By: Claude Sonnet 4.6 --- .../dashboard/widgets/note-widget.test.tsx | 202 ++++++++++++++++++ .../dashboard/widgets/search-widget.test.tsx | 131 ++++++++++++ 2 files changed, 333 insertions(+) create mode 100644 apps/web/src/components/dashboard/widgets/note-widget.test.tsx create mode 100644 apps/web/src/components/dashboard/widgets/search-widget.test.tsx diff --git a/apps/web/src/components/dashboard/widgets/note-widget.test.tsx b/apps/web/src/components/dashboard/widgets/note-widget.test.tsx new file mode 100644 index 0000000..da62ebc --- /dev/null +++ b/apps/web/src/components/dashboard/widgets/note-widget.test.tsx @@ -0,0 +1,202 @@ +import { act, render, screen } from '@testing-library/react'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; + +// Mock next-intl +vi.mock('next-intl', () => ({ + useTranslations: () => (key: string) => { + const map: Record = { + 'note.defaultTitle': 'Notiz', + 'note.autosaveError': 'Speichern fehlgeschlagen', + }; + return map[key] ?? key; + }, +})); + +// Mock @uiw/react-md-editor — provide a minimal textarea-based substitute +vi.mock('@uiw/react-md-editor', () => { + const MDEditor = ({ + value, + onChange, + 'data-testid': testId, + }: { + value?: string; + onChange?: (val?: string) => void; + 'data-testid'?: string; + }) => ( +