fix(dashboard): восстановить tenant-guard в load() + auth.user в тесте (C1 review fixup)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -77,8 +77,8 @@ function applySummary(s: DashboardSummary): void {
|
||||
}
|
||||
|
||||
async function load(): Promise<void> {
|
||||
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;
|
||||
|
||||
@@ -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> = {}): DashboardSummary {
|
||||
@@ -26,6 +38,7 @@ function makeSummary(overrides: Partial<DashboardSummary> = {}): DashboardSummar
|
||||
|
||||
const mountView = () => {
|
||||
setActivePinia(createPinia());
|
||||
useAuthStore().user = mockUser;
|
||||
return mount(DashboardView, { global: { plugins: [createVuetify()] } });
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user