[ui] PlanetGarden: Her round planet, the player's gardener, the ring of care, and care by gesture
This commit is contained in:
@@ -39,9 +39,18 @@ function wiring(log: CareEvent[] = []): RoseWiring & { clock: { now: number }; w
|
||||
|
||||
const bubble = (): string => document.querySelector('.bubble')?.textContent ?? '';
|
||||
|
||||
/** Opens the ring of care, where Touch her lives (planet-garden.md G7). */
|
||||
async function openRing(): Promise<HTMLElement> {
|
||||
if (!screen.queryByRole('group', { name: en.scene.ring })) {
|
||||
await fireEvent.keyDown(await screen.findByRole('button', { name: en.rose.care }), { key: 'Enter' });
|
||||
await tick();
|
||||
}
|
||||
return screen.getByRole('button', { name: en.rose.touch.label });
|
||||
}
|
||||
|
||||
async function touchAt(w: ReturnType<typeof wiring>, at: number): Promise<void> {
|
||||
w.clock.now = at;
|
||||
await fireEvent.click(screen.getByRole('button', { name: en.rose.touch.label }));
|
||||
await fireEvent.click(await openRing());
|
||||
await tick();
|
||||
}
|
||||
|
||||
@@ -54,7 +63,7 @@ describe('touching her (thorns.md)', () => {
|
||||
it('a touch is answered fondly, then her usual line returns; nothing is written', async () => {
|
||||
const w = wiring();
|
||||
render(Rose, { wiring: w, timeZone: ZONE });
|
||||
await screen.findByRole('button', { name: en.rose.touch.label });
|
||||
await openRing();
|
||||
const usual = bubble();
|
||||
vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });
|
||||
await touchAt(w, MORNING);
|
||||
@@ -70,7 +79,7 @@ describe('touching her (thorns.md)', () => {
|
||||
it('three quick taps: Gently. I have thorns. Taps while she rests change nothing', async () => {
|
||||
const w = wiring();
|
||||
render(Rose, { wiring: w, timeZone: ZONE });
|
||||
await screen.findByRole('button', { name: en.rose.touch.label });
|
||||
await openRing();
|
||||
vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });
|
||||
await touchAt(w, MORNING);
|
||||
await touchAt(w, MORNING + 500);
|
||||
@@ -84,7 +93,7 @@ describe('touching her (thorns.md)', () => {
|
||||
it('a held key is one touch, not a rush', async () => {
|
||||
const w = wiring();
|
||||
render(Rose, { wiring: w, timeZone: ZONE });
|
||||
const button = await screen.findByRole('button', { name: en.rose.touch.label });
|
||||
const button = await openRing();
|
||||
const repeat = new KeyboardEvent('keydown', { key: 'Enter', repeat: true, cancelable: true, bubbles: true });
|
||||
button.dispatchEvent(repeat);
|
||||
expect(repeat.defaultPrevented).toBe(true);
|
||||
@@ -102,7 +111,7 @@ describe('touching her (thorns.md)', () => {
|
||||
w.clock.now = MORNING + 25 * DAY + 3 * 3_600_000;
|
||||
render(Rose, { wiring: w, timeZone: ZONE });
|
||||
const img = await screen.findByRole('img', { name: /full bloom/ });
|
||||
expect(img.getAttribute('alt')).not.toMatch(/blushing/);
|
||||
expect(img.getAttribute('aria-label')).not.toMatch(/blushing/);
|
||||
await touchAt(w, w.clock.now);
|
||||
expect(screen.getByRole('img', { name: /full bloom, blushing/ })).toBeTruthy();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user