diff --git a/.github/run-tests.mjs b/.github/run-tests.mjs new file mode 100644 index 0000000..aedc6a6 --- /dev/null +++ b/.github/run-tests.mjs @@ -0,0 +1,30 @@ +// Runner headless de tests.html para CI (GitHub Actions). +// Requiere: un servidor HTTP sirviendo el repo en :8741 y playwright instalado. +// Uso local: python -m http.server 8741 & node .github/run-tests.mjs +import { chromium } from "playwright"; + +const browser = await chromium.launch(); +const page = await browser.newPage(); +page.on("pageerror", e => console.error("ERROR DE PÁGINA:", e.message)); + +await page.goto("http://localhost:8741/tests.html"); + +// Esperar a que el summary muestre el resultado final ("N/M tests") +await page.waitForFunction(() => { + const s = document.getElementById("summary"); + return s && /\d+\/\d+ tests/.test(s.textContent); +}, { timeout: 60000 }); + +const summary = await page.evaluate(() => document.getElementById("summary").textContent); +const ok = await page.evaluate(() => document.getElementById("summary").className === "ok"); +console.log(summary); + +if (!ok) { + const fails = await page.evaluate(() => + [...document.querySelectorAll("#results .err")].map(e => e.parentElement.textContent) + ); + for (const f of fails) console.error("\nFALLO: " + f); +} + +await browser.close(); +process.exit(ok ? 0 : 1); diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..6bd36f3 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,30 @@ +# Corre la suite de regresión (tests.html) en Chromium headless. +# tests.html es dev-only: el producto distribuible sigue siendo solo index.html. +name: tests + +on: + push: + branches: [main] + pull_request: + +jobs: + regression: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Instalar Playwright (Chromium) + run: | + npm init -y > /dev/null + npm install playwright > /dev/null + npx playwright install --with-deps chromium + + - name: Servir el repo y ejecutar la suite + run: | + python3 -m http.server 8741 & + sleep 1 + node .github/run-tests.mjs diff --git a/CLAUDE.md b/CLAUDE.md index d646df8..5c5f503 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -35,9 +35,11 @@ python -m http.server 8741 All tests must pass before committing changes to `index.html`. +CI: `.github/workflows/tests.yml` runs the full suite headless (Playwright + Chromium, via `.github/run-tests.mjs`) on every push to main and every PR. + ## Architecture -Everything is in `index.html` (~1955 lines): CSS in `