72 lines
2.5 KiB
TypeScript
72 lines
2.5 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 accepts childId param", async ({ request }) => {
|
|
const res = await request.get("/api/curriculum/next?childId=any&topic=lectura")
|
|
expect(res.status()).toBe(200)
|
|
const json = await res.json()
|
|
expect(json).toBeDefined()
|
|
})
|
|
|
|
test("curriculum/grade missing fields returns 400", async ({ request }) => {
|
|
const res = await request.post("/api/curriculum/grade", {
|
|
data: {},
|
|
})
|
|
expect(res.status()).toBe(400)
|
|
const json = await res.json()
|
|
expect(json.error).toBe("Missing required fields")
|
|
})
|
|
|
|
test("curriculum/grade validates required fields", async ({ request }) => {
|
|
const res = await request.post("/api/curriculum/grade", {
|
|
data: { childId: "test", exerciseId: "ex1", skillCode: "test" },
|
|
headers: { "Content-Type": "application/json" },
|
|
})
|
|
expect(res.status()).toBe(400)
|
|
const json = await res.json()
|
|
expect(json.error).toBe("No active session")
|
|
})
|
|
|
|
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")
|
|
})
|
|
})
|