9443b5b446
Таблица pending-записей яруса 3 + кнопка «Отметить выполнено» с confirm-
диалогом, дёргает POST .../manual-queue/{id}/resolve. Реюз существующего
админ-экрана интеграции с поставщиком (после «Истории сверок»).
NB: spec в tests/Frontend/ (vitest include — tests/Frontend/**, не
resources/.../__tests__/ как указал план Step 11.1). loadManualQueue
defensive Array.isArray-guard — иначе onMounted в чужих spec'ах
(mockResolvedValue без queue-ключа) ловил undefined.length.
Spec §4.6. Task 11 of 12. Vitest 5/5 (2 новых + 3 существующих).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
67 lines
2.6 KiB
TypeScript
67 lines
2.6 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
import { mount } from '@vue/test-utils';
|
|
import { createVuetify } from 'vuetify';
|
|
import * as components from 'vuetify/components';
|
|
import * as directives from 'vuetify/directives';
|
|
import axios from 'axios';
|
|
import AdminSupplierIntegrationView from '../../resources/js/views/admin/AdminSupplierIntegrationView.vue';
|
|
|
|
vi.mock('axios');
|
|
|
|
const vuetify = createVuetify({ components, directives });
|
|
|
|
describe('AdminSupplierIntegrationView — manual queue section', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
(axios.get as ReturnType<typeof vi.fn>).mockImplementation((url: string) => {
|
|
if (url.endsWith('/manual-queue')) {
|
|
return Promise.resolve({
|
|
data: {
|
|
queue: [
|
|
{
|
|
id: 1,
|
|
project_id: 42,
|
|
platform: 'B1',
|
|
operation: 'create',
|
|
external_id: null,
|
|
payload_snapshot: { limit: 10, signal_type: 'site', unique_key: 'foo.com' },
|
|
failure_reason: 'contract_break',
|
|
created_at: '2026-05-19T10:00:00Z',
|
|
},
|
|
],
|
|
},
|
|
});
|
|
}
|
|
return Promise.resolve({ data: { health: null, history: [] } });
|
|
});
|
|
});
|
|
|
|
it('renders pending queue rows with payload + reason', async () => {
|
|
const wrapper = mount(AdminSupplierIntegrationView, { global: { plugins: [vuetify] } });
|
|
await new Promise((r) => setTimeout(r, 50));
|
|
|
|
const text = wrapper.text();
|
|
expect(text).toContain('foo.com');
|
|
expect(text).toContain('contract_break');
|
|
expect(text).toContain('B1');
|
|
});
|
|
|
|
it('clicking «Отметить выполнено» calls resolve endpoint', async () => {
|
|
(axios.post as ReturnType<typeof vi.fn>).mockResolvedValue({
|
|
data: { resolved: true, external_id: 700123 },
|
|
});
|
|
vi.spyOn(window, 'confirm').mockReturnValue(true);
|
|
|
|
const wrapper = mount(AdminSupplierIntegrationView, { global: { plugins: [vuetify] } });
|
|
await new Promise((r) => setTimeout(r, 50));
|
|
|
|
const btn = wrapper.find('[data-testid="resolve-1"]');
|
|
expect(btn.exists()).toBe(true);
|
|
await btn.trigger('click');
|
|
|
|
expect(axios.post).toHaveBeenCalledWith(
|
|
expect.stringContaining('/manual-queue/1/resolve'),
|
|
);
|
|
});
|
|
});
|