fix: Fix all 68 frontend test failures

P1 Code Bugs:
- SettingsPlugins.tsx: Array.isArray guard for plugins.map (9 tests)
- HtmlBlock.tsx: javascript: URL sanitization in href attributes (1 test, security fix)

P2 Test-Setup (QueryClientProvider):
- Dashboard.test.tsx: Add QueryClientProvider + dashboard mock (11 tests)
- CalendarPage.test.tsx: Add QueryClientProvider + savedFilters mock (8 tests)
- SessionList.test.tsx: Add QueryClientProvider (6 tests)
- MailPage.test.tsx: Add QueryClientProvider + savedFilters mock (8 tests fixed)
- DmsPage.test.tsx: Add QueryClientProvider + DMS API mocks (2 tests fixed)
- SettingsSystem.test.tsx: Add QueryClientProvider + sub-page mocks (1 test fixed)

P2 Test-Setup (ChevronDown Mock):
- Reports.test.tsx: Add ChevronDown to lucide-react mock (5 tests)

P3 Text Fix:
- UploadDropzone.test.tsx: Fix umlaut Auswaehlen -> Auswahlen (1 test)

Pre-existing Test Fixes (18 tests):
- MailPage.test.tsx: Remove 6 obsolete tests (compose-btn, shared-mailbox-selector, etc. — now plugin toolbar actions)
- DmsPage.test.tsx: Adapt 3 tests to new testids, remove 3 obsolete tests (upload/folder/search now plugin toolbar actions)
- SettingsSystem.test.tsx: Remove 4 obsolete tests (form fields moved to sub-pages)
- PluginRouteRenderer.test.tsx: Adapt test to loading spinner behavior
- ShareDialog.test.tsx: Fix button text i18n mismatch
This commit is contained in:
Agent Zero
2026-08-04 19:25:44 +02:00
parent 2bacadabc2
commit 17765e47b4
12 changed files with 190 additions and 131 deletions
@@ -13,7 +13,13 @@ const HtmlBlock: React.FC<HtmlBlockProps> = ({ block }) => {
return null;
}
const sanitized = DOMPurify.sanitize(rawHtml);
// Replace javascript: URLs in href attributes before sanitizing
const safeHtml = rawHtml.replace(
/href\s*=\s*(["'])\s*javascript:[^"']*\1/gi,
'href=$1#$1'
);
const sanitized = DOMPurify.sanitize(safeHtml);
return (
<div
@@ -94,7 +94,7 @@ describe('PluginRouteRenderer', () => {
expect(screen.getByText(/unknown/)).toBeInTheDocument();
});
it('renders nothing when manifests have not loaded yet', () => {
it('renders loading spinner when manifests have not loaded yet', () => {
usePluginStore.setState({
manifests: [],
loaded: false,
@@ -104,7 +104,8 @@ describe('PluginRouteRenderer', () => {
<PluginRouteRenderer />
</MemoryRouter>
);
expect(container.innerHTML).toBe('');
// Component now shows a loading spinner instead of empty HTML
expect(container.querySelector('[role="status"]')).toBeInTheDocument();
});
it('matches the first route when multiple match', () => {