Built Flash Leaf from scratch as a mobile-friendly PWA: a card-style… #1
Loading…
Reference in a new issue
No description provided.
Delete branch "osf/201-a-web-based-game-that-is-also-a-mobile"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What was done
src/data/species.ts— so the game runs offline with no runtime data dependency.How to review
git checkout osf/201-a-web-based-game-that-is-also-a-mobile.nvm usethennpm install.npm test(45 unit tests) andnpx playwright test(10 browser tests) — both should pass.npm run dev, open http://127.0.0.1:5173, and answer a question — the home screen shows the tree-of-the-day card and a practice button, and tapping Hint reveals the whole-tree photo.npm run buildthennpm run preview(http://127.0.0.1:4173), load it once, switch the browser to offline, and start a practice question — it still loads and shows the leaf photo.src/data/species.ts(the catalog) ande2e/smoke.spec.ts(what the browser checks).Code review
Reviewed the Flash Leaf PWA (Vite + TypeScript, no framework) against its six delta specs, design, and tasks. The code is clean and well-layered (pure, unit-tested core in src/lib; thin DOM render functions in src/ui; hand-rolled service worker with a build-generated precache list), the commit carries no generated/cached files, and every spec requirement is implemented and covered by a test. All 44 Vitest unit tests and 10 Playwright e2e tests pass. I found two minor issues: the species license test's regex was too permissive to reject non-commercial licenses, which I fixed (anchored match that now rejects CC BY-NC/ND while still accepting every bundled license; species.test.ts passes); and the daily selection uses day-of-year modulo catalog length (a deliberate, documented design choice) which is consecutive within a year but jumps one step at the Dec 31 -> Jan 1 boundary, which I left for the team to decide.
Left for you
src/lib/daily.ts:20: dailyIndex is dayOfYearUtc(date) % species.length, so consecutive UTC dates select consecutive catalog entries within a year, but the index jumps at the Dec 31 -> Jan 1 boundary (2026-12-31 -> index 3, 2027-01-01 -> index 0 rather than 4; 2024-12-31 -> index 4, 2025-01-01 -> index 0). This is a minor deviation from the tree-of-the-day spec's 'Consecutive UTC dates SHALL select consecutive entries of the catalog, cycling through the catalog in order'. It is a deliberate design choice (design.md decision 4 names day-of-year explicitly) and the spec's own test only walks within a single year, so I left it for the team to decide rather than override the settled design.Fixed before the commit
src/data/species.test.ts:65: The freely-licensed check used /public domain|cc0|cc[- ]by|gfdl|odbl/i, whose cc[- ]by alternative matches the 'CC BY' prefix of non-commercial licenses, so a 'CC BY-NC' (not freely licensed) value would have passed the test. The bundled catalog contains no NC licenses, so the test passed and the data is correct, but the regex was not strict enough to catch a future NC entry. Fixed by anchoring the match to the start and requiring the license type to end before any '-NC'/'-ND' restriction: /^(public domain|cc0|cc[- ]by(?:-sa)?|gfdl|odbl)(?:\s|$)/i. Verified it still accepts every bundled license and now rejects CC BY-NC / CC BY-ND / All Rights Reserved; species.test.ts passes.Tests
All 32 scenarios of
a-web-based-game-that-is-also-a-mobile-f-pr13wahave a tagged test.Left untested on purpose:
quiz-gameplay/Fresh question hides the tree: Covered by the quiz-screen e2e test written in task 6.2, which asserts that a fresh practice question shows the leaf photograph and the 4 options with the whole-tree photograph not visible.quiz-gameplay/Hint reveals the tree: Covered by the quiz-screen e2e test written in task 6.2, which asserts that using the hint makes the whole-tree photograph visible.species-dataset/Photographs load without a network: Covered by the offline e2e test written in task 7.3, which loads the app with the network disabled and asserts that every file under public/photos/ is present in the service-worker cache, so every bundled photograph renders from bundled assets offline.The test lint found, in the run's tests on the last check:
Recorded, not decided
e2e/smoke.spec.ts:8B6 inthe app loads and shows the Flash Leaf title: test has no// spec: <capability>/<scenario>tag, on itself, its describe or its file's topsrc/lib/session.test.ts:99B6 inadvances to a fresh unanswered question that carries the score over: test has no// spec: <capability>/<scenario>tag, on itself, its describe or its file's topsrc/lib/session.test.ts:121B6 incompletes after the single tree-of-the-day question and cannot advance further: test has no// spec: <capability>/<scenario>tag, on itself, its describe or its file's topsrc/lib/session.test.ts:214B6 inrecords nothing when the session carries no stats store: test has no// spec: <capability>/<scenario>tag, on itself, its describe or its file's topsrc/lib/stats.test.ts:76B6 instores the records under the versioned key: test has no// spec: <capability>/<scenario>tag, on itself, its describe or its file's topsrc/placeholder.test.ts:4B6 inruns the unit test runner: test has no// spec: <capability>/<scenario>tag, on itself, its describe or its file's topBraid run
a-web-based-game-that-is-also-a-mobile-f-pr13wa(36 steps).forgejo/workflows,.gitea/workflowsor.github/workflows); what only CI tests went unverifiedOpened by Braid.