WOD du jour composé par l'app, hors ligne (5c)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pierre MARTIN
2026-11-23 03:00:37 +01:00
co-authored by Claude Opus 5.5
parent 442b3f0a56
commit 7194530b38
9 changed files with 340 additions and 16 deletions
+28 -3
View File
@@ -42,6 +42,8 @@ const server = http.createServer((req, res) => {
});
let failures = 0;
/** Les derniers messages de la page (console, erreurs), pour le diagnostic d'un arrêt. */
const pageLog = [];
/** Page en cours, pour une capture si le parcours s'interrompt. */
let lastPage = null;
/** @param {string} scheme @param {boolean} cond @param {string} msg */
@@ -69,7 +71,8 @@ function check(scheme, cond, msg) {
const page = await ctx.newPage();
lastPage = page;
const errors = [];
page.on("pageerror", (e) => errors.push(String(e)));
page.on("pageerror", (e) => { errors.push(String(e)); pageLog.push("pageerror: " + String(e)); });
page.on("console", (m) => pageLog.push(`${m.type()}: ${m.text()}`.slice(0, 300)));
page.on("console", (m) => { if (m.type() === "error") errors.push(m.text()); });
const ok = (cond, msg) => check(scheme, cond, msg);
const shot = (name, full = false) => page.screenshot({ path: `${outDir}/${scheme}-${name}.png`, fullPage: full });
@@ -576,7 +579,19 @@ function check(scheme, cond, msg) {
await go("#/");
await page.getByRole("link", { name: /^WOD/ }).click();
await settle();
ok(await page.locator("h1").textContent() === "Références" && await page.getByRole("link", { name: /Fran · For Time/ }).isVisible(), "catalogue des WOD de référence");
ok(await page.locator("h1").textContent() === "WOD" && await page.getByRole("link", { name: /Fran · For Time/ }).isVisible(), "catalogue des WOD de référence");
// WOD du jour (lot 5c) : composé par l'app, un autre tirage dans l'adresse, le même en rouvrant.
const daily = page.locator(".wod-daily");
ok(await daily.getByRole("heading", { name: "WOD du jour" }).isVisible() && await daily.locator(".wod-move").count() >= 2, "WOD du jour composé par l'app");
const firstDraw = await daily.locator(".wod-moves").innerText();
await daily.getByRole("button", { name: "Un autre" }).click();
ok(page.url().endsWith("#/wod?tirage=2"), "un autre tirage, dans l'adresse : " + page.url().split("#")[1]);
const secondDraw = await daily.locator(".wod-moves").innerText();
await shot("24a-wod-du-jour");
await go("#/wod?tirage=2");
ok(await page.locator(".wod-daily .wod-moves").innerText() === secondDraw, "même tirage, même WOD");
await go("#/wod");
ok(await page.locator(".wod-daily .wod-moves").innerText() === firstDraw, "tirage 1 retrouvé");
await page.getByRole("link", { name: /Cindy · AMRAP 20 min/ }).click();
await settle();
ok(page.url().endsWith("#/wod/cindy") && await page.getByText("Scaled : ").isVisible(), "fiche de Cindy, avec sa variante scaled");
@@ -631,7 +646,17 @@ function check(scheme, cond, msg) {
process.exit(failures ? 1 : 0);
})().catch(async (e) => {
console.error(e);
if (lastPage) await lastPage.screenshot({ path: `${outDir}/erreur.png`, fullPage: true }).catch(() => {});
if (lastPage) {
await lastPage.screenshot({ path: `${outDir}/erreur.png`, fullPage: true }).catch(() => {});
// De quoi comprendre une page restée vide : état du document, scripts chargés, erreurs.
const diag = await lastPage.evaluate(() => ({
url: location.href, readyState: document.readyState, bodyChildren: document.body?.children.length ?? null,
scripts: performance.getEntriesByType("resource").filter((r) => /\.js$/.test(r.name)).length,
slowest: performance.getEntriesByType("resource").sort((a, b) => b.duration - a.duration).slice(0, 3).map((r) => `${r.name.split("/").pop()} ${Math.round(r.duration)} ms`),
})).catch((err) => ({ evaluate: String(err) }));
console.error("Diagnostic :", JSON.stringify(diag));
console.error("Messages de la page :", JSON.stringify(pageLog.slice(-15)));
}
process.exit(1);
});