[ui] LetterSlot: Add the page for A Letter from the Gardener, shown once the author writes it

docs/LETTER.md holds slots as comments only, so the player sees no change
until the author writes. The app bundles the letter at build time, a small
Markdown subset renders without {@html}, only https: and tel: become links,
and lint:copy now reads the letter. Review found turbo replaying a stale
build after the letter changed; docs/LETTER.md is now in its cache key.
This commit is contained in:
2026-11-01 15:39:17 +01:00
parent b871ab9899
commit a200832cfb
23 changed files with 639 additions and 21 deletions
+23
View File
@@ -2,6 +2,8 @@ import AxeBuilder from '@axe-core/playwright';
import { expect, test, type Page } from '@playwright/test';
import { PRODUCT_NAME } from '@rosea/schema';
import { en } from '@rosea/ui/copy';
import { parseLetter } from '@rosea/ui/letter';
import { readFileSync } from 'node:fs';
import { BASE, startStaticServer, type StaticServer } from './static-server.js';
let server: StaticServer;
@@ -104,3 +106,24 @@ test('the shell has no accessibility violations', async ({ page }) => {
const results = await new AxeBuilder({ page }).analyze();
expect(results.violations.map((v) => `${v.id}: ${v.help}`)).toEqual([]);
});
// Tests whichever state docs/LETTER.md is in: empty now, the author's words later.
test('the Letter: no way to it while empty, and it opens from the garden once written', async ({ page }) => {
const written = parseLetter(readFileSync(new URL('../docs/LETTER.md', import.meta.url), 'utf8')).length > 0;
await open(page);
const link = page.getByRole('link', { name: en.letter.title });
if (!written) {
await expect(link).toHaveCount(0);
await page.goto(server.url + '#letter');
await expect(page.getByRole('heading', { level: 1 })).toHaveText(PRODUCT_NAME);
return;
}
await link.click();
await expect(page.getByRole('heading', { level: 1 })).toHaveText(en.letter.title);
const results = await new AxeBuilder({ page }).analyze();
expect(results.violations.map((v) => `${v.id}: ${v.help}`)).toEqual([]);
await page.getByRole('link', { name: en.letter.back }).click();
await expect(page.getByRole('heading', { level: 1 })).toHaveText(PRODUCT_NAME);
});