Recette 1l : libellés de la courbe à 12 px, moment décisif en fin de match, ligne du match, Crawford, tuiles
La courbe du match suit sa taille réelle (viewBox recalculé, redessinée à chaque changement de taille) ; un contrôle de la recette vérifie les 12 px. Le moment décisif sur la fin du match garde l'anneau or seul. Ligne du match alignée à gauche, « contre Débutant ». « · Crawford » dans l'en-tête de l'analyse. Une seule légende sous les tuiles, avec la fiche. « Sur ce double passé ». Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
36bb9be384
commit
991a52787d
@@ -307,7 +307,35 @@ const losses = await page.evaluate(() =>
|
||||
[...document.querySelectorAll("#match-summary .match-loss")].map((e) => e.textContent));
|
||||
check(losses.every((t) => /^−?\d+,\d\s%( de chances de gagner le match)?$/.test(t)),
|
||||
`pertes : ${JSON.stringify(losses)}`);
|
||||
await capture("1-bilan-du-match");
|
||||
/** Recette : chaque texte de la courbe fait au moins 12 px à l'écran
|
||||
* (taille de la police, mise à l'échelle du viewBox). */
|
||||
async function curveTextsReadable(where) {
|
||||
const small = await page.evaluate(() => {
|
||||
const svg = document.getElementById("match-curve");
|
||||
const box = svg.getBoundingClientRect();
|
||||
const view = svg.viewBox.baseVal;
|
||||
const scale = Math.min(box.width / view.width, box.height / view.height);
|
||||
return [...svg.querySelectorAll("text")]
|
||||
.map((t) => ({ text: t.textContent, px: parseFloat(getComputedStyle(t).fontSize) * scale }))
|
||||
.filter((t) => t.px < 11.95)
|
||||
.map((t) => `« ${t.text} » ${t.px.toFixed(1)} px`);
|
||||
});
|
||||
check(small.length === 0, `${where} : libellés de la courbe trop petits : ${small.join(", ")}`);
|
||||
}
|
||||
await curveTextsReadable("portrait");
|
||||
// Le moment décisif sur la fin du match : l'anneau or seul, et la légende
|
||||
// le dit.
|
||||
const legend = await page.evaluate(() => ({
|
||||
items: [...document.querySelectorAll(".match-legend li")].map((li) => li.textContent),
|
||||
endDot: document.querySelector("#match-curve .match-mark-end") !== null,
|
||||
}));
|
||||
const decisiveAtEnd = legend.items.includes("Moment décisif, fin du match");
|
||||
check(decisiveAtEnd ? !legend.endDot && legend.items.length === 2 : legend.endDot && legend.items.length === 3,
|
||||
`légende de la courbe : ${JSON.stringify(legend)}`);
|
||||
// Les tuiles : le chiffre seul, l'unité en une ligne dessous.
|
||||
check((await page.textContent("#match-tiles-caption")).startsWith("Taux d'erreur, en millièmes par décision"),
|
||||
"légende des tuiles");
|
||||
await capture("1-bilan-du-match", () => curveTextsReadable("capture"));
|
||||
|
||||
// La courbe touchée : la bulle (partie, coup, score, chances), un lien vers
|
||||
// la décision.
|
||||
@@ -345,7 +373,7 @@ await until("analyse d'une partie du match", () =>
|
||||
/^#\/parties\/[a-z0-9-]+\/analyse\/\d+$/.test(location.hash) &&
|
||||
!document.getElementById("analysis-match").hidden);
|
||||
const header = await page.textContent("#analysis-match-title");
|
||||
check(new RegExp(`^Partie \\d sur ${games} · \\d–\\d$`).test(header), `en-tête de l'analyse : « ${header} »`);
|
||||
check(new RegExp(`^Partie \\d sur ${games} · \\d–\\d( · Crawford)?$`).test(header), `en-tête de l'analyse : « ${header} »`);
|
||||
await capture("3-analyse-partie-de-match", async () => {
|
||||
await page.evaluate(() => window.scrollTo(0, 0));
|
||||
});
|
||||
@@ -365,6 +393,12 @@ const line = await page.evaluate((ids) => {
|
||||
const item = document.querySelector("#games .games-match");
|
||||
return {
|
||||
title: item.querySelector("strong").textContent,
|
||||
caption: item.querySelector(".caption").textContent,
|
||||
aligned: (() => {
|
||||
const strong = item.querySelector("strong").getBoundingClientRect();
|
||||
const caption = item.querySelector(".caption").getBoundingClientRect();
|
||||
return Math.abs(strong.left - caption.left) < 1;
|
||||
})(),
|
||||
strokes: item.querySelectorAll(".match-stroke").length,
|
||||
won: item.querySelectorAll(".match-stroke.won").length,
|
||||
href: item.querySelector("a").getAttribute("href"),
|
||||
@@ -374,6 +408,7 @@ const line = await page.evaluate((ids) => {
|
||||
};
|
||||
}, bilan.gameIds);
|
||||
check(/^Match en 5 points · gagné 5–\d$/.test(line.title), `ligne du match : « ${line.title} »`);
|
||||
check(/· contre Débutant$/.test(line.caption) && line.aligned, `détail de la ligne du match : ${JSON.stringify(line)}`);
|
||||
check(line.strokes === games && line.won >= 2, `traits du match : ${JSON.stringify(line)}`);
|
||||
check(line.href === matchHash, `la ligne du match ouvre ${line.href}`);
|
||||
check(line.others === 0, `${line.others} parties du match listées à part`);
|
||||
|
||||
Reference in New Issue
Block a user