feat(N4): Restliche Module — Tasks/Kommunikation/Wiki/Reports/Agents/Tags/Search + Navigation + Dashboard-Schnittstelle (#368)
Check Cross-Plugin Imports / check (push) Has been cancelled
Check Cross-Plugin Imports / check (push) Has been cancelled
- Scope-Deklarationen: tasks only_mine, kommunikation conversation_ids, wiki category_ids (NEUE contracts.py), report_generator template_ids, automation agent_ids (module_key agents), tags tag_ids, unified_search entity_types dynamisch aus Provider-Registry - Core-Beiträge: navigation default_route (Startseite) + dashboard widget_app_ids (Widget-TYP-Angebot, Layout bleibt Phase M) - Backend-Filter (additive UND): /tasks (only_mine), /comm/conversations, /wiki/articles+/categories (Subtree), /reports/print-templates, /agents, /tags, /search GET+POST (entity_types-Schnitt), /miniapps?host=dashboard - apply_entity_type_scope-Helper (requested ∧ scope) - Frontend: WorkspaceSwitcher default_route-Navigation, Sidebar workspace-menu_order-Sortierung, workspaceStore moduleMenuOrder() - Tests: 18/18 Deklarationen + 11/11 Filter (TDD), Frontend 2/2 + Store 18/18, tsc clean, Build OK - Regression 64 passed (4 Kombi-Failures = Suite-Isolation, solo-bewiesen); Checker 0; Ruff = Vorbestand (Stash-bewiesen)
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* N4 — Navigation defaults (Phase N, final task).
|
||||
*
|
||||
* Workspace navigation config (admin-defined per workspace):
|
||||
* - default_route: where the workspace switcher navigates to after switching
|
||||
*/
|
||||
import React from 'react';
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import { WorkspaceSwitcher } from '@/components/layout/WorkspaceSwitcher';
|
||||
|
||||
const mockSwitch = vi.fn();
|
||||
const mockNavigate = vi.fn();
|
||||
|
||||
vi.mock('react-router-dom', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('react-router-dom')>();
|
||||
return {
|
||||
...actual,
|
||||
useNavigate: () => mockNavigate,
|
||||
};
|
||||
});
|
||||
|
||||
const myWorkspaces = [
|
||||
{ id: 'ws-1', name: 'Vertrieb', description: null, icon: 'LayoutGrid', is_default: false, is_active: true, role: 'member', is_user_default: false, modules: [] },
|
||||
{
|
||||
id: 'ws-2',
|
||||
name: 'Support',
|
||||
description: null,
|
||||
icon: 'LayoutGrid',
|
||||
is_default: false,
|
||||
is_active: true,
|
||||
role: 'member',
|
||||
is_user_default: false,
|
||||
modules: [
|
||||
{ module_key: 'navigation', menu_order: 0, config: { default_route: '/contacts' } },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
vi.mock('@/hooks/useWorkspace', () => ({
|
||||
useWorkspace: () => ({
|
||||
myWorkspaces,
|
||||
activeWorkspaceId: 'ws-1',
|
||||
switchWorkspace: mockSwitch,
|
||||
hasWorkspaces: true,
|
||||
}),
|
||||
}));
|
||||
|
||||
function renderSwitcher() {
|
||||
return render(
|
||||
<MemoryRouter>
|
||||
<WorkspaceSwitcher />
|
||||
</MemoryRouter>,
|
||||
);
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('WorkspaceSwitcher navigation (N4)', () => {
|
||||
it('switches workspace and navigates to its default_route', () => {
|
||||
renderSwitcher();
|
||||
fireEvent.click(screen.getByRole('button', { name: /Vertrieb/i }));
|
||||
fireEvent.click(screen.getByText('Support'));
|
||||
|
||||
expect(mockSwitch).toHaveBeenCalledWith('ws-2');
|
||||
expect(mockNavigate).toHaveBeenCalledWith('/contacts');
|
||||
});
|
||||
|
||||
it('switches without navigation config (backward compatible, no navigate call)', () => {
|
||||
renderSwitcher();
|
||||
fireEvent.click(screen.getByRole('button', { name: /Vertrieb/i }));
|
||||
// switch to ws-1 (no navigation config) — the dropdown entry (not the
|
||||
// trigger button, which also shows the active workspace name)
|
||||
fireEvent.click(screen.getAllByText('Vertrieb')[1].closest('button')!);
|
||||
|
||||
expect(mockSwitch).toHaveBeenCalledWith('ws-1');
|
||||
expect(mockNavigate).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user