import { FourOhFourActivityImpl, PenguenoRequest, type BaseRequest, type ServerTrace } from '../lib/index'; import { CollectingTrace, TestTraceable } from './test_utils'; const makeBaseRequest = (overrides: Partial = {}): BaseRequest => ({ url: 'https://example.com/missing', method: 'GET', header: () => ({}), formData: async () => new FormData(), json: async () => ({}), text: async () => '', param: () => undefined, query: () => ({}), queries: () => ({}), ...overrides, }); describe('server/activity/fourohfour (FourOhFourActivityImpl)', () => { beforeEach(() => { jest.spyOn(globalThis.crypto, 'randomUUID').mockReturnValue('00000000-0000-0000-0000-000000000000'); jest.spyOn(Math, 'random').mockReturnValue(0); }); afterEach(() => { jest.restoreAllMocks(); }); test('returns JsonResponse with 404', async () => { const trace = new CollectingTrace(); const req = PenguenoRequest.from(TestTraceable.of(makeBaseRequest(), trace)); const activity = new FourOhFourActivityImpl(); const resp = await activity.fourOhFour(req); expect(resp.status).toBe(404); expect(resp.headers['Content-Type']).toBe('application/json; charset=utf-8'); expect(resp.body()).toContain('"error"'); }); });