From 8df9e069387cc8a323472053299d27345784c423 Mon Sep 17 00:00:00 2001 From: David <60177543+davd-gzl@users.noreply.github.com> Date: Mon, 12 Oct 2026 07:48:27 +0000 Subject: [PATCH] Run the scroll-restore e2e test on the busiest snapshot date The test needs more than 30 destinations from Paris, and a blind today+5 days can land on a day with far fewer free MAX seats. That made the daily Pages deploy fail since 10 October. --- scripts/e2e.mjs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/scripts/e2e.mjs b/scripts/e2e.mjs index b752306..306679c 100644 --- a/scripts/e2e.mjs +++ b/scripts/e2e.mjs @@ -96,6 +96,28 @@ function pickRoundTripDates() { } const [RT_DATE, RT_DATE2] = pickRoundTripDates(); +// The scroll-restore scenario needs a long "Where to?" list (more than 30 destinations from +// Paris). Some days in the snapshot have far fewer free MAX seats, so pick the snapshot date +// with the most destinations from Paris instead of a blind now+5d. +function pickBusyDate() { + try { + const raw = JSON.parse(readFileSync(join(DIST, "data", "tgvmax.json"), "utf-8")); + const trains = Array.isArray(raw) ? raw : raw.trains || []; + const today = new Date().toISOString().slice(0, 10); + const dests = new Map(); + for (const t of trains) { + if (t.origine !== P || t.date < today || t.od_happy_card !== "OUI") continue; + if (!dests.has(t.date)) dests.set(t.date, new Set()); + dests.get(t.date).add(t.destination); + } + const [busiest] = [...dests].sort((a, b) => b[1].size - a[1].size || a[0].localeCompare(b[0]))[0] ?? []; + return busiest ?? DATE; + } catch { + return DATE; + } +} +const BUSY_DATE = pickBusyDate(); + // --- tiny assertion harness ------------------------------------------------- const results = []; class Fail extends Error {} @@ -685,7 +707,7 @@ await scenario( for (const [viewport, label] of [[MOBILE, "390px drawer"], [undefined, "1366px column"]]) { await scenario( `history: Back from a route restores the list's scroll (${label})`, - `${BASE}?mode=from&from=${enc(P)}&date=${DATE}`, + `${BASE}?mode=from&from=${enc(P)}&date=${BUSY_DATE}`, async (page) => { assert(await until(async () => (await $count(page, ".results .group-card")) > 30), "precondition: short list"); const scrollTop = () =>