From aaae22f58247128a1e70f48cf1f5255666925617 Mon Sep 17 00:00:00 2001 From: "arrz.dev" <55147716+arrzdev@users.noreply.github.com> Date: Mon, 16 Nov 2026 21:48:35 +0000 Subject: [PATCH 1/6] test(e2e): end-of-article play block on the five guides --- e2e/end-play-cta.spec.ts | 508 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 508 insertions(+) create mode 100644 e2e/end-play-cta.spec.ts diff --git a/e2e/end-play-cta.spec.ts b/e2e/end-play-cta.spec.ts new file mode 100644 index 00000000..32257981 --- /dev/null +++ b/e2e/end-play-cta.spec.ts @@ -0,0 +1,508 @@ +import type { Locator, Page } from "@playwright/test" +import { openApp } from "./support/app" +import { expect, test } from "./support/test" + +// The end of every guide is one block that asks the reader to play: the eight +// bots, a headline about what the page just taught, the computer game, a line +// that says it is free, and the other ways to play (the `design` document on +// TUD-5812, §2 and §3). It replaces the last chapter's bare play block, keeps +// that chapter's anchor, and sits before "Related guides". +// +// The hero's play block is play-block.spec.ts. This file is the end block only. + +const COMPUTER_GAME = "/offline?mode=ai" +const CTA = "Play against the computer" +const MORE = "Other ways to play" +const CAPTION = "Eight bots, Gus to Magnus" +const TRUST = "Free, no sign-up, no download." + +const LOCALES = [ + "de", + "en", + "es", + "fr", + "hi", + "it", + "ja", + "ko", + "nl", + "pl", + "pt", + "tr", + "zh", +] as const + +/** Each page's headline, and the anchor its last chapter had (design §3.3). */ +const PAGES = { + "/rules": { + id: "play", + headline: "Try the rules in a real game", + rail: false, + }, + "/how-to-play": { + id: "play", + headline: "Play your first game", + rail: true, + }, + "/strategy": { + id: "practise", + headline: "Try these tips in a real game", + rail: true, + }, + "/opening-moves": { + id: "practise", + headline: "Try these openings in a real game", + rail: true, + }, + "/starting-positions": { + id: "try-them", + headline: "Try these layouts in a real game", + rail: true, + }, +} as const + +type Path = keyof typeof PAGES +const PATHS = Object.keys(PAGES) as Path[] + +function endBlock(page: Page): Locator { + return page.locator("main [data-end-cta]") +} + +function endButton(page: Page): Locator { + return endBlock(page).getByRole("link", { name: CTA, exact: true }) +} + +function endMore(page: Page): Locator { + return endBlock(page).getByRole("link", { name: MORE, exact: true }) +} + +/** The page in a language: English has no prefix, the others do. */ +function localePath(locale: string, path: string): string { + return locale === "en" ? path : `/${locale}${path}` +} + +// §3.1 and §3.3 in the served HTML: there before any script runs, so a crawler +// and a reader on a slow phone get it too. +test.describe("served HTML", () => { + test.skip( + ({ browserName }) => browserName !== "chromium", + "raw HTTP checks: one browser is enough", + ) + + for (const locale of LOCALES) { + for (const path of PATHS) { + test(`${locale} ${path}: one end block, after the chapters, before the related guides`, async ({ + request, + }) => { + const response = await request.get(localePath(locale, path)) + expect(response.status()).toBe(200) + const served = await response.text() + const html = served.slice( + served.indexOf(""), + ) + + const blocks = [...html.matchAll(/data-end-cta(?=[\s>="])/g)] + expect(blocks).toHaveLength(1) + const block = blocks[0].index ?? -1 + + // after every chapter + const lastChapter = html.lastIndexOf("data-chapter") + expect(block).toBeGreaterThan(lastChapter) + // before the related guides + const related = html.indexOf("data-related-guides") + expect(related).toBeGreaterThan(-1) + expect(block).toBeLessThan(related) + + // one h1 on the page, still + expect(served.match(/]/g) ?? []).toHaveLength(1) + + // the anchor the last chapter had lands on the block + const anchor = html.indexOf(`id="${PAGES[path].id}"`) + expect(anchor).toBeGreaterThan(block) + expect(anchor).toBeLessThan(related) + }) + } + } +}) + +test.describe("in the browser", () => { + for (const path of PATHS) { + test(`${path}: faces, caption, headline, button, trust line, other ways, in that order`, async ({ + page, + }) => { + await openApp(page, path) + const block = endBlock(page) + await expect(block).toHaveCount(1) + + // §3.2: eight faces, decorative, lazy + const faces = block.locator("img") + await expect(faces).toHaveCount(8) + for (const face of await faces.all()) { + await expect(face).toHaveAttribute("alt", "") + await expect(face).toHaveAttribute("loading", "lazy") + } + + const heading = block.getByRole("heading", { level: 2 }) + await expect(heading).toHaveCount(1) + await expect(heading).toHaveText(PAGES[path].headline) + await expect(endButton(page)).toHaveAttribute("href", COMPUTER_GAME) + await expect(endMore(page)).toHaveAttribute("href", "/") + + // reading order: every face, then the words, then the links + const order = await block.evaluate( + (section, labels) => { + const text = section.textContent ?? "" + const lastFace = [...section.querySelectorAll("img")].at(-1) + const caption = [...section.querySelectorAll("*")].find( + (element) => + element.children.length === 0 && + (element.textContent ?? "").trim() === labels.caption, + ) + return { + facesBeforeCaption: + lastFace !== undefined && + caption !== undefined && + Boolean( + lastFace.compareDocumentPosition(caption) & + Node.DOCUMENT_POSITION_FOLLOWING, + ), + offsets: [ + labels.caption, + labels.headline, + labels.cta, + labels.trust, + labels.more, + ].map((label) => text.indexOf(label)), + } + }, + { + caption: CAPTION, + headline: PAGES[path].headline, + cta: CTA, + trust: TRUST, + more: MORE, + }, + ) + expect(order.facesBeforeCaption).toBe(true) + for (const offset of order.offsets) + expect(offset).toBeGreaterThan(-1) + expect(order.offsets).toEqual( + [...order.offsets].sort((a, b) => a - b), + ) + + // §3.3: named by its own headline, and the old anchor is inside it + const headingId = await heading.getAttribute("id") + expect(headingId).toBeTruthy() + await expect(block).toHaveAttribute( + "aria-labelledby", + headingId ?? "", + ) + expect( + await page.evaluate( + (id) => + document.getElementById(id)?.closest("[data-end-cta]") !== + null && document.getElementById(id) !== null, + PAGES[path].id, + ), + ).toBe(true) + }) + } + + // §3.3: the rail and the contents list still lead to it; /rules has no entry + test.describe("the chapter list", () => { + test.use({ viewport: { width: 1440, height: 900 } }) + + for (const path of PATHS) { + test(`${path}: ${PAGES[path].rail ? "its entry lands on the block" : "has no entry for the block"}`, async ({ + page, + }) => { + await openApp(page, path) + const entry = page.locator( + `[data-manual-rail] [data-rail-link="${PAGES[path].id}"]`, + ) + if (!PAGES[path].rail) { + await expect(entry).toHaveCount(0) + return + } + await entry.click() + await expect(page).toHaveURL(new RegExp(`#${PAGES[path].id}$`)) + await expect( + endBlock(page).getByRole("heading", { level: 2 }), + ).toBeInViewport() + }) + } + }) +}) + +test.describe("layout", () => { + test.skip( + ({ browserName }) => browserName !== "chromium", + "geometry at set widths: one engine is enough", + ) + + // §3.4: a band from edge to edge, the button one line across it + for (const viewport of [ + { width: 320, height: 664 }, + { width: 390, height: 664 }, + ]) { + test.describe(`phone at ${viewport.width}`, () => { + test.use({ viewport }) + + for (const path of PATHS) { + test(`${path}: a full-width band, the button one line`, async ({ + page, + }) => { + await openApp(page, path) + const panel = endBlock(page).locator("[data-end-cta-panel]") + await panel.scrollIntoViewIfNeeded() + + const band = await panel.boundingBox() + expect(band).not.toBeNull() + expect(Math.abs(band?.x ?? -1)).toBeLessThanOrEqual(0.5) + expect( + Math.abs((band?.x ?? 0) + (band?.width ?? 0) - viewport.width), + ).toBeLessThanOrEqual(0.5) + + const button = await endButton(page).boundingBox() + expect(button).not.toBeNull() + // one line: the 54 px minimum, a second line makes it ~75 px + expect(Math.round(button?.height ?? 0)).toBe(54) + expect( + Math.abs((button?.width ?? 0) - (viewport.width - 40)), + ).toBeLessThanOrEqual(1) + + // §3.6 + const more = await endMore(page).boundingBox() + expect(more?.height ?? 0).toBeGreaterThanOrEqual(44) + + expect( + await page.evaluate( + () => + document.documentElement.scrollWidth <= + document.documentElement.clientWidth, + ), + ).toBe(true) + }) + } + }) + } + + // §3.5: a card, the button and the link on one row, the trust line under + for (const viewport of [ + { width: 640, height: 900 }, + { width: 768, height: 1024 }, + { width: 1440, height: 900 }, + ]) { + test.describe(`card at ${viewport.width}`, () => { + test.use({ viewport }) + + for (const path of PATHS) { + test(`${path}: a rounded card, one row of actions, the trust line under`, async ({ + page, + }) => { + await openApp(page, path) + const panel = endBlock(page).locator("[data-end-cta-panel]") + await panel.scrollIntoViewIfNeeded() + + const card = await panel.evaluate((element) => { + const style = getComputedStyle(element) + const probe = document.createElement("span") + probe.style.cssText = + "position:absolute;visibility:hidden;width:62ch" + element.appendChild(probe) + const measure = probe.getBoundingClientRect().width + probe.remove() + return { + radius: style.borderTopLeftRadius, + border: style.borderTopWidth, + width: element.getBoundingClientRect().width, + measure, + } + }) + expect(card.radius).toBe("16px") + expect(card.border).toBe("1px") + expect(card.width).toBeLessThanOrEqual(card.measure + 1) + + const button = await endButton(page).boundingBox() + const more = await endMore(page).boundingBox() + const trust = await endBlock(page) + .getByText(TRUST, { exact: true }) + .boundingBox() + expect(button && more && trust).toBeTruthy() + if (!button || !more || !trust) return + + expect(button.height).toBeGreaterThanOrEqual(54) + expect(more.height).toBeGreaterThanOrEqual(44) + // one row + expect(more.x).toBeGreaterThan(button.x + button.width) + const middle = button.y + button.height / 2 + expect(more.y).toBeLessThan(middle) + expect(more.y + more.height).toBeGreaterThan(middle) + // the trust line under the row, from its left edge + expect(trust.y).toBeGreaterThanOrEqual( + button.y + button.height - 1, + ) + expect(Math.abs(trust.x - button.x)).toBeLessThanOrEqual(1) + }) + } + }) + } + + // §3.7: 200% text at 390, nothing clipped, nothing on top of something else + test.describe("200% text at 390", () => { + test.use({ viewport: { width: 390, height: 844 } }) + + for (const path of PATHS) { + test(`${path}: nothing clipped or overlapping`, async ({ page }) => { + await openApp(page, path) + await page.evaluate(() => { + document.documentElement.style.fontSize = "200%" + }) + const block = endBlock(page) + await block.scrollIntoViewIfNeeded() + + const problems = await block.evaluate((section) => { + const found: string[] = [] + const leaves = [ + ...section.querySelectorAll("h2, a, p, span, img"), + ].filter( + (element) => + !element.querySelector("h2, a, p, span, img") && + (element.getBoundingClientRect().width > 0 || + element.tagName === "IMG"), + ) + for (const element of leaves) { + if ( + element.tagName !== "IMG" && + element.scrollWidth > element.clientWidth + 1 + ) + found.push(`clipped: ${element.textContent?.trim()}`) + if ( + element.scrollHeight > element.clientHeight + 1 && + element.clientHeight > 0 + ) + found.push(`clipped: ${element.textContent?.trim()}`) + } + // text blocks never overlap each other (the faces overlap by design) + const texts = leaves + .filter((element) => element.tagName !== "IMG") + .map((element) => ({ + label: element.textContent?.trim() ?? "", + box: element.getBoundingClientRect(), + })) + for (const [index, a] of texts.entries()) { + for (const b of texts.slice(index + 1)) { + const overlaps = + a.box.left < b.box.right - 1 && + b.box.left < a.box.right - 1 && + a.box.top < b.box.bottom - 1 && + b.box.top < a.box.bottom - 1 + if (overlaps) found.push(`overlap: ${a.label} / ${b.label}`) + } + } + return found + }) + expect(problems).toEqual([]) + expect( + await page.evaluate( + () => + document.documentElement.scrollWidth <= + document.documentElement.clientWidth, + ), + ).toBe(true) + }) + } + }) +}) + +// §3.6: a keyboard user sees where they are on both links +test.describe("focus", () => { + test.use({ viewport: { width: 390, height: 844 } }) + + test("the button and the link show a focus ring from the keyboard", async ({ + page, + }) => { + await openApp(page, "/strategy") + await endMore(page).focus() + await page.keyboard.press("Shift+Tab") + await expect(endButton(page)).toBeFocused() + + const ring = (locator: Locator) => + locator.evaluate((element) => { + const style = getComputedStyle(element) + return ( + (style.outlineStyle !== "none" && + Number.parseFloat(style.outlineWidth) > 0) || + style.boxShadow !== "none" + ) + }) + expect(await ring(endButton(page))).toBe(true) + await page.keyboard.press("Tab") + await expect(endMore(page)).toBeFocused() + expect(await ring(endMore(page))).toBe(true) + }) +}) + +// §3.8: the block reads in the reader's language +test.describe("in French", () => { + test.skip( + ({ browserName }) => browserName !== "chromium", + "copy check: one browser is enough", + ) + + test("/fr/strategy: no English in the block", async ({ page }) => { + await openApp(page, "/fr/strategy") + const text = (await endBlock(page).textContent()) ?? "" + for (const english of [ + CAPTION, + PAGES["/strategy"].headline, + CTA, + TRUST, + MORE, + ]) { + expect(text).not.toContain(english) + } + }) +}) + +// §3.9: the end button starts a computer game and it is counted as before +test.describe("starting a game", () => { + // No service worker: on webkit one test's worker can claim another test's + // page and reload it mid-game (game-entry.spec.ts). + test.use({ serviceWorkers: "block" }) + + test("the end button on /strategy opens a computer game and sends one start", async ({ + page, + }) => { + const starts: Array> = [] + page.on("request", (request) => { + if (request.method() !== "POST") return + if (!request.url().endsWith("/api/v1/events/game")) return + const event = JSON.parse(request.postData() ?? "{}") + if (event.kind === "start") starts.push(event) + }) + + await openApp(page, "/strategy") + await endButton(page).scrollIntoViewIfNeeded() + await endButton(page).click() + + await expect(page).toHaveURL( + (url) => `${url.pathname}${url.search}` === COMPUTER_GAME, + ) + await expect( + page + .getByRole("button", { name: "Resign" }) + .or( + page.getByRole("tab", { name: "vs Computer", selected: true }), + ), + ).toBeVisible() + // a fresh browser lands on the board and the game starts by itself; the + // setup screen needs its own Start + const setup = page.getByRole("button", { name: /^Start/ }) + if (await setup.isVisible()) await setup.click() + + await expect.poll(() => starts.length).toBe(1) + expect(starts[0]).toMatchObject({ mode: "ai", entry: "strategy" }) + }) +}) From 458cfdbec8ffa5bf418fb759f40528083013a7bd Mon Sep 17 00:00:00 2001 From: "arrz.dev" <55147716+arrzdev@users.noreply.github.com> Date: Mon, 16 Nov 2026 22:02:33 +0000 Subject: [PATCH 2/6] feat(game): translate the end-of-article play block and the rules title --- apps/game/src/i18n/locales/de/game.json | 9 ++++++++- apps/game/src/i18n/locales/es/game.json | 9 ++++++++- apps/game/src/i18n/locales/fr/game.json | 9 ++++++++- apps/game/src/i18n/locales/hi/game.json | 9 ++++++++- apps/game/src/i18n/locales/it/game.json | 9 ++++++++- apps/game/src/i18n/locales/ja/game.json | 9 ++++++++- apps/game/src/i18n/locales/ko/game.json | 9 ++++++++- apps/game/src/i18n/locales/nl/game.json | 9 ++++++++- apps/game/src/i18n/locales/pl/game.json | 9 ++++++++- apps/game/src/i18n/locales/pt/game.json | 9 ++++++++- apps/game/src/i18n/locales/tr/game.json | 9 ++++++++- apps/game/src/i18n/locales/zh/game.json | 9 ++++++++- 12 files changed, 96 insertions(+), 12 deletions(-) diff --git a/apps/game/src/i18n/locales/de/game.json b/apps/game/src/i18n/locales/de/game.json index d4e2ff3d..cec52570 100644 --- a/apps/game/src/i18n/locales/de/game.json +++ b/apps/game/src/i18n/locales/de/game.json @@ -103,8 +103,15 @@ "moves_one": "{{count}} Zug", "moves_other": "{{count}} Züge" }, + "end_cta": { + "trust": "Kostenlos, ohne Anmeldung, ohne Download.", + "rules": "Probiere die Regeln in einer echten Partie", + "strategy": "Probiere diese Tipps in einer echten Partie", + "openings": "Probiere diese Eröffnungen in einer echten Partie", + "positions": "Probiere diese Aufstellungen in einer echten Partie" + }, "rules": { - "title": "So wird gespielt", + "title": "Regeln", "heading": "Abalone-Regeln: so wird gespielt", "intro": "Abalone ist ein Strategiespiel für zwei Personen auf einem sechseckigen Brett. Jede Seite hat 14 Kugeln. Du gewinnst, wenn du sechs Kugeln deines Gegners vom Brett schiebst. Diese Seite erklärt jede Regel. Wenn du bereit bist, spiele Abalone online oder probiere es gegen den Computer.", "goal": { diff --git a/apps/game/src/i18n/locales/es/game.json b/apps/game/src/i18n/locales/es/game.json index 2ef9fb17..34744594 100644 --- a/apps/game/src/i18n/locales/es/game.json +++ b/apps/game/src/i18n/locales/es/game.json @@ -103,8 +103,15 @@ "moves_one": "{{count}} jugada", "moves_other": "{{count}} jugadas" }, + "end_cta": { + "trust": "Gratis, sin registro, sin descargas.", + "rules": "Prueba las reglas en una partida real", + "strategy": "Prueba estos consejos en una partida real", + "openings": "Prueba estas aperturas en una partida real", + "positions": "Prueba estas posiciones en una partida real" + }, "rules": { - "title": "Cómo jugar", + "title": "Reglas", "heading": "Reglas de Abalone: cómo jugar", "intro": "Abalone es un juego de estrategia para dos jugadores en un tablero hexagonal. Cada jugador tiene 14 bolas. Ganas si empujas seis bolas del rival fuera del tablero. Esta página explica todas las reglas. Cuando estés listo, juega a Abalone en línea o pruébalo contra el ordenador.", "goal": { diff --git a/apps/game/src/i18n/locales/fr/game.json b/apps/game/src/i18n/locales/fr/game.json index 93795b63..9d2b3ff0 100644 --- a/apps/game/src/i18n/locales/fr/game.json +++ b/apps/game/src/i18n/locales/fr/game.json @@ -103,8 +103,15 @@ "moves_one": "{{count}} coup", "moves_other": "{{count}} coups" }, + "end_cta": { + "trust": "Gratuit, sans inscription, sans téléchargement.", + "rules": "Essayez les règles dans une vraie partie", + "strategy": "Essayez ces conseils dans une vraie partie", + "openings": "Essayez ces ouvertures dans une vraie partie", + "positions": "Essayez ces dispositions dans une vraie partie" + }, "rules": { - "title": "Comment jouer", + "title": "Règles", "heading": "Règles d'Abalone : comment jouer", "intro": "Abalone est un jeu de stratégie pour deux joueurs sur un plateau hexagonal. Chaque joueur a 14 billes. Tu gagnes en poussant six billes adverses hors du plateau. Cette page explique toutes les règles. Quand tu es prêt, joue à Abalone en ligne ou essaie contre l'ordinateur.", "goal": { diff --git a/apps/game/src/i18n/locales/hi/game.json b/apps/game/src/i18n/locales/hi/game.json index a43014a6..76b442e5 100644 --- a/apps/game/src/i18n/locales/hi/game.json +++ b/apps/game/src/i18n/locales/hi/game.json @@ -103,8 +103,15 @@ "moves_one": "{{count}} चाल", "moves_other": "{{count}} चालें" }, + "end_cta": { + "trust": "मुफ़्त, साइन-अप के बिना, डाउनलोड के बिना।", + "rules": "नियमों को असली खेल में आज़माएँ", + "strategy": "इन सुझावों को असली खेल में आज़माएँ", + "openings": "इन शुरुआती चालों को असली खेल में आज़माएँ", + "positions": "इन शुरुआती जमावटों को असली खेल में आज़माएँ" + }, "rules": { - "title": "कैसे खेलें", + "title": "नियम", "heading": "Abalone के नियम: कैसे खेलें", "intro": "Abalone षट्कोणीय बोर्ड पर दो खिलाड़ियों का रणनीति वाला खेल है। हर खिलाड़ी के पास 14 गोलियाँ होती हैं। विरोधी की छह गोलियाँ बोर्ड से बाहर धकेलकर आप जीतते हैं। यह पेज हर नियम समझाता है। जब आप तैयार हों, Abalone ऑनलाइन खेलें या कंप्यूटर के खिलाफ आज़माएँ।", "goal": { diff --git a/apps/game/src/i18n/locales/it/game.json b/apps/game/src/i18n/locales/it/game.json index 61dafb08..baac577d 100644 --- a/apps/game/src/i18n/locales/it/game.json +++ b/apps/game/src/i18n/locales/it/game.json @@ -103,8 +103,15 @@ "moves_one": "{{count}} mossa", "moves_other": "{{count}} mosse" }, + "end_cta": { + "trust": "Gratis, senza registrazione, senza download.", + "rules": "Prova le regole in una partita vera", + "strategy": "Prova questi consigli in una partita vera", + "openings": "Prova queste aperture in una partita vera", + "positions": "Prova queste disposizioni in una partita vera" + }, "rules": { - "title": "Come si gioca", + "title": "Regole", "heading": "Regole di Abalone: come si gioca", "intro": "Abalone è un gioco di strategia per due giocatori su una scacchiera esagonale. Ogni giocatore ha 14 biglie. Vinci spingendo sei biglie avversarie fuori dal tabellone. Questa pagina spiega ogni regola. Quando sei pronto, gioca ad Abalone online oppure prova contro il computer.", "goal": { diff --git a/apps/game/src/i18n/locales/ja/game.json b/apps/game/src/i18n/locales/ja/game.json index 2d501222..32b0362a 100644 --- a/apps/game/src/i18n/locales/ja/game.json +++ b/apps/game/src/i18n/locales/ja/game.json @@ -102,8 +102,15 @@ "game_over": "対局終了", "moves": "{{count}}手" }, + "end_cta": { + "trust": "無料、登録不要、ダウンロード不要。", + "rules": "ルールを実際の対局で試そう", + "strategy": "このコツを実際の対局で試そう", + "openings": "この序盤の手を実際の対局で試そう", + "positions": "この初期配置を実際の対局で試そう" + }, "rules": { - "title": "遊び方", + "title": "ルール", "heading": "アバロンのルール:遊び方", "intro": "アバロン(Abalone)は、六角形の盤で遊ぶ2人用の戦略ゲームです。各プレイヤーのボールは14個。相手のボールを6個、盤の外へ押し出すと勝ちです。このページでは全部のルールを説明します。準備ができたら、オンラインでアバロンをプレイするか、コンピューターと対戦してみましょう。", "goal": { diff --git a/apps/game/src/i18n/locales/ko/game.json b/apps/game/src/i18n/locales/ko/game.json index dcfad79a..8be12e6c 100644 --- a/apps/game/src/i18n/locales/ko/game.json +++ b/apps/game/src/i18n/locales/ko/game.json @@ -102,8 +102,15 @@ "game_over": "게임 종료", "moves": "{{count}}수" }, + "end_cta": { + "trust": "무료, 가입 없음, 다운로드 없음.", + "rules": "규칙을 실제 게임에서 써 보세요", + "strategy": "이 팁을 실제 게임에서 써 보세요", + "openings": "이 오프닝을 실제 게임에서 써 보세요", + "positions": "이 배치를 실제 게임에서 써 보세요" + }, "rules": { - "title": "게임 방법", + "title": "규칙", "heading": "아발론 규칙: 게임 방법", "intro": "아발론(Abalone)은 육각형 판에서 두 사람이 하는 전략 게임입니다. 각 플레이어는 구슬 14개를 가집니다. 상대 구슬 여섯 개를 판 밖으로 밀어내면 이깁니다. 이 페이지에서 모든 규칙을 설명합니다. 준비가 되었다면 온라인으로 아발론을 플레이하거나 컴퓨터와 대결해 보세요.", "goal": { diff --git a/apps/game/src/i18n/locales/nl/game.json b/apps/game/src/i18n/locales/nl/game.json index 40495dc1..83701838 100644 --- a/apps/game/src/i18n/locales/nl/game.json +++ b/apps/game/src/i18n/locales/nl/game.json @@ -103,8 +103,15 @@ "moves_one": "{{count}} zet", "moves_other": "{{count}} zetten" }, + "end_cta": { + "trust": "Gratis, zonder account, zonder download.", + "rules": "Probeer de regels in een echt potje", + "strategy": "Probeer deze tips in een echt potje", + "openings": "Probeer deze openingen in een echt potje", + "positions": "Probeer deze opstellingen in een echt potje" + }, "rules": { - "title": "Zo speel je", + "title": "Regels", "heading": "Abalone-regels: zo speel je", "intro": "Abalone is een strategiespel voor twee spelers op een zeshoekig bord. Elke speler heeft 14 ballen. Je wint door zes ballen van je tegenstander van het bord te duwen. Op deze pagina staan alle regels. Ben je klaar, speel dan Abalone online of probeer het tegen de computer.", "goal": { diff --git a/apps/game/src/i18n/locales/pl/game.json b/apps/game/src/i18n/locales/pl/game.json index 59a67a09..343483ee 100644 --- a/apps/game/src/i18n/locales/pl/game.json +++ b/apps/game/src/i18n/locales/pl/game.json @@ -104,8 +104,15 @@ "moves_few": "{{count}} ruchy", "moves_many": "{{count}} ruchów" }, + "end_cta": { + "trust": "Za darmo, bez rejestracji, bez pobierania.", + "rules": "Wypróbuj zasady w prawdziwej grze", + "strategy": "Wypróbuj te wskazówki w prawdziwej grze", + "openings": "Wypróbuj te otwarcia w prawdziwej grze", + "positions": "Wypróbuj te ustawienia w prawdziwej grze" + }, "rules": { - "title": "Jak grać", + "title": "Zasady", "heading": "Zasady Abalone: jak grać", "intro": "Abalone to strategiczna gra dla dwóch osób, rozgrywana na sześciokątnej planszy. Każdy gracz ma 14 kul. Wygrywasz, wypychając poza planszę sześć kul przeciwnika. Ta strona wyjaśnia wszystkie zasady. Gdy będziesz gotowy, zagraj w Abalone online albo spróbuj z komputerem.", "goal": { diff --git a/apps/game/src/i18n/locales/pt/game.json b/apps/game/src/i18n/locales/pt/game.json index d76ffd10..a97a0ee5 100644 --- a/apps/game/src/i18n/locales/pt/game.json +++ b/apps/game/src/i18n/locales/pt/game.json @@ -103,8 +103,15 @@ "moves_one": "{{count}} jogada", "moves_other": "{{count}} jogadas" }, + "end_cta": { + "trust": "Grátis, sem registo, sem transferência.", + "rules": "Experimenta as regras num jogo a sério", + "strategy": "Experimenta estas dicas num jogo a sério", + "openings": "Experimenta estas aberturas num jogo a sério", + "positions": "Experimenta estas posições num jogo a sério" + }, "rules": { - "title": "Como jogar", + "title": "Regras", "heading": "Regras de Abalone: como jogar", "intro": "O Abalone é um jogo de estratégia para dois jogadores num tabuleiro hexagonal. Cada jogador tem 14 bolas. Ganhas ao empurrar seis bolas do adversário para fora do tabuleiro. Esta página explica todas as regras. Quando estiveres pronto, joga Abalone online ou experimenta contra o computador.", "goal": { diff --git a/apps/game/src/i18n/locales/tr/game.json b/apps/game/src/i18n/locales/tr/game.json index 8d19cd05..b3039c82 100644 --- a/apps/game/src/i18n/locales/tr/game.json +++ b/apps/game/src/i18n/locales/tr/game.json @@ -102,8 +102,15 @@ "game_over": "Oyun bitti", "moves": "{{count}} hamle" }, + "end_cta": { + "trust": "Ücretsiz, kayıt yok, indirme yok.", + "rules": "Kuralları gerçek bir oyunda dene", + "strategy": "Bu ipuçlarını gerçek bir oyunda dene", + "openings": "Bu açılışları gerçek bir oyunda dene", + "positions": "Bu dizilişleri gerçek bir oyunda dene" + }, "rules": { - "title": "Nasıl oynanır", + "title": "Kurallar", "heading": "Abalone kuralları: nasıl oynanır", "intro": "Abalone, altıgen bir tahtada oynanan iki kişilik bir strateji oyunudur. Her oyuncunun 14 bilyesi vardır. Rakibin altı bilyesini tahtadan dışarı iterek kazanırsın. Bu sayfa tüm kuralları anlatır. Hazır olduğunda Abalone'u çevrimiçi oyna ya da bilgisayara karşı dene.", "goal": { diff --git a/apps/game/src/i18n/locales/zh/game.json b/apps/game/src/i18n/locales/zh/game.json index 3b328357..8427b481 100644 --- a/apps/game/src/i18n/locales/zh/game.json +++ b/apps/game/src/i18n/locales/zh/game.json @@ -102,8 +102,15 @@ "game_over": "对局结束", "moves": "{{count}} 步" }, + "end_cta": { + "trust": "免费,无需注册,无需下载。", + "rules": "在真实对局中试试规则", + "strategy": "在真实对局中试试这些技巧", + "openings": "在真实对局中试试这些开局", + "positions": "在真实对局中试试这些布局" + }, "rules": { - "title": "游戏玩法", + "title": "规则", "heading": "Abalone 规则:怎么玩", "intro": "Abalone 是一款在六边形棋盘上进行的双人策略游戏。每位玩家有 14 颗棋子。把对手的六颗棋子推出棋盘,你就赢了。本页讲解全部规则。准备好后,可以在线玩 Abalone,也可以先和电脑对战试试。", "goal": { From 0a209bc5b46f8bba856f1d4c83c1500cf7bf9c89 Mon Sep 17 00:00:00 2001 From: "arrz.dev" <55147716+arrzdev@users.noreply.github.com> Date: Mon, 16 Nov 2026 22:14:01 +0000 Subject: [PATCH 3/6] feat(game): one end block that asks the reader to play on the five guides Replaces the last chapter's bare play block on /rules, /how-to-play, /strategy, /opening-moves and /starting-positions with EndPlayCta: the eight bots, a headline about the page, the computer game, a line that says it is free, and the other ways to play. The block keeps the old chapter's anchor. The /rules top bar now reads Rules, not How to play. --- apps/game/src/components/end-play-cta.tsx | 123 ++++++++++++++++++ apps/game/src/components/play-block.tsx | 13 +- apps/game/src/i18n/locales/en/game.json | 9 +- .../src/routing/pages/how-to-play.page.tsx | 11 +- .../src/routing/pages/opening-moves.page.tsx | 10 +- apps/game/src/routing/pages/rules.page.tsx | 12 +- .../routing/pages/starting-positions.page.tsx | 11 +- apps/game/src/routing/pages/strategy.page.tsx | 10 +- 8 files changed, 178 insertions(+), 21 deletions(-) create mode 100644 apps/game/src/components/end-play-cta.tsx diff --git a/apps/game/src/components/end-play-cta.tsx b/apps/game/src/components/end-play-cta.tsx new file mode 100644 index 00000000..89e2ff13 --- /dev/null +++ b/apps/game/src/components/end-play-cta.tsx @@ -0,0 +1,123 @@ +import { cn } from "@repo/nativ/utils" +import { Link } from "@tanstack/react-router" +import type { ReactNode } from "react" +import { useTranslation } from "react-i18next" +import { BotFace } from "@/components/bot-face" +import { + PLAY_BUTTON_CLASS, + TEXT_LINK_CLASS, +} from "@/components/play-block" +import { COMPUTER_GAME } from "@/hooks/use-play-actions" +import { BOT_LEVELS } from "@/i18n/bots" + +export type EndPlayCtaProps = { + /** The headline's anchor: the id the page's last chapter had, so the old link still lands here. */ + id: string + /** What the page just taught, as a reason to play it. */ + headline: string + /** The button's label: it opens the computer game. */ + cta: string + /** The link's label: it goes home, to the choice of ways to play. */ + more: string + /** Reading that belongs to the end of the page, under the panel. */ + children?: ReactNode +} + +/** + * The end of a guide: one block that asks the reader to play (the `design` + * document on TUD-5812, §2). + * + * The hero's `PlayBlock` is the same button, so at the end of the article it + * read as one more chapter. This one stops the reader: the eight bots say + * somebody is waiting, the headline says what to try, and the line under the + * button says it costs nothing and asks for no account. + * + * Not a `Chapter`: it has no number and no hairline of its own on a phone. The + * panel is a band from edge to edge there, where the button keeps one line at + * 320, and a card from `sm`. The page's column pads by 20px up to `sm`, which + * is what the band's negative margin takes back. + * + * Static and a plain link, so it works before the page has hydrated. + */ +export function EndPlayCta({ + id, + headline, + cta, + more, + children, +}: EndPlayCtaProps) { + const { t } = useTranslation() + + return ( +
+
+ {/* The eight of them: "eight bots" is a claim, the faces are the + evidence. Overlapped, and the row padded by the overlap so the last + face's tail does not push the caption off. */} +
+
+ {BOT_LEVELS.map((level) => ( + + ))} +
+ + {t("common:home.bots_caption")} + +
+ +

