Public source validation / validate (push) Failing after 3m8s
41 lines
2.1 KiB
TypeScript
41 lines
2.1 KiB
TypeScript
import { cleanup, render, screen } from '@testing-library/react';
|
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
|
|
import { CapacityPage } from '../../src/CapacityPage';
|
|
|
|
afterEach(() => {
|
|
cleanup();
|
|
vi.unstubAllGlobals();
|
|
});
|
|
|
|
describe('CapacityPage forecast qualification', () => {
|
|
it('does not count an insufficient assessment as a forecast', async () => {
|
|
vi.stubGlobal('fetch', vi.fn().mockResolvedValue(new Response(JSON.stringify({
|
|
contractVersion: 'v1', generatedAt: '2026-08-12T01:00:00Z',
|
|
policy: { enabled: true, windowSeconds: 2592000, minPoints: 3, method: 'linear_median_rate' },
|
|
qualifiedCount: 0,
|
|
items: [{ entityId: 'media', name: 'Media', kind: 'share', enabled: true, method: 'insufficient_data', windowSeconds: 2592000, dataPoints: 1, confidence: 'none', currentUsedBytes: 100, capacityBytes: 0, rateBytesPerDay: 0, reason: 'insufficient_points' }],
|
|
}), { status: 200, headers: { 'Content-Type': 'application/json' } })));
|
|
|
|
render(<CapacityPage />);
|
|
|
|
expect(await screen.findByText(/0 gekwalificeerde prognoses/)).toBeVisible();
|
|
expect(screen.getByRole('heading', { name: 'Media' })).toBeVisible();
|
|
expect(screen.getByText('Er zijn minder historische metingen dan het ingestelde minimum.')).toBeVisible();
|
|
expect(screen.queryByText('0 B / 0 B')).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('renders a concrete empty state without a synthetic entity', async () => {
|
|
vi.stubGlobal('fetch', vi.fn().mockResolvedValue(new Response(JSON.stringify({
|
|
contractVersion: 'v1', generatedAt: '2026-08-12T01:00:00Z', reason: 'source_unavailable',
|
|
policy: { enabled: true, windowSeconds: 2592000, minPoints: 3, method: 'linear_median_rate' },
|
|
qualifiedCount: 0, items: [],
|
|
}), { status: 200, headers: { 'Content-Type': 'application/json' } })));
|
|
|
|
render(<CapacityPage />);
|
|
|
|
expect(await screen.findByRole('heading', { name: 'Nog geen bruikbare capaciteitsprognose' })).toBeVisible();
|
|
expect(screen.getByRole('link', { name: 'Bekijk shares en groeihistorie' })).toHaveAttribute('href', '/shares');
|
|
});
|
|
});
|