all: health-проверка api и страница /health в web

This commit is contained in:
arswarog committed 2026-10-27 10:44:23 +03:00
1 parent bd6f349dc4
commit db4eb04092
10 files changed
+93 -893

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
import { render, screen } from '@testing-library/react';
import { HealthPage } from './HealthPage';
describe('HealthPage', () => {
afterEach(() => {
vi.unstubAllGlobals();
});
it('показывает версию API из ответа сервера', async () => {
const fetchMock = vi.fn().mockResolvedValue({
ok: true,
json: () => Promise.resolve({ status: 'ok', version: 'v1.2.3' }),
});
vi.stubGlobal('fetch', fetchMock);
render(<HealthPage />);
expect(await screen.findByText('v1.2.3')).toBeTruthy();
expect(fetchMock).toHaveBeenCalledWith('/api/health');
});
it('показывает, что API недоступен, если запрос упал', async () => {
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('network')));
render(<HealthPage />);
expect(await screen.findByText('down')).toBeTruthy();
});
});