From 3c3fd248e9ec5e76d0ff6cd9ecb8beefd25e7726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Sat, 16 May 2026 11:06:19 +0300 Subject: [PATCH] =?UTF-8?q?fix(dashboard):=20=D0=B2=D0=BE=D1=81=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=B8=D1=82=D1=8C=20tenant-guard?= =?UTF-8?q?=20=D0=B2=20load()=20+=20auth.user=20=D0=B2=20=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=B5=20(C1=20review=20fixup)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 (1M context) --- app/resources/js/views/DashboardView.vue | 4 ++-- app/tests/Frontend/DashboardView.spec.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/resources/js/views/DashboardView.vue b/app/resources/js/views/DashboardView.vue index b7123ec6..d9035d1a 100644 --- a/app/resources/js/views/DashboardView.vue +++ b/app/resources/js/views/DashboardView.vue @@ -77,8 +77,8 @@ function applySummary(s: DashboardSummary): void { } async function load(): Promise { - if (range.value === 'custom') return; - const tenantId = auth.user?.tenant_id ?? 0; + const tenantId = auth.user?.tenant_id; + if (!tenantId || range.value === 'custom') return; try { applySummary(await getDashboardSummary(tenantId, range.value as DashboardRange)); fetchError.value = false; diff --git a/app/tests/Frontend/DashboardView.spec.ts b/app/tests/Frontend/DashboardView.spec.ts index b5ef3d12..390b4fa8 100644 --- a/app/tests/Frontend/DashboardView.spec.ts +++ b/app/tests/Frontend/DashboardView.spec.ts @@ -4,11 +4,23 @@ import { createVuetify } from 'vuetify'; import { createPinia, setActivePinia } from 'pinia'; import DashboardView from '../../resources/js/views/DashboardView.vue'; import type { DashboardSummary } from '../../resources/js/api/dashboard'; +import { useAuthStore } from '../../resources/js/stores/auth'; +import type { AuthUser } from '../../resources/js/api/auth'; vi.mock('../../resources/js/api/dashboard', () => ({ getDashboardSummary: vi.fn(), })); +const mockUser: AuthUser = { + id: 1, + email: 'user@liderra.ru', + first_name: 'Иван', + last_name: 'Петров', + tenant_id: 1, + totp_enabled: false, + last_login_at: null, +}; + const dashboardApi = await import('../../resources/js/api/dashboard'); function makeSummary(overrides: Partial = {}): DashboardSummary { @@ -26,6 +38,7 @@ function makeSummary(overrides: Partial = {}): DashboardSummar const mountView = () => { setActivePinia(createPinia()); + useAuthStore().user = mockUser; return mount(DashboardView, { global: { plugins: [createVuetify()] } }); };