From eb41b65dadd6259ae0b686d17ec20870e40b59b3 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: Sun, 17 May 2026 03:44:50 +0300 Subject: [PATCH] =?UTF-8?q?fix(ui):=20C3=20=E2=80=94=20=D1=81=D0=B1=D1=80?= =?UTF-8?q?=D0=BE=D1=81=20toast-=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=B0=20+?= =?UTF-8?q?=20=D1=82=D0=B8=D0=BF=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20?= =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=D0=B0=20(review-fixup)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/resources/js/views/DealsView.vue | 1 + app/tests/Frontend/DealsView.spec.ts | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/resources/js/views/DealsView.vue b/app/resources/js/views/DealsView.vue index 51f7cd87..b4266d99 100644 --- a/app/resources/js/views/DealsView.vue +++ b/app/resources/js/views/DealsView.vue @@ -364,6 +364,7 @@ async function exportAllFiltered(format: 'xlsx' | 'csv' = 'xlsx') { * На fail / без tenant — fallback на локальный CSV. */ async function exportDealIds(ids: number[], format: 'xlsx' | 'csv') { + exportToastText.value = ''; if (auth.user?.tenant_id) { try { if (format === 'xlsx') { diff --git a/app/tests/Frontend/DealsView.spec.ts b/app/tests/Frontend/DealsView.spec.ts index 4fd05031..3c241c49 100644 --- a/app/tests/Frontend/DealsView.spec.ts +++ b/app/tests/Frontend/DealsView.spec.ts @@ -1,4 +1,4 @@ -import { describe, it, test, expect, vi } from 'vitest'; +import { describe, it, test, expect, vi, afterEach } from 'vitest'; import { mount, flushPromises } from '@vue/test-utils'; import { createVuetify } from 'vuetify'; import { createRouter, createMemoryHistory } from 'vue-router'; @@ -7,6 +7,7 @@ import DealsView from '../../resources/js/views/DealsView.vue'; import { MOCK_DEALS } from '../../resources/js/composables/mockDeals'; import * as dealsApi from '../../resources/js/api/deals'; import { useAuthStore } from '../../resources/js/stores/auth'; +import type { AuthUser } from '../../resources/js/api/auth'; // Smoke-тесты DealsView с mock-данными. @@ -328,8 +329,7 @@ test('C3: exportAllFiltered вызывает backend-экспорт со все // Установить auth.user с tenant_id чтобы exportDealIds пошёл в backend const auth = useAuthStore(); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (auth as any).user = { id: 1, tenant_id: 42, email: 'test@test.com' }; + auth.user = { id: 1, tenant_id: 42, email: 'test@test.com' } as AuthUser; // activeTab по умолчанию 'active' — установить 'all' чтобы filteredDeals === dealsState const vm = wrapper.vm as unknown as { @@ -350,7 +350,6 @@ test('C3: exportAllFiltered вызывает backend-экспорт со все }); test('C3: exportAllFiltered на пустом списке показывает toast и не зовёт backend', async () => { - vi.restoreAllMocks(); const xlsxSpy = vi.spyOn(dealsApi, 'exportDealsXlsx').mockResolvedValue(new Blob()); const wrapper = await mountDeals(); await flushPromises(); @@ -372,3 +371,5 @@ test('C3: exportAllFiltered на пустом списке показывает expect(xlsxSpy).not.toHaveBeenCalled(); expect(vm.exportToastText).toBe('Список пуст — нечего экспортировать.'); }); + +afterEach(() => vi.restoreAllMocks());