[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
+8
View File
@@ -91,6 +91,14 @@ describe('the in-game sunset (chair-sunset.md)', () => {
expect(screen.queryByRole('dialog')).toBeNull();
});
it('late in the evening its words still name the real sunset, never the sunrise (sunrise.md R4)', async () => {
const late = Date.parse('2026-03-29T22:00:00+02:00');
const scene = await openScene({ now: () => late });
vi.advanceTimersByTime(SUNSET_MS);
await tick();
expect(within(scene).getByText(/^Tomorrow the sun sets at .* in Brno\.$/)).toBeTruthy();
});
it('with no town and no guess, the words after it ask for a town', async () => {
const scene = await openScene({ guess: null, load: async () => ({ kind: 'device-zone' }) });
vi.advanceTimersByTime(SUNSET_MS);
+15 -3
View File
@@ -89,11 +89,23 @@ describe('the garden remembers', () => {
expect(screen.queryByRole('searchbox')).toBeNull();
});
it('after the sunset, it speaks of tomorrow\'s', async () => {
it("after the sunset, it names tomorrow's sunrise (sunrise.md)", async () => {
const after = invitation(sunDay('2026-03-29', brno)) + 60_000;
render(Shell, { sunset: wiring({ saved: { kind: 'town', town: brno }, now: () => after }) });
const tomorrow = invitation(sunDay('2026-03-30', brno));
expect(await screen.findByText(en.sunset.tomorrow(timeOf(brno, tomorrow), 'Brno'))).toBeTruthy();
const tomorrow = sunDay('2026-03-30', brno);
if (tomorrow.kind !== 'sun-sets') throw new Error('Brno has a sunrise in March');
expect(await screen.findByText(en.sunset.risesTomorrow(timeOf(brno, tomorrow.sunrise), 'Brno'))).toBeTruthy();
});
it('before sunrise, it names this morning\'s sunrise; after it, tonight\'s sunset', async () => {
const early = Date.parse('2026-03-29T04:00:00+02:00');
const today = sunDay('2026-03-29', brno);
if (today.kind !== 'sun-sets') throw new Error('Brno has a sunrise in March');
render(Shell, { sunset: wiring({ saved: { kind: 'town', town: brno }, now: () => early }) });
expect(await screen.findByText(en.sunset.rises(timeOf(brno, today.sunrise), 'Brno'))).toBeTruthy();
cleanup();
render(Shell, { sunset: wiring({ saved: { kind: 'town', town: brno }, now: () => today.sunrise + 60_000 }) });
expect(await screen.findByText(en.sunset.tonight(timeOf(brno, today.sunset), 'Brno'))).toBeTruthy();
});
it('in polar night it speaks of the noon twilight; in polar day, of the lowest light', async () => {