[ui] PlanetGarden: Analysis, review, lessons and the tablet smoke that always stops Chrome
This commit is contained in:
@@ -146,3 +146,31 @@ asserts something the edge makes false.
|
||||
**How to apply it.** Bound every search to the region the test means (here: daytime on the
|
||||
pour's own local day), and when a test built on a search fails, print what the search
|
||||
returned before debugging the code under test.
|
||||
|
||||
## jsdom has no `PointerEvent`, so a test pointer carries no coordinates
|
||||
|
||||
**What happened.** On 2026-11-17 the planet garden's gesture tests fired `pointerDown` and
|
||||
`pointerMove` with `clientX`/`clientY`, and every gesture read as a tap at (0, 0). jsdom has no
|
||||
`PointerEvent`; testing-library falls back to a plain `Event`, which drops the coordinates.
|
||||
|
||||
**Why it bit.** The test looked like a finger and measured nothing. A missing browser API in the
|
||||
test environment does not fail loudly; it quietly hands the code a poorer event.
|
||||
|
||||
**How to apply it.** Before testing pointer gestures in jsdom, polyfill `PointerEvent` on
|
||||
`MouseEvent` (`packages/ui/test/planet.test.ts`) and assert one coordinate-dependent outcome first
|
||||
(a sideways swipe does *not* pull a weed). Check real fingers on the device (`pnpm test:android`).
|
||||
|
||||
## A device test's clean-up must cover its very first step
|
||||
|
||||
**What happened.** On 2026-11-17 `scripts/android-smoke.ts` connected to Chrome on the tablet
|
||||
*before* its `try`. Chrome was still cold-starting, the connect failed with *socket hang up*, and
|
||||
the `finally` that stops Chrome and removes the adb mappings never ran: Chrome stayed open on a
|
||||
device the author asked to leave as it was found. It was stopped by hand.
|
||||
|
||||
**Why it bit.** Clean-up written for the failures you expect (a step fails) misses the one that
|
||||
happens first (the setup fails). On a shared device, a leftover is somebody else's problem.
|
||||
|
||||
**How to apply it.** Open the `try` before the first command that changes the device; make the
|
||||
clean-up tolerate half-done setup (`page?.close()`, `browser?.close()`); retry connections that
|
||||
race a cold start (the script tries for 30 s). After every device run, check: `pidof` the app is
|
||||
empty, `reverse --list` and `forward --list` are empty.
|
||||
|
||||
Reference in New Issue
Block a user