fix(ui): C3 — сброс toast-текста + типизация теста (review-fixup)
This commit is contained in:
@@ -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') {
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user