Some checks failed
CI / build-and-test (pull_request) Has been cancelled
- Add PLAN.md and sync backend docs, .env.example, API doc (404 details) - Document mock DB and PORT/API_PORT in docs/backend.md; README monorepo + frontend/.env.example - Migration 002: finish_place column, status registered; mapper and mock DB updated - Frontend: registered status, finishPlace, calendar year/month filters, pace sparkline - Extract createApp for tests; supertest + tsx; GitHub Actions CI Made-with: Cursor
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import request from "supertest";
|
|
import { createApp } from "../src/app";
|
|
|
|
const app = createApp();
|
|
|
|
test("GET /health returns ok", async () => {
|
|
const res = await request(app).get("/health").expect(200);
|
|
assert.equal(res.body.status, "ok");
|
|
});
|
|
|
|
test("GET /ready succeeds with mock database", async () => {
|
|
const res = await request(app).get("/ready").expect(200);
|
|
assert.equal(res.body.status, "ready");
|
|
assert.equal(res.body.db, "connected");
|
|
});
|
|
|
|
test("GET /races rejects invalid year", async () => {
|
|
const res = await request(app).get("/races?year=bad").expect(400);
|
|
assert.equal(res.body.error, "validation_error");
|
|
assert.ok(Array.isArray(res.body.details));
|
|
});
|
|
|
|
test("GET /races rejects month out of range", async () => {
|
|
const res = await request(app).get("/races?month=13").expect(400);
|
|
assert.equal(res.body.error, "validation_error");
|
|
});
|
|
|
|
test("GET /races accepts year and month", async () => {
|
|
const res = await request(app).get("/races?year=2026&month=5").expect(200);
|
|
assert.ok(Array.isArray(res.body));
|
|
});
|
|
|
|
test("GET /races/:id returns not_found", async () => {
|
|
const res = await request(app).get("/races/does-not-exist").expect(404);
|
|
assert.equal(res.body.error, "not_found");
|
|
assert.ok(Array.isArray(res.body.details));
|
|
});
|