- Botón 'Volver' en todas las sesiones de ejercicios (ExerciseSession) - Botón 'Cambiar perfil' en las 3 home pages (Isabella/Francesca/Sebastián) - Páginas inline de Isabella migradas a ExerciseSession (elimina código duplicado) - APIs con try/catch: curriculum/next, dashboard/summary, fsrs/next, children - Validación childId en curriculum/next (404 si no existe) - /api/health endpoint para Docker healthcheck - .env.example, .dockerignore, README.md creados - docker-compose.yml con healthcheck en app service - Test E2E: health endpoint + childId validation - 62/62 tests pasan, TS exit 0
73 lines
2.4 KiB
TypeScript
73 lines
2.4 KiB
TypeScript
import { test, expect } from "@playwright/test"
|
|
|
|
test.describe("Curriculum API", () => {
|
|
test("TTS endpoint generates audio", async ({ request }) => {
|
|
const res = await request.get("/api/tts?text=hola%20mundo")
|
|
expect(res.ok()).toBeTruthy()
|
|
expect(res.headers()["content-type"]).toBe("audio/wav")
|
|
const body = await res.body()
|
|
expect(body.length).toBeGreaterThan(1000)
|
|
})
|
|
|
|
test("TTS requires text param", async ({ request }) => {
|
|
const res = await request.get("/api/tts")
|
|
expect(res.status()).toBe(400)
|
|
const json = await res.json()
|
|
expect(json.error).toContain("text param")
|
|
})
|
|
|
|
test("TTS text too long returns 400", async ({ request }) => {
|
|
const long = "a".repeat(250)
|
|
const res = await request.get(`/api/tts?text=${long}`)
|
|
expect(res.status()).toBe(400)
|
|
})
|
|
|
|
test("curriculum/next requires childId", async ({ request }) => {
|
|
const res = await request.get("/api/curriculum/next")
|
|
expect(res.status()).toBe(400)
|
|
const json = await res.json()
|
|
expect(json.error).toContain("childId")
|
|
})
|
|
|
|
test("curriculum/next rejects non-existent childId", async ({ request }) => {
|
|
const res = await request.get("/api/curriculum/next?childId=nonexistent&topic=lectura")
|
|
expect(res.status()).toBe(404)
|
|
const json = await res.json()
|
|
expect(json.error).toContain("not found")
|
|
})
|
|
|
|
test("curriculum/grade missing fields returns 400", async ({ request }) => {
|
|
const res = await request.post("/api/curriculum/grade", {
|
|
data: {},
|
|
headers: { "Content-Type": "application/json" },
|
|
})
|
|
expect(res.status()).toBe(400)
|
|
const json = await res.json()
|
|
expect(json.error).toBe("Missing required fields")
|
|
})
|
|
|
|
|
|
|
|
test("curriculum/progress requires childId", async ({ request }) => {
|
|
const res = await request.get("/api/curriculum/progress")
|
|
expect(res.status()).toBe(400)
|
|
const json = await res.json()
|
|
expect(json.error).toContain("childId")
|
|
})
|
|
|
|
test("dashboard/summary requires childId", async ({ request }) => {
|
|
const res = await request.get("/api/dashboard/summary")
|
|
expect(res.status()).toBe(400)
|
|
const json = await res.json()
|
|
expect(json.error).toContain("childId")
|
|
})
|
|
|
|
test("health endpoint returns ok status", async ({ request }) => {
|
|
const res = await request.get("/api/health")
|
|
expect(res.status()).toBe(200)
|
|
const json = await res.json()
|
|
expect(json.status).toBe("ok")
|
|
expect(json.timestamp).toBeDefined()
|
|
})
|
|
})
|