From e6467d18cf48416ea66349554701abc58ae6ee99 Mon Sep 17 00:00:00 2001 From: curo1305 Date: Fri, 12 Jun 2026 16:11:00 +0200 Subject: [PATCH] feat(09-04): delete AdminView + 4 tab files; update tests + router guard test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - git rm AdminView.vue, AdminUsersTab.vue, AdminQuotasTab.vue, AdminAiConfigTab.vue, AuditLogTab.vue - Migrate tab tests to import from views/admin/Admin*View.vue - Update router.guard.test.js: replace AdminView mock with AdminLayout + 5 admin view mocks - Add D-09 redirect test (admin on / → /admin) - Fix stale api/admin.js JSDoc consumer list - Fix SettingsView.vue stale AdminView comment reference --- frontend/src/api/admin.js | 4 +- .../src/components/admin/AdminAiConfigTab.vue | 391 -------------- .../src/components/admin/AdminQuotasTab.vue | 182 ------- .../src/components/admin/AdminUsersTab.vue | 480 ------------------ frontend/src/components/admin/AuditLogTab.vue | 346 ------------- .../admin/__tests__/AdminAiConfigTab.test.js | 2 +- .../admin/__tests__/AdminQuotasTab.test.js | 2 +- .../admin/__tests__/AdminUsersTab.test.js | 2 +- .../src/router/__tests__/router.guard.test.js | 21 +- frontend/src/views/AdminView.vue | 43 -- frontend/src/views/SettingsView.vue | 2 +- 11 files changed, 26 insertions(+), 1449 deletions(-) delete mode 100644 frontend/src/components/admin/AdminAiConfigTab.vue delete mode 100644 frontend/src/components/admin/AdminQuotasTab.vue delete mode 100644 frontend/src/components/admin/AdminUsersTab.vue delete mode 100644 frontend/src/components/admin/AuditLogTab.vue delete mode 100644 frontend/src/views/AdminView.vue diff --git a/frontend/src/api/admin.js b/frontend/src/api/admin.js index 028ce79..cf25da0 100644 --- a/frontend/src/api/admin.js +++ b/frontend/src/api/admin.js @@ -1,8 +1,8 @@ /** * Admin API — user management, quota, AI config, audit log, daily exports. * - * Consumers: AdminUsersTab.vue, AdminQuotasTab.vue, AdminAiConfigTab.vue, - * AuditLogTab.vue, AdminDailyExportsTab.vue + * Consumers: AdminUsersView.vue, AdminQuotasView.vue, AdminAiView.vue, + * AdminAuditView.vue */ import { request, fetchWithRetry } from './utils.js' diff --git a/frontend/src/components/admin/AdminAiConfigTab.vue b/frontend/src/components/admin/AdminAiConfigTab.vue deleted file mode 100644 index e0eed21..0000000 --- a/frontend/src/components/admin/AdminAiConfigTab.vue +++ /dev/null @@ -1,391 +0,0 @@ - - - diff --git a/frontend/src/components/admin/AdminQuotasTab.vue b/frontend/src/components/admin/AdminQuotasTab.vue deleted file mode 100644 index 7babeb4..0000000 --- a/frontend/src/components/admin/AdminQuotasTab.vue +++ /dev/null @@ -1,182 +0,0 @@ - - - diff --git a/frontend/src/components/admin/AdminUsersTab.vue b/frontend/src/components/admin/AdminUsersTab.vue deleted file mode 100644 index 289ae61..0000000 --- a/frontend/src/components/admin/AdminUsersTab.vue +++ /dev/null @@ -1,480 +0,0 @@ - - - diff --git a/frontend/src/components/admin/AuditLogTab.vue b/frontend/src/components/admin/AuditLogTab.vue deleted file mode 100644 index 6e110c8..0000000 --- a/frontend/src/components/admin/AuditLogTab.vue +++ /dev/null @@ -1,346 +0,0 @@ - - - diff --git a/frontend/src/components/admin/__tests__/AdminAiConfigTab.test.js b/frontend/src/components/admin/__tests__/AdminAiConfigTab.test.js index 8c0d0af..2e0f365 100644 --- a/frontend/src/components/admin/__tests__/AdminAiConfigTab.test.js +++ b/frontend/src/components/admin/__tests__/AdminAiConfigTab.test.js @@ -7,7 +7,7 @@ vi.mock('../../../api/client.js', () => ({ adminUpdateAiConfig: vi.fn(), })) -import AdminAiConfigTab from '../AdminAiConfigTab.vue' +import AdminAiConfigTab from '../../../views/admin/AdminAiView.vue' import * as api from '../../../api/client.js' function makeUser(overrides = {}) { diff --git a/frontend/src/components/admin/__tests__/AdminQuotasTab.test.js b/frontend/src/components/admin/__tests__/AdminQuotasTab.test.js index ed57863..fc82868 100644 --- a/frontend/src/components/admin/__tests__/AdminQuotasTab.test.js +++ b/frontend/src/components/admin/__tests__/AdminQuotasTab.test.js @@ -8,7 +8,7 @@ vi.mock('../../../api/client.js', () => ({ adminUpdateQuota: vi.fn(), })) -import AdminQuotasTab from '../AdminQuotasTab.vue' +import AdminQuotasTab from '../../../views/admin/AdminQuotasView.vue' import * as api from '../../../api/client.js' const MB = 1048576 diff --git a/frontend/src/components/admin/__tests__/AdminUsersTab.test.js b/frontend/src/components/admin/__tests__/AdminUsersTab.test.js index cfa67e9..f116353 100644 --- a/frontend/src/components/admin/__tests__/AdminUsersTab.test.js +++ b/frontend/src/components/admin/__tests__/AdminUsersTab.test.js @@ -11,7 +11,7 @@ vi.mock('../../../api/client.js', () => ({ adminCreateUser: vi.fn(), })) -import AdminUsersTab from '../AdminUsersTab.vue' +import AdminUsersTab from '../../../views/admin/AdminUsersView.vue' import * as api from '../../../api/client.js' function makeUser(overrides = {}) { diff --git a/frontend/src/router/__tests__/router.guard.test.js b/frontend/src/router/__tests__/router.guard.test.js index 99336fc..036a88c 100644 --- a/frontend/src/router/__tests__/router.guard.test.js +++ b/frontend/src/router/__tests__/router.guard.test.js @@ -11,7 +11,12 @@ vi.mock('../../views/auth/LoginView.vue', () => ({ default: { template: '
vi.mock('../../views/auth/RegisterView.vue', () => ({ default: { template: '
' } })) vi.mock('../../views/auth/PasswordResetView.vue', () => ({ default: { template: '
' } })) vi.mock('../../views/auth/NewPasswordView.vue', () => ({ default: { template: '
' } })) -vi.mock('../../views/AdminView.vue', () => ({ default: { template: '
' } })) +vi.mock('../../layouts/AdminLayout.vue', () => ({ default: { template: '
' } })) +vi.mock('../../views/admin/AdminOverviewView.vue', () => ({ default: { template: '
' } })) +vi.mock('../../views/admin/AdminUsersView.vue', () => ({ default: { template: '
' } })) +vi.mock('../../views/admin/AdminQuotasView.vue', () => ({ default: { template: '
' } })) +vi.mock('../../views/admin/AdminAiView.vue', () => ({ default: { template: '
' } })) +vi.mock('../../views/admin/AdminAuditView.vue', () => ({ default: { template: '
' } })) vi.mock('../../views/SharedView.vue', () => ({ default: { template: '
' } })) // Heavy view components imported statically — stub them too @@ -78,4 +83,18 @@ describe('router — admin guard (SEC-07)', () => { await router.push('/admin') expect(router.currentRoute.value.path).toBe('/admin') }) + + it('redirects an admin user away from / to /admin (D-09)', async () => { + // Arrange: admin trying to navigate to a regular user route + useAuthStore.mockReturnValue({ + accessToken: 'fake-token', + user: { id: '1', role: 'admin' }, + refresh: vi.fn().mockResolvedValue(undefined), + }) + + // Act: admin attempts to visit the regular user home + await router.push('/') + // The D-09 guard branch returns { path: '/admin' } + expect(router.currentRoute.value.path).toBe('/admin') + }) }) diff --git a/frontend/src/views/AdminView.vue b/frontend/src/views/AdminView.vue deleted file mode 100644 index 22dae05..0000000 --- a/frontend/src/views/AdminView.vue +++ /dev/null @@ -1,43 +0,0 @@ - - - diff --git a/frontend/src/views/SettingsView.vue b/frontend/src/views/SettingsView.vue index ec1bd19..616f5b3 100644 --- a/frontend/src/views/SettingsView.vue +++ b/frontend/src/views/SettingsView.vue @@ -27,7 +27,7 @@
- +