f9f86ca05f
Дружелюбный переключатель ВКЛ/ВЫКЛ флага routing_match_by_snapshot для владельца — без правки БД и без 30-символьного основания общего edit-flow. GET/POST source-edit-flag в AdminSupplierIntegrationController пишут в system_settings type=bool + audit-журнал. На экране карточка с VSwitch и диалогом подтверждения, бамп ключа возвращает тумблер к факту при отмене. TDD: 5 эндпоинт-тестов + фронт-спек. Larastan чист, baseline дополнен Pest-шумом. Проверено глазами через Playwright. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
41 lines
1.9 KiB
TypeScript
41 lines
1.9 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
import { mount } from '@vue/test-utils';
|
|
import { createVuetify } from 'vuetify';
|
|
import axios from 'axios';
|
|
import AdminSupplierIntegrationView from '../../resources/js/views/admin/AdminSupplierIntegrationView.vue';
|
|
|
|
vi.mock('axios');
|
|
|
|
const vuetify = createVuetify();
|
|
|
|
describe('AdminSupplierIntegrationView — тумблер разблокировки смены источника', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
(axios.get as ReturnType<typeof vi.fn>).mockImplementation((url: string) => {
|
|
if (url.endsWith('/source-edit-flag')) {
|
|
return Promise.resolve({ data: { enabled: true } });
|
|
}
|
|
if (url.endsWith('/export-mode')) {
|
|
return Promise.resolve({ data: { mode: 'batch' } });
|
|
}
|
|
if (url.endsWith('/manual-queue')) {
|
|
return Promise.resolve({ data: { queue: [] } });
|
|
}
|
|
return Promise.resolve({ data: { health: null, history: [] } });
|
|
});
|
|
(axios.post as ReturnType<typeof vi.fn>).mockResolvedValue({ data: { enabled: false } });
|
|
});
|
|
|
|
it('GETs the flag on mount and renders the toggle card with current label', async () => {
|
|
const wrapper = mount(AdminSupplierIntegrationView, { global: { plugins: [vuetify] } });
|
|
await new Promise((r) => setTimeout(r, 50));
|
|
|
|
expect(axios.get).toHaveBeenCalledWith('/api/admin/supplier-integration/source-edit-flag');
|
|
const card = wrapper.find('[data-testid="source-edit-flag-card"]');
|
|
expect(card.exists()).toBe(true);
|
|
expect(wrapper.text()).toContain('Разблокировка смены источника');
|
|
// флаг enabled=true с бэка → подпись «Включена»
|
|
expect(wrapper.text()).toContain('Включена');
|
|
});
|
|
});
|