Refactor navigation route handling for admin menu:

- Replace `router` reference with reactive `routeContext` to remove router dependency.
- Add `syncAdminNavigationRoute` for syncing route data.
- Update `NavigationMenuItems.vue` to utilize the new syncing approach.
- Adjust unit tests to validate route context handling changes.
This commit is contained in:
Jeppe Bundgaard
2026-03-19 13:25:42 +01:00
parent 1493261ef7
commit 17036a0ae7
3 changed files with 25 additions and 9 deletions
@@ -9,10 +9,12 @@ const source = readFileSync(
).replace(/\r\n/g, '\n');
describe('NavigationMenuItemsAdmin contract', () => {
it('derives department id from reactive route context', () => {
expect(source).toContain('import { useRoute } from "vue-router";');
expect(source).toContain('const route = useRoute();');
expect(source).toContain('route.params.departmentId');
expect(source).toContain('route.path.match(/^\\/admin\\/(\\d+)(?:\\/|$)/)');
it('derives department id from synced route context without router import', () => {
expect(source).not.toContain('import { router } from "@/router.js";');
expect(source).toContain('const routeContext = ref(');
expect(source).toContain('const syncAdminNavigationRoute = (route: any) => {');
expect(source).toContain('const currentRoute = routeContext.value;');
expect(source).toContain('currentRoute?.params?.departmentId');
expect(source).toContain('currentRoute?.path?.match(/^\\/admin\\/(\\d+)(?:\\/|$)/)');
});
});