[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
+21 -1
View File
@@ -3,6 +3,7 @@ import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/sv
import { afterEach, describe, expect, it } from 'vitest';
import Shell from '../src/Shell.svelte';
import { en } from '../src/copy/en.js';
import { said } from './said.js';
afterEach(() => {
cleanup();
@@ -19,6 +20,25 @@ const LETTER = [
const h1 = (): HTMLElement => screen.getByRole('heading', { level: 1 });
describe('the licence credit (CPAL-1.0 Exhibit B; domi-ui.md D9)', () => {
const credit = 'Built on Domi · https://aula.marek-novak.cz · Copyright (c) 2026 Marek Novák';
it('stands at the foot of the first screen in its exact words, as plain text that leads nowhere', () => {
render(Shell);
const line = screen.getByText(credit);
expect(line.textContent).toBe(credit);
expect(line.closest('a')).toBeNull();
expect(document.querySelectorAll('a[href^="https://aula"]')).toHaveLength(0);
});
it('stands at the foot of the Letter too', async () => {
window.location.hash = '#letter';
render(Shell, { letter: LETTER });
await waitFor(() => expect(h1().textContent).toBe(en.letter.title));
expect(screen.getByText(credit)).toBeTruthy();
});
});
describe('Shell', () => {
it('names the product in the page heading, from the schema constant', () => {
render(Shell);
@@ -94,7 +114,7 @@ describe('Shell and a new version waiting (calm-refresh.md)', () => {
it('when one waits: one quiet line and Refresh, which only the player\'s tap sends', async () => {
let refreshed = 0;
render(Shell, { updateReady: true, onrefresh: () => (refreshed += 1) });
expect(screen.getByRole('status').textContent).toBe(en.update.ready);
expect(said().textContent).toBe(en.update.ready);
expect(refreshed).toBe(0);
await fireEvent.click(screen.getByRole('button', { name: en.update.refresh }));
expect(refreshed).toBe(1);
+3 -2
View File
@@ -4,6 +4,7 @@ import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/sv
import { tick } from 'svelte';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { en } from '../src/copy/en.js';
import { said } from './said.js';
import Rose from '../src/rose/Rose.svelte';
import type { RoseWiring } from '../src/rose/types.js';
@@ -89,7 +90,7 @@ describe('the rose', () => {
render(Rose, { wiring: w, timeZone: ZONE });
await screen.findByRole('img', { name: /^The rose/ });
await hold(1500); // half a can
expect(screen.getByRole('status').textContent).toBe(en.rose.leavesLift);
expect(said().textContent).toBe(en.rose.leavesLift);
await release();
expect(w.appended).toHaveLength(1);
expect(w.appended[0]).toMatchObject({ act: 'water', amount: 0.5, localDay: '2026-03-01', from: ME, to: ME });
@@ -105,7 +106,7 @@ describe('the rose', () => {
render(Rose, { wiring: wiring({ log: [water(MORNING - 60_000, 0.5)] }), timeZone: ZONE });
await screen.findByRole('img', { name: /^The rose/ });
await hold(3000);
expect(screen.getByRole('status').textContent).toBe(en.rose.plenty);
expect(said().textContent).toBe(en.rose.plenty);
});
it('pours with the keyboard too: hold Space, let go', async () => {
+12
View File
@@ -0,0 +1,12 @@
import { screen } from '@testing-library/svelte';
/**
* The one status line Rosea herself speaks through. Every @domi/ui button also carries a hidden status of its own
* (`.domi-sr`, empty until the button works on a Promise, which Rosea's never do: domi-ui.md D2), so "the" status
* is the one that is not a button's.
*/
export function said(): HTMLElement {
const own = screen.getAllByRole('status').filter((el) => !el.classList.contains('domi-sr'));
if (own.length !== 1) throw new Error(`expected one status line of Rosea's own, found ${own.length}`);
return own[0]!;
}
+3 -2
View File
@@ -3,6 +3,7 @@ import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/sv
import { afterEach, describe, expect, it, vi } from 'vitest';
import Shell from '../src/Shell.svelte';
import { en } from '../src/copy/en.js';
import { said } from './said.js';
import type { SunsetChoice, SunsetWiring } from '../src/sunset/types.js';
const brno: NamedPlace = { name: 'Brno', region: '', country: 'Czechia', lat: 49.2, lon: 16.61, timeZone: 'Europe/Prague' };
@@ -48,7 +49,7 @@ describe('the garden asks where the sunset is', () => {
const w = wiring();
render(Shell, { sunset: w });
await fireEvent.input(await screen.findByRole('searchbox'), { target: { value: 'br' } });
expect(await screen.findByRole('status')).toHaveProperty('textContent', en.sunset.found(1));
await waitFor(() => expect(said().textContent).toBe(en.sunset.found(1)));
await fireEvent.click(screen.getByRole('button', { name: /Brno/ }));
const at = invitation(sunDay('2026-03-29', brno));
@@ -61,7 +62,7 @@ describe('the garden asks where the sunset is', () => {
it('nothing found says a larger town nearby will do, never an error', async () => {
render(Shell, { sunset: wiring() });
await fireEvent.input(await screen.findByRole('searchbox'), { target: { value: 'zz' } });
await waitFor(() => expect(screen.getByRole('status').textContent).toBe(en.sunset.found(0)));
await waitFor(() => expect(said().textContent).toBe(en.sunset.found(0)));
});
it('"not now" uses the guess, saves the device zone, and says it is a guess', async () => {