Files
edueasy/e2e/exercise-content.spec.ts
T

79 lines
2.8 KiB
TypeScript

import { test, expect } from "@playwright/test"
import { readFileSync } from "fs"
import { join } from "path"
const lecturaStages = 9
const numerosStages = 8
test.describe("Exercise content integrity", () => {
for (let i = 1; i <= lecturaStages; i++) {
test(`lectura etapa ${i} file exists and has exercises`, () => {
const file = join(process.cwd(), "curriculum", "lectura", `etapa-${i}.ts`)
const content = readFileSync(file, "utf-8")
expect(content.length).toBeGreaterThan(200)
expect(content).toContain("stage")
expect(content).toContain("exercises")
})
}
for (let i = 1; i <= numerosStages; i++) {
test(`numeros etapa ${i} file exists and has exercises`, () => {
const file = join(process.cwd(), "curriculum", "numeros", `etapa-${i}.ts`)
const content = readFileSync(file, "utf-8")
expect(content.length).toBeGreaterThan(200)
expect(content).toContain("stage")
expect(content).toContain("exercises")
})
}
test("curriculum index imports all stages via loadStages", () => {
const file = join(process.cwd(), "curriculum", "index.ts")
const content = readFileSync(file, "utf-8")
expect(content).toContain("initCurriculum")
expect(content).toContain("loadStages")
expect(content).toContain("[1, 2, 3, 4, 5, 6, 7, 8, 9]")
})
test("type definitions export required types", () => {
const file = join(process.cwd(), "curriculum", "types.ts")
const content = readFileSync(file, "utf-8")
expect(content).toContain("export type Exercise")
expect(content).toContain("export interface Stage")
expect(content).toContain("export type ExerciseType")
expect(content).toContain("export type ErrorType")
})
test("exercise dispatcher maps all exercise types", () => {
const file = join(process.cwd(), "components", "exercises", "exercise-dispatcher.tsx")
const content = readFileSync(file, "utf-8")
const types = ["sensibilizacion", "conciencia", "trazo", "eleccion", "emparejar", "secuencia", "palabra", "problema", "lectura"]
for (const t of types) {
expect(content).toContain(t)
}
})
test("all exercise component files exist", () => {
const components = [
"ejercicio-sensibilizacion",
"ejercicio-conciencia",
"ejercicio-eleccion",
"ejercicio-secuencia",
"ejercicio-palabra",
"ejercicio-lectura",
"ejercicio-trazo",
"exercise-dispatcher",
]
for (const c of components) {
const file = join(process.cwd(), "components", "exercises", `${c}.tsx`)
const content = readFileSync(file, "utf-8")
expect(content.length).toBeGreaterThan(100)
}
})
test("TTS route exists", () => {
const file = join(process.cwd(), "app", "api", "tts", "route.ts")
const content = readFileSync(file, "utf-8")
expect(content).toContain("espeak-ng")
})
})