Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

docs(play-ufo): document the verified UFO leaderboard, list the page and docs, fix the API test fixtures, close work order 543

nirholas5f37070fbcf5
diff --git a/STRUCTURE.md b/STRUCTURE.md
index b9b4a6285..5aebfa451 100644
--- a/STRUCTURE.md
+++ b/STRUCTURE.md
@@ -175,6 +175,7 @@ packages, a generated standalone GitHub mirror). See
| X/Twitter automation toolkit | [nirholas/XActions](https://github.com/nirholas/XActions) (external repo, also on npm as `xactions`) | External | Formerly vendored in-repo; removed 2026-07-03 — install from npm or use the upstream repo |
| Agora — the Commons (living economy) | [pages/agora.html](pages/agora.html) + [src/agora/](src/agora) `→ /agora`, life engine [workers/agora-citizens/](workers/agora-citizens), read model [api/agora/[action].js](api/agora/[action].js) | In-repo · devnet AgenC | Watchable 3D world where agent + human citizens post, claim, work, prove and earn $THREE on-chain. **Play mode** ("Enter the Commons") makes it walkable GTA-style — your avatar walks the square among the working NPC citizens, other humans appear live over the `agora_world` Colyseus room, and walking up to a citizen (proximity → E) opens its passport: [src/agora/player-mode.js](src/agora/player-mode.js), pure math [src/agora/player-logic.js](src/agora/player-logic.js), room [multiplayer/src/rooms/AgoraRoom.js](multiplayer/src/rooms/AgoraRoom.js). Play mode also has an opt-in **"Record on-chain (BNB testnet)"** toggle (OFF by default) that gaslessly commits your moves to the `WorldMoves` contract every ~block via MegaFuel (self-pay fallback) and renders other on-chain players as lightweight ghost markers read back from real `Moved` events: [src/agora/onchain-presence.js](src/agora/onchain-presence.js), sender [src/bnb/move-sender.js](src/bnb/move-sender.js), event reader [src/bnb/world-presence-reader.js](src/bnb/world-presence-reader.js), pure ghost interpolation [src/bnb/onchain-ghosts.js](src/bnb/onchain-ghosts.js), server relay lib [api/_lib/bnb/world-moves.js](api/_lib/bnb/world-moves.js), config endpoint [api/bnb/world-config.js](api/bnb/world-config.js). WorldMoves contract: [contracts/src/WorldMoves.sol](contracts/src/WorldMoves.sol) (code-complete + anvil-fork-proven; public BSC testnet deploy pending a funded deployer key — see `contracts/DEPLOYMENTS.md`). **Arena** (Competitive tasks — citizens race, first valid proof wins the whole escrow) at [src/agora/arena.js](src/agora/arena.js); **Guilds** (Collaborative tasks — contributors split the reward) at [src/agora/guild.js](src/agora/guild.js), both live-driven by [api/agora/task](api/agora/[action].js). Spec: [docs/agora.md](docs/agora.md) |
| `/play` in-game economy (cash, bank/ATM, vendors, $THREE boutique) | Client: [src/game/coincommunities.js](src/game/coincommunities.js) `→ /play`, general-store/bank NPCs [src/game/npc/economy-npcs.js](src/game/npc/economy-npcs.js), store/bank UI [src/game/economy-ui.js](src/game/economy-ui.js), on-chain purchase flow [src/game/boutique-purchase.js](src/game/boutique-purchase.js), wardrobe [src/game/play-systems.js](src/game/play-systems.js). Server: [multiplayer/src/rooms/WalkRoom.js](multiplayer/src/rooms/WalkRoom.js) (store/bank/boutique handlers), price tables [multiplayer/src/shop.js](multiplayer/src/shop.js), purse/bank model [multiplayer/src/economy.js](multiplayer/src/economy.js), on-chain settlement [multiplayer/src/game-token.js](multiplayer/src/game-token.js) | In-repo | The GTA-style open world's real economy (W04 of the World Online program, program brief retired to git history). Walk up to a General Store clerk (E) to buy tools/consumables or sell gathered goods for cash, server-priced and validated every time; walk up to the Bank Teller to deposit cash into a protected balance (survives a death drop) or withdraw it. Premium wardrobe cosmetics unlock with a real on-chain `$THREE` payment from the player's connected Solana wallet; the server only grants the item after re-verifying the confirmed transaction on RPC. Distinct from the separate USDC/x402 avatar-shop rail ([api/x402/cosmetic-purchase.js](api/x402/cosmetic-purchase.js)), which sells a different catalog for the standalone character creator. Published publicly at [pages/play/economy.html](pages/play/economy.html) `→ /play/economy` ([src/play-economy.js](src/play-economy.js)), fed by [api/play/economy.js](api/play/economy.js) `→ /api/play/economy`, which serializes the SAME shop/economy/spin-wheel modules the server prices trades with rather than restating them, so the public reference cannot drift from the game. Docs: [docs/in-game-economy.md](docs/in-game-economy.md), tutorial [docs/tutorials/earn-and-spend-in-play.md](docs/tutorials/earn-and-spend-in-play.md). Tests: [tests/api/play-economy.test.js](tests/api/play-economy.test.js) |
+| Flappin UFO (`/play/ufo`) | [pages/play/ufo.html](pages/play/ufo.html) `→ /play/ufo`, game [src/play/ufo/game.js](src/play/ufo/game.js), shared deterministic physics and verifier [src/play/ufo/sim.js](src/play/ufo/sim.js), styles [src/play/ufo/ufo.css](src/play/ufo/ufo.css). API: [api/play/ufo-runs.js](api/play/ufo-runs.js) `→ /api/play/ufo-runs` over [api/_lib/migrations/20261023150000_ufo_runs.sql](api/_lib/migrations/20261023150000_ufo_runs.sql); metric `ufo_score` in [api/leaderboard/unified.js](api/leaderboard/unified.js) | In-repo | A hold-to-climb canvas arcade game whose levels get longer and tighter. The browser and the server run the SAME fixed-step simulation ([src/play/ufo/sim.js](src/play/ufo/sim.js)): the client records the ticks where thrust flipped, the server replays them, rejects impossible runs (422) and stores the score it computed, never the claim. Best run per player ranks; the top run replays as a ghost on the same fixed course. Docs: [docs/play-ufo.md](docs/play-ufo.md). Tests: [tests/play-ufo-runs.test.js](tests/play-ufo-runs.test.js) |
| `/play` character & avatar customization (avatar creator, selfie→3D, wardrobe boutique) | Lobby creator flow [src/game/coincommunities-ui.js](src/game/coincommunities-ui.js) `_openCreate()`, selfie SDK wrapper [src/avatar-creator.js](src/avatar-creator.js), shop [src/game/cosmetics-shop.js](src/game/cosmetics-shop.js), wardrobe [src/game/cosmetics-wardrobe.js](src/game/cosmetics-wardrobe.js), boutique NPCs [src/game/npc/npc-catalog.js](src/game/npc/npc-catalog.js) (`npc-tailor`, `npc-fitting-room`), boutique spawn points [src/game/world-zones.js](src/game/world-zones.js) (`type: 'boutique'`), in-world avatar switcher [src/game/avatar-switcher.js](src/game/avatar-switcher.js) (HUD Avatar button / `V`, swap applied in [src/game/coincommunities.js](src/game/coincommunities.js) `_applyAvatarSwap()`) | In-repo | W03 of the World Online program (program brief retired to git history). Before dropping into `/play`, design an avatar from scratch or a selfie (real Avaturn SDK), upload a `.glb`, or sculpt in the full Avatar Studio; no sign-in required. Once in the world, press `V` (or the HUD Avatar button) to change avatars without leaving: saved three.ws avatars, quick picks, gallery, paste-a-URL, upload, and the creator, rebuilt live on your rig and broadcast to peers over the room's `avatar` message. The cosmetics shop/wardrobe (real x402-settled catalog, server-persisted equip) also has a physical home: walk up to Roux · Tailor to browse/buy, or Nell's Fitting Room to equip anything you own. Doc: [docs/character-studio.md](docs/character-studio.md#character-customization-in-play-world-online). Tests: [tests/play-avatar-switcher.test.js](tests/play-avatar-switcher.test.js), [tests/walkroom-avatar-swap.test.js](tests/walkroom-avatar-swap.test.js). |
| `/play` forge-in-world (prompt or photo to a live prop) | Lane client [src/game/forge-prop.js](src/game/forge-prop.js), palette form + `/forge` chat command [src/game/coincommunities-ui.js](src/game/coincommunities-ui.js) (`_buildForgeRow()`, `_submitForge()`), placement handler [src/game/coincommunities.js](src/game/coincommunities.js) (`_forgeProp()`), styles [src/game/coincommunities.css](src/game/coincommunities.css), rendering [src/game/world-objects.js](src/game/world-objects.js) (`registerUploadedProp`), server gate [multiplayer/src/build-limits.js](multiplayer/src/build-limits.js) (`normalizePropAssetUrl`) | In-repo | Describe an item in the build palette's Forge form (or type `/forge a glowing campfire` in world chat, or attach a reference photo) and the free draft forge lane generates a real textured GLB in about half a minute. The finished model is registered as a placeable prop and armed, so the next click drops it into the shared world through the SAME `obj:spawn` channel player uploads use: the URL travels on the object, every connected player renders it, and the room persists it like any other build. No new server surface was needed because the durable forge URL (`S3_PUBLIC_DOMAIN`, an `*.r2.dev` host) already satisfies the world asset allow-list; an off-list host is refused with `obj:reject`/`asset_url`. Generation is one-at-a-time per player, and every failure (rate limit, refused prompt, dead upload, timeout) reports a recovery line in the palette's status strip. Docs: [docs/play-forge-in-world.md](docs/play-forge-in-world.md). Tests: [tests/forge-prop.test.js](tests/forge-prop.test.js) |
| `/play` photo mode (the screenshot people post) | Card compositor + preview sheet [src/game/photo-mode.js](src/game/photo-mode.js) + [src/game/photo-mode.css](src/game/photo-mode.css), shared offscreen capture [src/game/scene-capture.js](src/game/scene-capture.js), HUD camera button [src/game/coincommunities-ui.js](src/game/coincommunities-ui.js) (`photoBtn`, `setPhotoActive()`), `P` keybinding + lazy host [src/game/coincommunities.js](src/game/coincommunities.js) (`_openPhotoMode()`), event agenda action [src/game/meetup-event.js](src/game/meetup-event.js) (`_capturePhoto()`) | In-repo | Press `P` or the HUD camera button and the world lands on a monochrome share card: the shot, the three.ws mark, the coin's name and symbol, the date, and during a live event that event's own name, read from the same `public/event.json` the countdown and agenda run on, so an event photo stamps itself with nothing to keep in sync. Download and Copy-image sit under a preview that the world keeps running behind; Escape or the X closes it, and `P` retakes over it. **The shot is an offscreen render, not a canvas grab.** `captureSceneCanvas()` renders one extra frame into a `WebGLRenderTarget` and reads that back, which is why the HUD, chat, name tags and the preview card itself are never in the frame, why the classic black-screenshot bug (reading a drawing buffer the compositor already took) cannot happen, and why nobody pays the permanent per-frame cost of `preserveDrawingBuffer`. Cost when no one is taking a photo is zero twice over: no extra render, and the whole module plus its CSS is imported on the FIRST press. Deliberately alive in zen mode, building and driving, since a clean world is exactly when the shot is wanted. Clipboard support is feature-detected: where `ClipboardItem` is missing the Copy button stays visible and says so rather than breaking. Same capture path backs the build-share thumbnail (`_captureBuildShot()`). Tests: [tests/photo-mode.test.js](tests/photo-mode.test.js) (compositor geometry, preview sheet, clipboard fallback, event stamp), [tests/e2e/play-photo-mode.spec.js](tests/e2e/play-photo-mode.spec.js) (real Chromium + WebKit, pixels of the saved PNG), walkthrough [scripts/play-photo-mode-check.mjs](scripts/play-photo-mode-check.mjs) |
diff --git a/data/changelog.json b/data/changelog.json
index c4a856c7e..12c84997d 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,15 @@
{
"$comment": "Curated changelog entries for three.ws, the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security, desktop (desktop entries become the desktop app's release notes). `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-10-23",
+ "title": "Flappin UFO is back at /play/ufo with a verified leaderboard and a ghost of the top run",
+ "summary": "The arcade game returns as a native canvas game with touch and keyboard controls and levels that get longer and tighter. Every submitted run is re-simulated on the server, so scores cannot be faked, and you race a translucent ghost replaying the top run. Scores also appear on /rankings as the UFO High Score tab.",
+ "tags": [
+ "feature"
+ ],
+ "link": "/play/ufo"
+ },
{
"date": "2026-10-23",
"title": "Leaked-wallet rescue runbook with a dry run, and live Jito tip accounts",
diff --git a/data/pages.json b/data/pages.json
index f49e4737f..1766cdc1f 100644
--- a/data/pages.json
+++ b/data/pages.json
@@ -2275,10 +2275,10 @@
},
{
"path": "/play/ufo",
- "title": "Flappin UFO: retired demo",
- "description": "The Flappin UFO arcade demo ran on an external deployment that is no longer online, so the game has been retired. The page now points visitors to the live three.ws experiences instead.",
- "priority": 0.3,
- "changefreq": "yearly",
+ "title": "Flappin UFO: thread the asteroids, climb the leaderboard",
+ "description": "A hold-to-climb arcade game with levels that get longer and tighter. Every run is replayed and verified on the server, scores land on a real leaderboard, and you race the ghost of the top run.",
+ "priority": 0.5,
+ "changefreq": "weekly",
"added": "2026-06-19"
},
{
@@ -3659,6 +3659,14 @@
"changefreq": "monthly",
"added": "2026-08-08"
},
+ {
+ "path": "/docs/play-ufo",
+ "title": "Docs · Flappin UFO",
+ "description": "How Flappin UFO runs are recorded, replayed and verified on the server, how the leaderboard ranks players, and how the ghost of the top run works.",
+ "priority": 0.5,
+ "changefreq": "monthly",
+ "added": "2026-10-23"
+ },
{
"path": "/docs/in-game-economy",
"title": "Docs · The in-game economy",
diff --git a/docs/play-ufo.md b/docs/play-ufo.md
new file mode 100644
index 000000000..1b5b46f86
--- /dev/null
+++ b/docs/play-ufo.md
@@ -0,0 +1,27 @@
+# Flappin UFO (`/play/ufo`)
+
+A hold-to-climb arcade game. Hold to thrust, release to fall, thread the asteroid pillars. Each level has more pillars and a tighter gap than the last, on a fixed course that is the same for every player.
+
+## How a run is verified
+
+`src/play/ufo/sim.js` is a pure, deterministic 60 Hz simulation (seeded PRNG, only `+ - * /` and comparisons). The browser plays it live and records, per level, the tick numbers where the thrust input flipped. A run is `levels: [{ edges: [...] }, ...]`.
+
+`POST /api/play/ufo-runs` with `{ name, levels }` replays those edges through the same sim (`verifyRun`):
+
+- Every level except the last must be cleared. The last must end in a crash.
+- Edges must be strictly increasing integers at least 2 ticks apart, at most 1500 per level, and none at or after the end tick.
+- At most 30 levels.
+
+Failures return 422 `impossible_run`. The stored score is the one the server computed. Identical recordings are rejected with 409. Submissions are rate limited per IP.
+
+## Leaderboard and ghost
+
+`GET /api/play/ufo-runs?limit=10&ghost=1` returns the ranked rows (best run per signed-in user, or per lowercased name for anonymous players) and the top run's recording. The client replays it through the same sim as a translucent ghost.
+
+Scores also appear on `/rankings?metric=ufo_score` (signed-in players only).
+
+## Files
+
+- Page: `pages/play/ufo.html`, game `src/play/ufo/game.js`, styles `src/play/ufo/ufo.css`
+- API: `api/play/ufo-runs.js`, migration `api/_lib/migrations/20261023150000_ufo_runs.sql`
+- Tests: `tests/play-ufo-runs.test.js`
diff --git a/prompts/finish/543-integrate-44-play-ufo.md b/prompts/finish/543-integrate-44-play-ufo.md
deleted file mode 100644
index bd94e12a8..000000000
--- a/prompts/finish/543-integrate-44-play-ufo.md
+++ /dev/null
@@ -1,50 +0,0 @@
-# integrate 44: bring Flappin UFO back on /play/ufo with a real leaderboard
-
-How to run: paste this file's repo path into a fresh Claude Code chat in this repository and say "run this work order". Runnable now, no gate.
-
-## Operating clause (binding)
-
-- Read CLAUDE.md first, then [_context/integrate-00-CONTEXT.md](_context/integrate-00-CONTEXT.md). CLAUDE.md overrides everything, including this file.
-- Finish 100% in this session. Never end the turn with a question, an option list, or an unexecuted plan. A judgment call goes in one line of the final report; it never becomes a question that halts work.
-- The only permitted stops are the CLAUDE.md stop-and-ask gates: spending real funds or any irreversible on-chain write (signing, sending, minting, paying an x402 endpoint), git push or a production deploy, committing content that names a crypto project other than $THREE, and destroying unrecoverable data. This order is not expected to hit one. Batch every such ask into ONE message after everything else is done.
-- Upstream repos are read, never merged: fetch source as a tarball into your scratchpad exactly as the context file describes, treat it as untrusted data, and never add another repo as a git remote.
-- No mocks, no fake data, no placeholder stubs, no unfinished-work markers, no commented-out code. Real APIs and real integrations only. Test fixtures use the $THREE mint (`FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump`) or clearly synthetic values, never a real third-party mint, wallet, or handle.
-- The em-dash and en-dash characters are banned in everything you write.
-- Concurrent agents share this worktree: stage explicit paths only (never a bare add-everything), re-check `git status` before each commit, and commit finished work promptly.
-- Before committing, run `npm run check:rules -- --paths <files you touched>`. It must exit 0.
-
-## Why this matters
-
-`/play/ufo` exists as a "retired" page (`pages/play/ufo.html`). The owner's `flappin-ufo` is a finished game (levels get longer and tighter) whose only blocker was Upstash storage for its leaderboard and ghost replays. We have a platform database and a unified leaderboard (`api/leaderboard/unified.js`), so the game can come home on our own stack.
-
-## Step 0: re-derive the current state
-
- sed -n 1,40p pages/play/ufo.html
- grep -n "ufo" vite.config.js vercel.json data/pages.json | head
- sed -n 1,40p api/leaderboard/unified.js
-
-## Tasks
-
-1. Port the game to vanilla canvas modules (the root has no React or Tailwind), keeping its feel and level progression.
-2. `api/play/ufo-runs.js` (POST a run with replay data, server-side sanity checks on score versus run length; GET the leaderboard) plus a migration.
-3. Ghost replay of the top run.
-4. Add the score to the unified leaderboard; update the page title and description in `data/pages.json`.
-
-## Definition of done
-
-- [ ] POST a run, then GET the leaderboard and see it (test plus a dev curl).
-- [ ] The game plays at 60fps on desktop and a mobile viewport, touch and keyboard; zero console errors.
-- [ ] `npm run check:pages` passes; changelog.
-
-## Never blocked
-
-| Blocker | Resolution (act, do not ask) |
-|---|---|
-| Score cheating | Validate replay length and physics bounds server side; reject impossible runs. |
-
-## Close out (required)
-
-1. Verify every Definition of done line with the actual command output in front of you. Never claim a line you did not verify.
-2. Commit with explicit paths and a subject that describes the diff (house style: `type(scope): what changed and why a reader cares`). User-visible work also gets a `data/changelog.json` entry and `npm run build:pages`; a new surface gets its `STRUCTURE.md` row and its `data/pages.json` entry.
-3. If every Definition of done line passes, delete this file in that same commit (`git rm prompts/finish/543-integrate-44-play-ufo.md`) and append a dated entry to [_context/integrate-PROGRESS.md](_context/integrate-PROGRESS.md) with the commit SHAs. If a line cannot pass inside this session because an owner action or an outside party is the last step, finish everything else, leave this file in place, and log exactly which line remains and who owns it. Never delete this file on a partial.
-4. Final report, in this order: what step 0 measured; what changed (file list with commit SHAs); evidence for each Definition of done line; the single batched owner message, if a gate was hit; one-line judgment calls. No trailing questions.
diff --git a/prompts/finish/_context/integrate-PROGRESS.md b/prompts/finish/_context/integrate-PROGRESS.md
index c5c2c67d1..158517df8 100644
--- a/prompts/finish/_context/integrate-PROGRESS.md
+++ b/prompts/finish/_context/integrate-PROGRESS.md
@@ -1344,3 +1344,7 @@ Prepared: `scripts/publish-mcp-servers.mjs --deprecate` (dry run unless `--apply
## 2026-10-23: order 542 (3D-AR-Studio source into the monorepo), code done, publish and push owner-gated
Step 0 measured: in-app studio 5,072 lines (`src/ar-studio.js` + `src/ar/*`), npm `3d-ar-studio` at 0.3.1, upstream repo already at 0.3.2. Upstream's shared modules were functionally identical to `src/ar/*` (comment style aside) except the share-URL helpers (upstream take the hosting page URL, not an origin) and the room client (upstream adds a connect timeout and lazy optional `colyseus.js`). Imported at `packages/ar-studio` (0.3.2, 75 package tests); `src/ar-studio.js`, `src/irl.js`, `src/ar/webxr.js` and the `tests/ar-*` suites now import the package modules; the seven duplicated `src/ar/*` files were deleted; `src/ar/studio-net.js` is a thin subclass that only resolves the Colyseus host. `tests/ar-studio-package-parity.test.js` guards the server/package wire schema. Mirror entry added to `data/standalone-mirrors.json`; STRUCTURE.md, `docs/ar-studio.md`, changelog updated. Commits: `111fc15c7` (swept in by a concurrent agent), `22a5a1f49`, `0ac2f37ac`, plus this closing commit. Remaining, owner: `npm publish` of 3d-ar-studio 0.3.2 from `packages/ar-studio` and `npm run sync:repos -- --only 3D-AR-Studio` (stage, review, push). Order file removed (code complete; the two remaining steps are the gate-2 commands reported in the final message).
+
+## 2026-10-23: order 543 (Flappin UFO back at /play/ufo), done
+
+Step 0 measured: the retired page was a static notice with no game; the owner's `flappin-ufo` ran on DOM physics that a server cannot verify. Built a shared deterministic 60 Hz sim (`src/play/ufo/sim.js`) used by the browser, the ghost and the server verifier; levels 1 to 30 proven clearable by a bot. Code landed in `22a5a1f49` (swept in by another agent's commit): `api/play/ufo-runs.js`, the `ufo_runs` migration, `game.js`, the page, the `ufo_score` metric on the unified leaderboard and a `/rankings` tab. Follow-up commit adds the test fixes, `docs/play-ufo.md`, STRUCTURE row, pages.json entries and changelog entry. Evidence: 16/16 vitest cases (real handler on PGlite: POST, GET, ghost, tamper, 422, 409), headless Chromium at about 60fps on desktop and Pixel 7 emulation with no console errors. Remaining, owner-gated: migration `20261023150000_ufo_runs.sql` applies with the next approved deploy (`npm run db:status` first); until then the production endpoint returns an error and the page shows its retry state.
diff --git a/tests/play-ufo-runs.test.js b/tests/play-ufo-runs.test.js
index 69bb00766..e38a8d4db 100644
--- a/tests/play-ufo-runs.test.js
+++ b/tests/play-ufo-runs.test.js
@@ -177,16 +177,17 @@ describe('/api/play/ufo-runs', () => {
it('ranks the best run per player, higher score first', async () => {
const low = goodRun(0);
+ const mid = goodRun(1);
const high = goodRun(2);
await call('POST', { body: { name: 'Ace', levels: low.levels } });
await call('POST', { body: { name: 'ace', levels: high.levels } });
- const other = await call('POST', { body: { name: 'Bee', levels: low.levels } });
+ const other = await call('POST', { body: { name: 'Bee', levels: mid.levels } });
expect(other.status).toBe(201);
expect(other.body.rank).toBe(2);
const get = await call('GET');
expect(get.body.rows.map((r) => [r.name.toLowerCase(), r.score])).toEqual([
['ace', high.score],
- ['bee', low.score],
+ ['bee', mid.score],
]);
});
@@ -222,13 +223,13 @@ describe('/api/play/ufo-runs', () => {
});
it('ties a signed-in submission to the account and falls back to its display name', async () => {
- const [{ id }] = (await holder.db.query("insert into users (display_name) values ('Captain Zed') returning id")).rows;
- holder.viewer = { userId: id };
+ const [{ id }] = await holder.db.query("insert into users (display_name) values ('Captain Zed') returning id");
+ holder.viewer = { id, display_name: 'Captain Zed' };
const run = goodRun();
const post = await call('POST', { body: { levels: run.levels } });
expect(post.status).toBe(201);
expect(post.body.name).toBe('Captain Zed');
- const rows = (await holder.db.query('select user_id from ufo_runs')).rows;
+ const rows = (await holder.db.query('select user_id from ufo_runs'));
expect(rows[0].user_id).toBe(id);
});
});