Recette 1e : titre du bilan sur l'issue, notation du moteur partout, boutons de 48 px en paysage, filtre en accent-soft, longue partie ; tests navigateur adaptés au bilan
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ced004edb0
commit
663ef35b51
+102
-4
@@ -22,7 +22,7 @@
|
||||
|
||||
import { mkdirSync } from "node:fs";
|
||||
import { chromium, firefox } from "playwright";
|
||||
import { hiddenUnderActionBar } from "./recette.mjs";
|
||||
import { hiddenUnderActionBar, tallButtons } from "./recette.mjs";
|
||||
|
||||
const [base, browserName, shots] = process.argv.slice(2);
|
||||
const browserType = { chromium, firefox }[browserName];
|
||||
@@ -116,6 +116,8 @@ async function capture(name) {
|
||||
hidden.length === 0,
|
||||
`${name} ${size.width}x${size.height} : caché sous la barre d'action : ${hidden.join(", ")}`,
|
||||
);
|
||||
const tall = await tallButtons(page);
|
||||
check(tall.length === 0, `${name} ${size.width}x${size.height} : boutons étirés : ${tall.join(", ")}`);
|
||||
await page.screenshot({ path: `${dir}/${name}-${size.width}x${size.height}.png` });
|
||||
captures++;
|
||||
}
|
||||
@@ -172,8 +174,19 @@ async function play(dice, halfMoves) {
|
||||
|
||||
await startFrom(BEAROFF);
|
||||
await play([6, 1], [[6, 5], [5, 0]]);
|
||||
// L'ordinateur, sûr de gagner, double : le joueur passe.
|
||||
// L'ordinateur, sûr de gagner, double. La ligne du maître commente le
|
||||
// coup : sa feuille d'explication écrit le coup joué dans la notation du
|
||||
// moteur, comme le bilan et l'analyse plus bas.
|
||||
await until("double de l'ordinateur", () => !document.getElementById("drop").hidden);
|
||||
await until("ligne du maître", () => !document.getElementById("advice-line").hidden);
|
||||
await page.click("#advice-line");
|
||||
await until("feuille du maître", () => document.getElementById("explain-mine") !== null);
|
||||
await page.click("#explain-mine");
|
||||
const sheetLegend = await page.textContent("#explain-legend");
|
||||
check(sheetLegend.includes(" 6/off,"), `feuille du maître : ${sheetLegend}`);
|
||||
await page.click("#explain-done");
|
||||
await until("feuille fermée", () => document.getElementById("explain-veil").hidden);
|
||||
// Le joueur passe.
|
||||
await page.click("#drop");
|
||||
// Le panneau de fin de partie, puis le bilan à sa place, à son adresse.
|
||||
await until(
|
||||
@@ -203,8 +216,11 @@ const summary = await page.evaluate(() => ({
|
||||
}));
|
||||
const id = summary.hash.split("/")[2];
|
||||
check(summary.panelHidden, "le panneau de fin de partie reste sous le bilan");
|
||||
check(summary.title === "Vous passez", `titre : ${summary.title}`);
|
||||
check(summary.reading.startsWith("1 point pour lui."), `lecture : ${summary.reading}`);
|
||||
check(summary.title === "L'ordinateur gagne la partie simple", `titre : ${summary.title}`);
|
||||
check(
|
||||
summary.reading.startsWith("Vous avez passé son double : 1 point pour lui. "),
|
||||
`lecture : ${summary.reading}`,
|
||||
);
|
||||
check(summary.reading.includes("D'après mon analyse"), `lecture : ${summary.reading}`);
|
||||
check(!summary.reading.includes("!"), `lecture : ${summary.reading}`);
|
||||
// Le refus du double, juste ; le coup 6/5/off, grosse erreur ; le jet
|
||||
@@ -309,6 +325,19 @@ const best = await page.evaluate(() => ({
|
||||
move: document.getElementById("analysis-board").dataset.move,
|
||||
}));
|
||||
check(best.move === "best" && best.legend.includes("6/off 1/off"), `maître : ${best.legend}`);
|
||||
// Une seule notation, celle du moteur : le même coup s'écrit pareil dans
|
||||
// la feuille du maître, le bilan, la liste et le visualiseur.
|
||||
await page.click("#analysis-mine");
|
||||
const notations = await page.evaluate(() => ({
|
||||
legend: document.getElementById("analysis-legend").textContent,
|
||||
row: document.querySelector('#analysis-list .analysis-row[data-turn="1"] .row-move')
|
||||
?.textContent,
|
||||
}));
|
||||
check(
|
||||
notations.legend.includes(" 6/off,") && notations.row === "6/off",
|
||||
`notation : visualiseur « ${notations.legend} », liste « ${notations.row} »`,
|
||||
);
|
||||
await page.click("#analysis-best");
|
||||
await capture("5-visualiseur");
|
||||
log("analyse : courbe, point touché, clavier, liste filtrée, visualiseur");
|
||||
|
||||
@@ -370,6 +399,75 @@ check(branches.length === 2, `branches : ${branches.join(" | ")}`);
|
||||
check(branches[0].startsWith("Partie d'origine : 1 coup, finie"), `origine : ${branches[0]}`);
|
||||
log(`rejouer d'ici : ${branches.join(" | ")}`);
|
||||
|
||||
// ------------------------------------------- Une partie plus longue
|
||||
|
||||
// Pour juger la courbe en usage réel (Chromium seulement) : une longue
|
||||
// course (tests/reference/positions.json, race-2) jouée jusqu'au bout,
|
||||
// le joueur prenant à chaque fois le premier pion jouable et sa première
|
||||
// arrivée, puis son analyse complète.
|
||||
if (full) {
|
||||
await startFrom("cLezAQBwN2cGAA");
|
||||
for (let actions = 0; ; actions++) {
|
||||
check(actions < 2000, "la longue partie ne finit pas");
|
||||
const what = await page.evaluate(() => {
|
||||
if (document.body.classList.contains("busy")) {
|
||||
return null;
|
||||
}
|
||||
if (!document.getElementById("summary-veil").hidden) {
|
||||
return "over";
|
||||
}
|
||||
if (!document.getElementById("panel-veil").hidden) {
|
||||
return "panel";
|
||||
}
|
||||
const usable = (id) => {
|
||||
const b = document.getElementById(id);
|
||||
return !b.hidden && !b.disabled;
|
||||
};
|
||||
for (const id of ["take", "skip", "confirm", "roll"]) {
|
||||
if (usable(id)) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
if (document.querySelector("#board .hit.can-land")) {
|
||||
return "land";
|
||||
}
|
||||
return document.querySelector("#board .hit.can-move") ? "move" : null;
|
||||
});
|
||||
if (what === "over") {
|
||||
break;
|
||||
}
|
||||
if (what === null || what === "panel") {
|
||||
await sleep(100);
|
||||
continue;
|
||||
}
|
||||
const target = {
|
||||
take: "#take",
|
||||
skip: "#skip",
|
||||
confirm: "#confirm",
|
||||
roll: "#roll",
|
||||
land: "#board .hit.can-land",
|
||||
move: "#board .hit.can-move",
|
||||
}[what];
|
||||
await page.locator(target).first().click();
|
||||
await idle();
|
||||
}
|
||||
await until("bilan de la longue partie", () =>
|
||||
document.getElementById("summary")?.dataset.ready === "true");
|
||||
await page.click("#summary-analysis");
|
||||
await until("analyse complète de la longue partie", () => {
|
||||
const bands = document.querySelectorAll("#analysis-curve .curve-band").length;
|
||||
return (
|
||||
!document.getElementById("analysis").hidden &&
|
||||
bands >= 20 &&
|
||||
document.querySelectorAll("#analysis-curve .curve-dot").length === bands
|
||||
);
|
||||
}, null, 600_000);
|
||||
const turns = await page.locator("#analysis-curve .curve-band").count();
|
||||
await page.evaluate(() => window.scrollTo(0, 0));
|
||||
await capture("7-analyse-partie-longue");
|
||||
log(`longue partie : ${turns} coups, courbe complète`);
|
||||
}
|
||||
|
||||
const csp = await page.evaluate(() => window.__csp);
|
||||
for (const violation of csp) {
|
||||
problems.push(`politique de sécurité : ${violation}`);
|
||||
|
||||
Reference in New Issue
Block a user