fix(web): eingeklappt stehen Eintraege aus "Eigene Module" zuletzt

Die eingeklappte Seitenleiste zeigte die Kacheln in Ladefolge; ein Eintrag
aus "Eigene Module" konnte so vor einem eigenen Eintrag anderer
Kategorien stehen. Jetzt gleiche Gruppenfolge wie ausgeklappt.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-29 11:30:06 +02:00
parent 4ff9a239fd
commit 3cb43d6cc0
2 changed files with 36 additions and 2 deletions
@@ -40,9 +40,13 @@ vi.mock('next-intl', () => ({
},
}));
let mockCollapsed = false;
function mockSidebarCollapsed(value: boolean) {
mockCollapsed = value;
}
vi.mock('@/lib/stores/sidebar-store', () => ({
useSidebarStore: () => ({
isCollapsed: false,
isCollapsed: mockCollapsed,
isMobileOpen: false,
toggle: vi.fn(),
setMobileOpen: vi.fn(),
@@ -108,6 +112,7 @@ afterEach(() => {
mockPathname = '/';
mockRefreshKey = 0;
mockCustomModules = [];
mockCollapsed = false;
});
function customModule(overrides: Partial<(typeof mockCustomModules)[number]> = {}) {
@@ -325,6 +330,24 @@ describe('Sidebar', () => {
expect(screen.queryByText('custom-modules')).toBeNull();
});
it('eingeklappt stehen Eintraege aus „Eigene Module“ zuletzt', async () => {
mockCustomModules = [
customModule({ id: 'cm-1', category: 'custom-modules', name: 'Mein Wiki' }),
customModule({ id: 'cm-2', category: 'fleet', name: 'Tankkarte' }),
];
mockSidebarCollapsed(true);
const Sidebar = await importSidebar();
render(<Sidebar />);
const hrefs = () =>
Array.from(document.querySelectorAll('aside ul.border-t a')).map((a) => a.getAttribute('href'));
await waitFor(() => {
expect(hrefs()).toContain('/modules/custom/cm-1');
});
expect(hrefs().at(-1)).toBe('/modules/custom/cm-1');
expect(hrefs().indexOf('/modules/custom/cm-2')).toBeLessThan(hrefs().indexOf('/modules/custom/cm-1'));
});
it('eingebaute Module stehen innerhalb einer Kategorie vor eigenen', async () => {
mockCustomModules = [customModule({ category: 'Domain-Tools', name: 'Aaa Eigenes' })];
const Sidebar = await importSidebar();