Evolve summarizer into AI service with OCR support
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
import React from 'react';
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
|
||||
import AdminSystemPage from './pages/AdminSystemPage';
|
||||
import { I18nProvider } from './i18n/I18nProvider';
|
||||
import { api } from './api';
|
||||
|
||||
const mockedApi = api as jest.Mocked<typeof api>;
|
||||
|
||||
describe('AdminSystemPage', () => {
|
||||
it('renders AI service health, latency, and OCR readiness', async () => {
|
||||
mockedApi.get.mockImplementation((url: string) => {
|
||||
if (url === '/admin/system') {
|
||||
return Promise.resolve({
|
||||
data: {
|
||||
environment: 'Production',
|
||||
contentRoot: '/app',
|
||||
version: '1.2.3',
|
||||
commitSha: 'abc1234',
|
||||
buildStamp: '2026-03-23 11:00 UTC',
|
||||
storage: { dataRoot: '/data', dbPath: '/data/jobtracker.db', dbExists: true, dbSizeBytes: 2048, companyCount: 3, jobCount: 7, deletedCount: 1 },
|
||||
email: { enabled: true, host: 'smtp.example.test', port: 587, enableSsl: true, from: 'noreply@example.test', fromName: 'Jobbjakt' },
|
||||
database: { provider: 'mariadb', looksConfigured: true, canConnect: true, target: 'server=db', usesFileStorage: false, warning: null },
|
||||
runtime: { framework: '.NET 9', osDescription: 'Linux', processArchitecture: 'X64', machineName: 'app-01' },
|
||||
auth: { required: true, hasJwtKey: true, googleConfigured: true, gmailConfigured: true },
|
||||
ai: {
|
||||
healthy: true,
|
||||
model: 'distilbart',
|
||||
device: 'cpu',
|
||||
gpuAvailable: false,
|
||||
gpuName: null,
|
||||
ocrAvailable: true,
|
||||
ocrLanguages: 'eng',
|
||||
healthLatencyMs: 12.4,
|
||||
probeLatencyMs: 25.8,
|
||||
lastProbeAt: '2026-03-23T10:00:00Z',
|
||||
lastProbeSuccessAt: '2026-03-23T10:00:00Z',
|
||||
lastProbeFailureAt: null,
|
||||
probeFailures: 0,
|
||||
requests: 18,
|
||||
cacheHits: 9,
|
||||
cacheMisses: 9,
|
||||
failures: 0,
|
||||
averageLatencyMs: 42.2,
|
||||
ocrRequests: 5,
|
||||
ocrFailures: 0,
|
||||
averageOcrLatencyMs: 88.4,
|
||||
lastOcrSuccessAt: '2026-03-23T10:05:00Z',
|
||||
lastOcrFailureAt: null,
|
||||
lastSuccessAt: '2026-03-23T10:04:00Z',
|
||||
lastFailureAt: null,
|
||||
lastError: null,
|
||||
},
|
||||
},
|
||||
} as any);
|
||||
}
|
||||
return Promise.resolve({ data: {} } as any);
|
||||
});
|
||||
|
||||
render(
|
||||
<I18nProvider>
|
||||
<AdminSystemPage />
|
||||
</I18nProvider>,
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('AI service')).toBeTruthy();
|
||||
});
|
||||
|
||||
expect(screen.getByText(/25.8 ms probe/i)).toBeTruthy();
|
||||
expect(screen.getByText('OCR eng')).toBeTruthy();
|
||||
expect(screen.getByText('OCR avg latency')).toBeTruthy();
|
||||
expect(screen.getByText('88.4 ms')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user