Addresses final-review findings: I1 render-generation guard prevents a double-mount /timer leak on rapid re-navigation; I2 adds anonymous-rejection tests for the owner-only POST /speedtest/run and /health/check; M1 CSS comment; M2 cron↔worker dedup note; M4 full 8-byte PNG signature check; M5 card-contract unit test for all 7 cards. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
25 lines
1.1 KiB
JavaScript
25 lines
1.1 KiB
JavaScript
import { describe, it, expect, beforeAll } from 'vitest';
|
|
import request from 'supertest';
|
|
import { setup } from './helpers.js';
|
|
import * as statusRepo from '../../lib/db/repos/service_status.js';
|
|
|
|
let app, ownerHeaders;
|
|
beforeAll(async () => {
|
|
({ app, ownerHeaders } = await setup());
|
|
await statusRepo.upsert({ service_id: 'gitea', status: 'ok', latency_ms: 10, detail: '200' });
|
|
});
|
|
describe('health api', () => {
|
|
it('401 without auth', async () => expect((await request(app).get('/api/health/services')).status).toBe(401));
|
|
it('POST /check rejects anonymous (owner-only mutation)', async () =>
|
|
expect((await request(app).post('/api/health/check')).status).toBe(401));
|
|
it('returns groups with counts + merged cached status', async () => {
|
|
const res = await request(app).get('/api/health/services').set(ownerHeaders);
|
|
expect(res.status).toBe(200);
|
|
const infra = res.body.find(g => g.category === 'infrastructure');
|
|
expect(infra).toBeTruthy();
|
|
expect(infra.healthy).toBeGreaterThanOrEqual(1); // gitea ok
|
|
const gitea = infra.services.find(s => s.id === 'gitea');
|
|
expect(gitea.status).toBe('ok');
|
|
});
|
|
});
|