[ui] DomiUi: Rosea's buttons and town search on @domi/ui v1.0.4 (CPAL-1.0, vendored by its own tool into packages/domi-ui), the licence credit at the foot of every screen, the README's copy line and public-domain sources; before-and-after pictures by pnpm look:shots

This commit is contained in:
2026-11-23 00:59:50 +01:00
parent 295e6ba59a
commit 8018268821
79 changed files with 8554 additions and 222 deletions
+90
View File
@@ -0,0 +1,90 @@
import { mkdirSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { expect, test, type Browser, type Page } from '@playwright/test';
import { en } from '@rosea/ui/copy';
import { openRing, pastGardener } from './garden.js';
import { startStaticServer, type StaticServer } from './static-server.js';
/**
* Every screen with a control, photographed from the BUILT PWA in the light and the dark, on a phone and a desktop:
* the before-and-after pictures a change of look needs (domi-ui.md; @domi/ui docs/INTEGRATE.md §0). This makes
* pictures, not assertions, so it has its own config and `pnpm test:e2e` never runs it.
*
* ROSEA_LOOK=before pnpm look:shots writes e2e/look/before/<theme>-<device>-<screen>.png (git-ignored)
*
* Nothing is read from a player: a fresh garden, no town until the search is shown, a fixed day in March.
*/
const LABEL = process.env['ROSEA_LOOK'] ?? 'now';
const OUT = fileURLToPath(new URL(`./look/${LABEL}/`, import.meta.url));
const ZONE = 'Europe/Prague';
const DAY = Date.parse('2026-03-10T08:00:00+01:00');
let server: StaticServer;
test.beforeAll(async () => {
mkdirSync(OUT, { recursive: true });
server = await startStaticServer();
});
test.afterAll(async () => {
await server.close();
});
test.describe.configure({ mode: 'serial', timeout: 240_000 });
async function photograph(browser: Browser, theme: 'light' | 'dark', phone: boolean): Promise<void> {
const device = phone ? 'phone' : 'desktop';
const context = await browser.newContext({
timezoneId: ZONE,
locale: 'en-US',
colorScheme: theme,
reducedMotion: 'reduce',
...(phone
? { viewport: { width: 360, height: 800 }, deviceScaleFactor: 2, isMobile: true, hasTouch: true }
: { viewport: { width: 1280, height: 800 }, deviceScaleFactor: 1 })
});
const shot = (page: Page, screen: string): Promise<Buffer> =>
page.screenshot({ path: `${OUT}${theme}-${device}-${screen}.png`, animations: 'disabled', caret: 'hide' });
try {
const page = await context.newPage();
await page.clock.install({ time: DAY });
await page.goto(server.url);
await expect(page.getByRole('heading', { level: 2, name: en.gardener.question })).toBeVisible({ timeout: 20_000 });
await shot(page, '1-gardener');
await pastGardener(page);
const search = page.getByRole('searchbox', { name: en.sunset.searchLabel });
await expect(search).toBeVisible();
await shot(page, '2-town-empty');
await search.fill('prague');
await expect(page.getByRole('button', { name: /^Prague/ }).first()).toBeVisible();
await shot(page, '3-town-results');
await page.getByRole('button', { name: /^Prague/ }).first().click();
await expect(page.getByRole('button', { name: en.rose.care })).toBeVisible();
await shot(page, '4-garden');
await openRing(page);
await shot(page, '5-ring');
await page.keyboard.press('Escape');
await page.getByRole('button', { name: en.rose.numbers }).click();
await page.getByRole('button', { name: en.rose.safe.title }).click();
await page.getByRole('button', { name: en.rose.safe.save }).scrollIntoViewIfNeeded();
await shot(page, '6-numbers-safe');
await page.reload();
await page.getByRole('button', { name: en.chair.move }).click();
const scene = page.getByRole('dialog', { name: en.chair.scene });
await expect(scene).toBeVisible();
await page.clock.runFor(30_000);
await shot(page, '7-sunset');
} finally {
await context.close();
}
}
for (const theme of ['light', 'dark'] as const) {
for (const phone of [true, false]) {
test(`${theme}, ${phone ? 'phone' : 'desktop'}`, async ({ browser }) => {
await photograph(browser, theme, phone);
});
}
}
+19
View File
@@ -0,0 +1,19 @@
import { defineConfig, devices } from '@playwright/test';
/**
* The before-and-after pictures of a change of look (`pnpm look:shots`, e2e/look.spec.ts): the BUILT PWA in the
* light and the dark, written to e2e/look/<ROSEA_LOOK>/ (git-ignored). Its own config, so `pnpm test:e2e` stays the
* suite of record and the pictures are taken only when asked for.
*/
export default defineConfig({
testDir: '.',
testMatch: /look\.spec\.ts/,
fullyParallel: false,
workers: 1,
retries: 0,
reporter: [['list']],
use: {
...devices['Desktop Chrome'],
trace: 'retain-on-failure'
}
});
+2 -1
View File
@@ -191,7 +191,8 @@ test.describe('the sunset place, in Prague\'s time zone at noon on 29 March 2026
await page.clock.setFixedTime(NOON);
await open(page);
await page.getByRole('searchbox').fill('pra');
await expect(page.getByRole('status')).not.toHaveText('');
// The question's own status line (every @domi/ui button also carries an empty one, .domi-sr).
await expect(page.getByRole('status').and(page.locator('.found'))).not.toHaveText('');
expect((await new AxeBuilder({ page }).analyze()).violations.map((v) => `${v.id}: ${v.help}`)).toEqual([]);
await page.getByRole('button', { name: /^Prague/ }).first().click();
await expect(page.locator('.sun')).toBeVisible();