+ {headline} +

+ + {/* One column on a phone: the button, the trust line, the link. From + `sm` the button and the link are a row and the trust line is under + both, which is why the three are placed rather than flowed. */} +
+ + {cta} + +

+ {t("game:end_cta.trust")} +

+ + {more} + +
+
+ + {children && ( +
+ {children} +
+ )} +
+ ) +} diff --git a/apps/game/src/components/play-block.tsx b/apps/game/src/components/play-block.tsx index 596e4711..31b853f2 100644 --- a/apps/game/src/components/play-block.tsx +++ b/apps/game/src/components/play-block.tsx @@ -4,9 +4,15 @@ import { Link } from "@tanstack/react-router" import { buttonClassName } from "@/components/ui/button" import { COMPUTER_GAME } from "@/hooks/use-play-actions" -const TEXT_LINK_CLASS = +export const TEXT_LINK_CLASS = "font-semibold text-brand-light underline underline-offset-2 hover:text-white" +/** The computer-game button: a thumb wide on a phone, as wide as its label from `sm`. */ +export const PLAY_BUTTON_CLASS = cn( + buttonClassName("primary", "lg"), + "h-auto min-h-[54px] w-full py-3 text-center text-balance sm:w-auto sm:px-8", +) + export type PlayBlockProps = { /** The button's label: it opens the computer game. */ cta: string @@ -44,10 +50,7 @@ export function PlayBlock({ moreLink = { to: "/" }, onPlay, }: PlayBlockProps) { - const ctaClassName = cn( - buttonClassName("primary", "lg"), - "h-auto min-h-[54px] w-full py-3 text-center text-balance sm:w-auto sm:px-8", - ) + const ctaClassName = PLAY_BUTTON_CLASS return (
diff --git a/apps/game/src/i18n/locales/en/game.json b/apps/game/src/i18n/locales/en/game.json index 59122d5e..c11ca9f0 100644 --- a/apps/game/src/i18n/locales/en/game.json +++ b/apps/game/src/i18n/locales/en/game.json @@ -104,7 +104,7 @@ "moves_other": "{{count}} moves" }, "rules": { - "title": "How to play", + "title": "Rules", "heading": "Abalone rules: how to play", "intro": "You play Abalone by taking turns to move up to three marbles one space. A bigger group can push a smaller one. Push six of your opponent's marbles off the board to win. When you are ready, play Abalone online or try it against the computer.", "goal": { @@ -606,5 +606,12 @@ "more": "Other ways to play" }, "rules_link": "New to the game? Follow how to play Abalone step by step." + }, + "end_cta": { + "trust": "Free, no sign-up, no download.", + "rules": "Try the rules in a real game", + "strategy": "Try these tips in a real game", + "openings": "Try these openings in a real game", + "positions": "Try these layouts in a real game" } } diff --git a/apps/game/src/routing/pages/how-to-play.page.tsx b/apps/game/src/routing/pages/how-to-play.page.tsx index b474a01a..292124b1 100644 --- a/apps/game/src/routing/pages/how-to-play.page.tsx +++ b/apps/game/src/routing/pages/how-to-play.page.tsx @@ -1,5 +1,6 @@ import { createFileRoute, Link } from "@tanstack/react-router" import { Trans, useTranslation } from "react-i18next" +import { EndPlayCta } from "@/components/end-play-cta" import { LanguageVersions } from "@/components/language-versions" import type { ManualChapter } from "@/components/manual/chapter" import { Chapter } from "@/components/manual/chapter" @@ -119,8 +120,12 @@ function HowToPlayPage() { /> - - {playBlock} +

-
+ diff --git a/apps/game/src/routing/pages/opening-moves.page.tsx b/apps/game/src/routing/pages/opening-moves.page.tsx index f785de18..27f2059f 100644 --- a/apps/game/src/routing/pages/opening-moves.page.tsx +++ b/apps/game/src/routing/pages/opening-moves.page.tsx @@ -1,5 +1,6 @@ import { createFileRoute, Link } from "@tanstack/react-router" import { Trans, useTranslation } from "react-i18next" +import { EndPlayCta } from "@/components/end-play-cta" import { LanguageVersions } from "@/components/language-versions" import type { ManualChapter } from "@/components/manual/chapter" import { Chapter } from "@/components/manual/chapter" @@ -117,9 +118,12 @@ function OpeningMovesPage() { - - {playBlock} - + diff --git a/apps/game/src/routing/pages/rules.page.tsx b/apps/game/src/routing/pages/rules.page.tsx index 13c5bbcc..c0465f84 100644 --- a/apps/game/src/routing/pages/rules.page.tsx +++ b/apps/game/src/routing/pages/rules.page.tsx @@ -4,6 +4,7 @@ import { cn } from "@repo/nativ/utils" import { createFileRoute, Link } from "@tanstack/react-router" import type { ReactNode } from "react" import { Trans, useTranslation } from "react-i18next" +import { EndPlayCta } from "@/components/end-play-cta" import { LanguageVersions } from "@/components/language-versions" import type { ManualChapter } from "@/components/manual/chapter" import { Chapter, Plate } from "@/components/manual/chapter" @@ -513,9 +514,14 @@ function RulesPage() {

-
- {playBlock} -
+ {/* The end of the page is a block of its own, not a chapter: the + contents list has no entry for it */} + diff --git a/apps/game/src/routing/pages/starting-positions.page.tsx b/apps/game/src/routing/pages/starting-positions.page.tsx index b94b6fe2..67b9d44e 100644 --- a/apps/game/src/routing/pages/starting-positions.page.tsx +++ b/apps/game/src/routing/pages/starting-positions.page.tsx @@ -1,6 +1,7 @@ import { cn } from "@repo/nativ/utils" import { createFileRoute, Link } from "@tanstack/react-router" import { Trans, useTranslation } from "react-i18next" +import { EndPlayCta } from "@/components/end-play-cta" import { LanguageVersions } from "@/components/language-versions" import type { ManualChapter } from "@/components/manual/chapter" import { Chapter, Plate } from "@/components/manual/chapter" @@ -255,8 +256,12 @@ function StartingPositionsPage() { - - {playBlock} +

-
+
diff --git a/apps/game/src/routing/pages/strategy.page.tsx b/apps/game/src/routing/pages/strategy.page.tsx index 4eeae43b..311faf62 100644 --- a/apps/game/src/routing/pages/strategy.page.tsx +++ b/apps/game/src/routing/pages/strategy.page.tsx @@ -1,5 +1,6 @@ import { createFileRoute, Link } from "@tanstack/react-router" import { Trans, useTranslation } from "react-i18next" +import { EndPlayCta } from "@/components/end-play-cta" import { LanguageVersions } from "@/components/language-versions" import type { ManualChapter } from "@/components/manual/chapter" import { Chapter } from "@/components/manual/chapter" @@ -187,9 +188,12 @@ function StrategyPage() { /> - - {playBlock} - + From fc003626147efb4d9745158d2cf3ced85aaf48af Mon Sep 17 00:00:00 2001 From: "arrz.dev" <55147716+arrzdev@users.noreply.github.com> Date: Mon, 16 Nov 2026 22:14:02 +0000 Subject: [PATCH 4/6] test(e2e): the end block on the guides replaces the last chapter in the older specs --- e2e/play-block.spec.ts | 6 +++--- e2e/strategy-page.spec.ts | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/e2e/play-block.spec.ts b/e2e/play-block.spec.ts index 1325f3c8..b1aa73df 100644 --- a/e2e/play-block.spec.ts +++ b/e2e/play-block.spec.ts @@ -35,13 +35,13 @@ const LOCALES = [ /** Where each page's two blocks sit, as the section ids around them. */ const PAGES = { "/rules": { - // (b) after the FAQ, last on the page - end: "faq", + // (b) the end block, after the FAQ (end-play-cta.spec.ts) + end: "play", // the intro's own links, in reading order intro: ["play Abalone online", "try it against the computer"], }, "/strategy": { - // (b) inside "Practise" + // (b) the end block, which keeps the old "Practise" anchor end: "practise", intro: ["free game against the computer", "Abalone rules"], }, diff --git a/e2e/strategy-page.spec.ts b/e2e/strategy-page.spec.ts index 6c4c5dac..77a5c9e9 100644 --- a/e2e/strategy-page.spec.ts +++ b/e2e/strategy-page.spec.ts @@ -23,7 +23,9 @@ const SECTIONS = [ ["mistakes", "Common mistakes"], ["computer", "How strong is the computer?"], ["faq", "Frequently asked"], - ["practise", "Practise"], + //the end block (end-play-cta.spec.ts): the rail's entry is "Practise", the + //block's own headline is not + ["practise", "Try these tips in a real game"], //the links to the other guides close the page (related-guides.spec.ts) ["related-guides", "Related guides"], ] as const @@ -124,7 +126,7 @@ test.describe("served HTML", () => { } }) - // the Practise card's actions are the last play block + // the end block's actions are the last play block // (e2e/play-block.spec.ts, content-play-block on TUD-820) test("ends with a way to practise, and the other ways to play", async ({ request, From 5a0e3f215f3ccc3251be2ae4ff2b4386059224ac Mon Sep 17 00:00:00 2001 From: "arrz.dev" <55147716+arrzdev@users.noreply.github.com> Date: Mon, 16 Nov 2026 23:27:58 +0000 Subject: [PATCH 5/6] fix(game): the end block's caption is 14px, the smallest text a guide holds --- apps/game/src/components/end-play-cta.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/game/src/components/end-play-cta.tsx b/apps/game/src/components/end-play-cta.tsx index 89e2ff13..d3e44bcd 100644 --- a/apps/game/src/components/end-play-cta.tsx +++ b/apps/game/src/components/end-play-cta.tsx @@ -71,7 +71,7 @@ export function EndPlayCta({ /> ))}
- + {t("common:home.bots_caption")} From 3eddf14d217372fde209b6cb40d82d0cc10b044e Mon Sep 17 00:00:00 2001 From: "arrz.dev" <55147716+arrzdev@users.noreply.github.com> Date: Mon, 16 Nov 2026 23:27:59 +0000 Subject: [PATCH 6/6] test(e2e): the home preload budget grows with the end block's copy --- e2e/home-render-budget.spec.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/e2e/home-render-budget.spec.ts b/e2e/home-render-budget.spec.ts index 23af1cb2..e3c38c3d 100644 --- a/e2e/home-render-budget.spec.ts +++ b/e2e/home-render-budget.spec.ts @@ -22,7 +22,8 @@ const INLINE_CSS_BUDGET_BYTES = 93_968 // went from about 2.97 s to 2.63 s on a local Lighthouse run (2026-11-08). // Measured 45 (was 34). const MODULEPRELOAD_COUNT_BUDGET = 49 -// Measured 799,780 bytes in CI (799,736 before the modal and the sheet +// Measured 800,279 bytes in CI (799,806 before the end-of-article play block +// on the guides; 799,780 before the French how-to-play page; 799,736 before the modal and the sheet // skipped an Escape that a select list inside already used; 791,089 before i18next 27 and // react-i18next 18, whose larger core now shares a chunk with the auth // provider; 791,064 @@ -37,7 +38,7 @@ const MODULEPRELOAD_COUNT_BUDGET = 49 // library moved to the first signed-in connect, 818,327 before the auth SDK // moved to first use). CI is the measure: its build bakes in the commit's // short sha where a local one writes "dev", 62 bytes more here. -const MODULEPRELOAD_JS_BUDGET_BYTES = 799_806 +const MODULEPRELOAD_JS_BUDGET_BYTES = 800_279 test.skip( ({ browserName }) => browserName !== "chromium",