[ui] Sunrise: The garden names the real sunrise from sunset until it comes

This commit is contained in:
2026-11-17 18:52:56 +01:00
parent e0a3b66dc8
commit 0c4f5bb556
9 changed files with 137 additions and 16 deletions
+15 -1
View File
@@ -3,7 +3,7 @@ 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 { nextInvitation } from '@rosea/engine';
import { nextInvitation, nextSunEvent } from '@rosea/engine';
import { searchTowns } from '@rosea/content/places';
import { readFileSync } from 'node:fs';
import { BASE, startStaticServer, type StaticServer } from './static-server.js';
@@ -163,6 +163,20 @@ test.describe('the sunset place, in Prague\'s time zone at noon on 29 March 2026
expect(requests.some((url) => /\/assets\/places-.*\.js$/.test(url))).toBe(true);
});
test('at five in the morning the garden names the sunrise, not the sunset (sunrise.md)', async ({ page }) => {
const early = Date.parse('2026-03-29T05:00:00+02:00');
await page.clock.setFixedTime(early);
await open(page);
await page.getByRole('searchbox', { name: en.sunset.searchLabel }).fill('brno');
await page.getByRole('button', { name: /^Brno/ }).first().click();
const brno = searchTowns('brno')[0]!;
const { at } = nextSunEvent(early, brno);
const time = new Intl.DateTimeFormat('en-US', { hour: 'numeric', minute: '2-digit', timeZone: brno.timeZone }).format(at);
const line = page.locator('.sun p').first();
await expect(line).toHaveText(/^The sun rises at .* in Brno\.$/);
expect(spaced((await line.textContent()) ?? '')).toBe(spaced(en.sunset.rises(time, 'Brno')));
});
test('"not now" guesses Prague from the device\'s zone and says it is a guess', async ({ page }) => {
await page.clock.setFixedTime(NOON);
await open(page);