[ui] PlanetGarden: Analysis, review, lessons and the tablet smoke that always stops Chrome
This commit is contained in:
@@ -40,6 +40,11 @@ describe('pulling a weed', () => {
|
||||
expect(isPull(line(at(100, 200), at(100, 120), GESTURE.pullMs + 1))).toBe(false);
|
||||
expect(isPull(line(at(100, 200), at(100, 280), 300))).toBe(false);
|
||||
});
|
||||
|
||||
it('far enough up but more sideways than up is not a pull (only the direction decides)', () => {
|
||||
expect(isPull(line(at(100, 200), at(200, 140), 300))).toBe(false);
|
||||
expect(isPull(line(at(100, 200), at(150, 140), 300))).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('sweeping the petals', () => {
|
||||
|
||||
@@ -178,10 +178,27 @@ describe('her planet (planet-garden.md)', () => {
|
||||
expect(screen.queryByRole('group', { name: en.scene.ring })).toBeNull();
|
||||
});
|
||||
|
||||
it('with reduced motion the gardener does not walk', async () => {
|
||||
/** Where the gardener stands now, in degrees round the world. */
|
||||
const gardenerAt = (): number => Number(/rotate\((-?[\d.]+)/.exec(document.querySelector('.walker')?.getAttribute('transform') ?? '')?.[1]);
|
||||
|
||||
/** Asks the gardener to touch her (from the ring), and reads where they are straight after. */
|
||||
async function touchFromRing(): Promise<number> {
|
||||
await fireEvent.keyDown(await screen.findByRole('button', { name: en.rose.care }), { key: 'Enter' });
|
||||
await tick();
|
||||
await fireEvent.click(screen.getByRole('button', { name: en.rose.touch.label }));
|
||||
await tick();
|
||||
return gardenerAt();
|
||||
}
|
||||
|
||||
it('with reduced motion the gardener is at the work at once; otherwise still on the way', async () => {
|
||||
render(Rose, { wiring: wiring(morningWhen(() => true)), timeZone: ZONE });
|
||||
expect(await touchFromRing()).toBeCloseTo(-28, 0);
|
||||
cleanup();
|
||||
|
||||
vi.stubGlobal('matchMedia', (q: string) => ({ matches: q.includes('reduce'), media: q, addEventListener: () => undefined, removeEventListener: () => undefined }));
|
||||
render(Rose, { wiring: wiring(morningWhen(() => true)), timeZone: ZONE });
|
||||
await screen.findByRole('button', { name: en.rose.care });
|
||||
expect(document.querySelector('.planet')?.classList.contains('reduced')).toBe(true);
|
||||
expect(await touchFromRing()).toBe(-10);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user