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.

test(irl): give the pin PATCH suites real UUIDs and record the IRL endpoint audit

nirholasda759181120d
diff --git a/api/irl/README.md b/api/irl/README.md
index c101a619d..e213fe983 100644
--- a/api/irl/README.md
+++ b/api/irl/README.md
@@ -29,7 +29,7 @@ Why this layer is shaped the way it is:
| `GET /api/irl/agent-summary?mine=1` | One row per owned pin (identity + derived activity + `status`) so the owner dashboard paints without N calls. Auth required. [`agent-summary.js`](./agent-summary.js) |
| `GET /api/irl/analytics` | Site-wide usage rollup (pins placed, nearby reads, shares, drop claims). Ops-gated (admin session or `OPS_SECRET`). [`analytics.js`](./analytics.js) |
| `GET/PATCH/DELETE /api/irl/privacy` | The privacy center: plain-language data summary, `?export=1` full JSON export, unpublish/republish a pin, delete one pin / everything / forget-this-device (purges interactions the device authored elsewhere too). [`privacy.js`](./privacy.js) |
-| `POST /api/irl/report` `{ pinId, reason, deviceToken? }` | Community moderation: distinct-reporter dedup, per-pin 24 h ceiling, threshold hide (never delete, owner can appeal). [`report.js`](./report.js) |
+| `POST /api/irl/report` `{ pinId, reason, detail? }` + `x-irl-device` | Community moderation: distinct-reporter dedup (keyed on the session user, else the device token from the `x-irl-device` header or the body, else the caller IP), per-pin 24 h ceiling, threshold hide (never delete, owner can appeal). [`report.js`](./report.js) |
| `POST /api/irl/share?pinId=&deviceToken=` | Owner uploads their composite AR photo (raw PNG body) and mints a permanent share token: `{ token, url, imageUrl }`. [`share.js`](./share.js) |
| `GET /irl/s/:token` | The unfurlable share page (real `og:image` of the capture, caption and agent name only, never coordinates). [`share/[token].js`](./share/%5Btoken%5D.js) |
diff --git a/data/changelog.json b/data/changelog.json
index 2d135a8cb..8af05af8b 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -20740,6 +20740,15 @@
"docs",
"fix"
]
+ },
+ {
+ "date": "2026-08-13",
+ "title": "IRL endpoints answer bad input honestly, and the usage rollup works again",
+ "summary": "Audited the ten /api/irl endpoints against a real database. A pin, drop or interaction id that was not a UUID used to reach Postgres and come back as a server error; those requests are now a plain 400 that never touches the database. The site-wide /irl usage rollup had a broken daily-series query, and because the endpoint quietly served an empty summary when a query failed, it had been reporting zeros instead of real numbers; the query is fixed and a failure is now logged. A report filed from a device that sends its id in the header is once again recognised, so an owner cannot accidentally count as an independent reporter of their own pin, and repeat reports from one device still collapse into one. Captions shilling a coin whose ticker runs past ten characters are rejected like every other off-brand ticker.",
+ "tags": [
+ "fix",
+ "security"
+ ]
}
]
}
diff --git a/prompts/swarm-100/api-irl-01.md b/prompts/swarm-100/api-irl-01.md
deleted file mode 100644
index 8b29cd315..000000000
--- a/prompts/swarm-100/api-irl-01.md
+++ /dev/null
@@ -1,110 +0,0 @@
-# API audit: api/irl batch 01 (10 files)
-
-How to run: paste this file's repo path into a fresh Claude Code chat in this
-repository and say "run this work order". This file is fully self-contained:
-it depends on no other prompt file anywhere. If neighboring files in
-prompts/swarm-100/ are gone, that work is done; if present, ignore them.
-Every claim below rots; step 0 re-measures, and what you measure wins.
-
-## Operating clause (binding)
-
-- Read CLAUDE.md first. Its rules override 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, git push or a production deploy,
- committing content that references a crypto project other than $THREE, and
- destroying unrecoverable data.
-- No mocks, no fake data, no placeholder stubs, no unfinished-work markers, no
- commented-out code. Real APIs and real integrations only.
-- 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), and commit finished work promptly.
-- Before committing, run: npm run check:rules -- --paths <files you touched>.
- It must exit 0.
-
-## Step 0: re-derive the current state
-
-1. Confirm each file below still exists; deleted ones are done, skip them.
-2. For each, decide routability: grep its path in vercel.json and read how
- server/index.mjs maps filesystem handlers. Routed files get an endpoint
- audit; internal modules get a code and test audit.
-3. Start a local server for endpoint checks: node server/index.mjs with .env
- loaded, on a free PORT if 3000 is busy.
-
-## Task: audit these api files, then fix everything found
-
-Files in this batch:
-
-- api/irl/agent-card.js
-- api/irl/agent-summary.js
-- api/irl/analytics.js
-- api/irl/drops.js
-- api/irl/fix-token.js
-- api/irl/interactions-stream.js
-- api/irl/interactions.js
-- api/irl/pins.js
-- api/irl/privacy.js
-- api/irl/report.js
-
-For every routed handler:
-
-1. Exercise it with curl against the local server: the success path returns
- real data with the correct status; malformed input returns a 4xx JSON
- error, never a stack trace or an HTML error page; auth is enforced where
- the code intends it; CORS matches neighboring handlers.
-2. Hard-rule scan: no mock fallbacks, no fake-data arrays, no stubbed
- responses, no unfinished markers. Errors are handled at the boundary and
- internal code trusts itself.
-3. Do not spend funds or sign anything on-chain while probing. Payment and
- trading handlers get their validation and error paths exercised, never a
- live settlement.
-
-For every internal (non-routed) module:
-
-4. Something must import it; if nothing does, delete it as dead code (verify
- with a repo-wide grep first).
-5. Its main path and one failure path must be covered in tests/; add the
- missing test if not.
-
-## Definition of done
-
-- [ ] Every listed file has recorded evidence: a curl transcript for routed
- handlers, a passing test or a deletion for internal modules.
-- [ ] Zero hard-rule violations remain in these files.
-- [ ] vitest run passes; npm run check:rules -- --paths <touched files>
- exits 0.
-
-## Never blocked
-
-| Blocker | Resolution (act, do not ask) |
-|---|---|
-| Missing env var or credential | Check .env and .env.local, then the Cloud Run service env, then Secret Manager (the CLAUDE.md self-unblock playbook has the exact commands). If it truly exists nowhere, wire the code fully behind the env var, prove the wiring with a dry run, and name the single missing var in the report. |
-| gcloud not on PATH | Run: export PATH="$HOME/google-cloud-sdk/bin:$PATH" |
-| Dev server port 3000 busy | Another agent may be serving this repo; probe it and reuse if so. Otherwise start your own on a free port: npx vite --port 3101 |
-| Playwright browser missing | npx playwright install chromium |
-| A surface needs a signed-in user | Register a fresh account through the real /register flow against the real API and use it. Never mock the session. |
-| A defect sits in code you did not touch | Fix it if it blocks a Definition of done line (root cause it, never mask it). Otherwise note it in the report and continue. |
-| An unrelated test is red | Same rule. Never pipe npm test through tail; it masks exit codes. |
-
-## 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).
-3. Delete this prompt file in that same commit:
-
- git rm prompts/swarm-100/api-irl-01.md
-
- The shrinking directory is this campaign's only progress ledger; there is
- no progress log to update.
-4. Final report: what step 0 measured, what changed (file list), evidence per
- Definition of done line, and any one-line judgment calls. No trailing
- questions, no unexecuted plans.
-
-If a line genuinely cannot pass inside this session (an external party must
-respond, or an owner-gated action is the final step), finish everything else,
-leave this file in place, and state exactly which line remains and who owns
-it. Never delete this file on a partial.
diff --git a/tests/api/irl-pins-calibrate.test.js b/tests/api/irl-pins-calibrate.test.js
index 708fca2e2..b5a08cbaf 100644
--- a/tests/api/irl-pins-calibrate.test.js
+++ b/tests/api/irl-pins-calibrate.test.js
@@ -87,7 +87,7 @@ async function patch(body) {
beforeEach(() => {
sqlMock.mockClear();
pinRow = {
- id: 'pin-1',
+ id: PIN_ID,
user_id: null,
device_token: 'device-A',
lat: ORIGIN.lat,
@@ -102,11 +102,16 @@ beforeEach(() => {
sessionUser = null;
});
+// `irl_pins.id` is a UUID column and the handler rejects any non-UUID id at the
+// boundary, so the fixtures below are real UUIDs rather than readable slugs.
+const PIN_ID = '11111111-1111-4111-8111-111111111111';
+const MISSING_PIN_ID = '22222222-2222-4222-8222-222222222222';
+
describe('PATCH /api/irl/pins calibrate — ownership gate', () => {
it('404s when the pin no longer exists', async () => {
pinRow = null;
const { res, body } = await patch({
- id: 'gone', deviceToken: 'device-A',
+ id: MISSING_PIN_ID, deviceToken: 'device-A',
calibrate: { lat: ORIGIN.lat, lng: ORIGIN.lng },
});
expect(res.statusCode).toBe(404);
@@ -115,7 +120,7 @@ describe('PATCH /api/irl/pins calibrate — ownership gate', () => {
it('403s a non-owner (device token mismatch, no session)', async () => {
const { res, body } = await patch({
- id: 'pin-1', deviceToken: 'device-B',
+ id: PIN_ID, deviceToken: 'device-B',
calibrate: { lat: ORIGIN.lat, lng: ORIGIN.lng },
});
expect(res.statusCode).toBe(403);
@@ -124,14 +129,14 @@ describe('PATCH /api/irl/pins calibrate — ownership gate', () => {
it('403s a caller with neither matching session nor device token', async () => {
const { res } = await patch({
- id: 'pin-1',
+ id: PIN_ID,
calibrate: { lat: ORIGIN.lat, lng: ORIGIN.lng },
});
expect(res.statusCode).toBe(403);
});
it('never reaches the UPDATE for a denied caller', async () => {
- await patch({ id: 'pin-1', deviceToken: 'device-B', calibrate: { lat: ORIGIN.lat, lng: ORIGIN.lng } });
+ await patch({ id: PIN_ID, deviceToken: 'device-B', calibrate: { lat: ORIGIN.lat, lng: ORIGIN.lng } });
const ranUpdate = sqlMock.mock.calls.some(([s]) =>
/UPDATE irl_pins SET/i.test(Array.isArray(s) ? s.join(' ') : String(s)));
expect(ranUpdate).toBe(false);
@@ -141,7 +146,7 @@ describe('PATCH /api/irl/pins calibrate — ownership gate', () => {
describe('PATCH /api/irl/pins calibrate — bounds enforcement', () => {
it('400s on out-of-range coordinates', async () => {
const { res, body } = await patch({
- id: 'pin-1', deviceToken: 'device-A',
+ id: PIN_ID, deviceToken: 'device-A',
calibrate: { lat: 999, lng: ORIGIN.lng },
});
expect(res.statusCode).toBe(400);
@@ -152,7 +157,7 @@ describe('PATCH /api/irl/pins calibrate — bounds enforcement', () => {
// ~22 m north — well beyond the ±3 m client clamp and the 5 m server ceiling.
const farLat = ORIGIN.lat + 0.0002;
const { res, body } = await patch({
- id: 'pin-1', deviceToken: 'device-A',
+ id: PIN_ID, deviceToken: 'device-A',
calibrate: { lat: farLat, lng: ORIGIN.lng },
});
expect(res.statusCode).toBe(422);
@@ -163,7 +168,7 @@ describe('PATCH /api/irl/pins calibrate — bounds enforcement', () => {
it('422s a yaw nudge beyond the rotation ceiling', async () => {
// Same spot (move passes), but 90° off the stored 90° bearing → > 46° cap.
const { res, body } = await patch({
- id: 'pin-1', deviceToken: 'device-A',
+ id: PIN_ID, deviceToken: 'device-A',
calibrate: { lat: ORIGIN.lat, lng: ORIGIN.lng, anchorYawDeg: 180 },
});
expect(res.statusCode).toBe(422);
@@ -173,7 +178,7 @@ describe('PATCH /api/irl/pins calibrate — bounds enforcement', () => {
it('422s a floor-height nudge beyond the rise ceiling', async () => {
const { res, body } = await patch({
- id: 'pin-1', deviceToken: 'device-A',
+ id: PIN_ID, deviceToken: 'device-A',
calibrate: { lat: ORIGIN.lat, lng: ORIGIN.lng, anchorHeightM: 5 },
});
expect(res.statusCode).toBe(422);
@@ -186,7 +191,7 @@ describe('PATCH /api/irl/pins calibrate — accepted nudges persist for everyone
// ~1.1 m north, 10° yaw correction, +30 cm — all within the calibrate envelope.
const newLat = ORIGIN.lat + 1.1 / M_PER_DEG_LAT;
const { res, body } = await patch({
- id: 'pin-1', deviceToken: 'device-A',
+ id: PIN_ID, deviceToken: 'device-A',
calibrate: { lat: newLat, lng: ORIGIN.lng, anchorYawDeg: 100, anchorHeightM: 0.3 },
});
expect(res.statusCode).toBe(200);
@@ -203,7 +208,7 @@ describe('PATCH /api/irl/pins calibrate — accepted nudges persist for everyone
pinRow.device_token = null;
sessionUser = { id: 'owner-uuid' };
const { res, body } = await patch({
- id: 'pin-1',
+ id: PIN_ID,
calibrate: { lat: ORIGIN.lat, lng: ORIGIN.lng, anchorYawDeg: 90 },
});
expect(res.statusCode).toBe(200);
@@ -212,7 +217,7 @@ describe('PATCH /api/irl/pins calibrate — accepted nudges persist for everyone
it('treats yaw as wrap-around (340° vs stored 90° is 110° apart → rejected)', async () => {
const { res } = await patch({
- id: 'pin-1', deviceToken: 'device-A',
+ id: PIN_ID, deviceToken: 'device-A',
calibrate: { lat: ORIGIN.lat, lng: ORIGIN.lng, anchorYawDeg: 340 },
});
expect(res.statusCode).toBe(422);
diff --git a/tests/api/irl-pins-outfit.test.js b/tests/api/irl-pins-outfit.test.js
index 9972464c8..ff446b704 100644
--- a/tests/api/irl-pins-outfit.test.js
+++ b/tests/api/irl-pins-outfit.test.js
@@ -96,7 +96,7 @@ beforeEach(() => {
bakeSpy.mockReset();
bakeSpy.mockResolvedValue({ url: BAKED_URL });
pinRow = {
- id: 'pin-1',
+ id: PIN_ID,
user_id: 'owner-uuid',
avatar_url: '/api/avatars/av-1/glb',
avatar_base_url: null,
@@ -105,24 +105,29 @@ beforeEach(() => {
sessionUser = { id: 'owner-uuid' };
});
+// `irl_pins.id` is a UUID column and the handler rejects any non-UUID id at the
+// boundary, so the fixtures below are real UUIDs rather than readable slugs.
+const PIN_ID = '11111111-1111-4111-8111-111111111111';
+const MISSING_PIN_ID = '22222222-2222-4222-8222-222222222222';
+
describe('PATCH /api/irl/pins outfit — auth + ownership gate', () => {
it('401s an unauthenticated caller (auth gate precedes the handler)', async () => {
sessionUser = null;
- const { res } = await patch({ id: 'pin-1', avatar_manifest: { colors: { outfit: '#7a1f2b' } } });
+ const { res } = await patch({ id: PIN_ID, avatar_manifest: { colors: { outfit: '#7a1f2b' } } });
expect(res.statusCode).toBe(401);
expect(bakeSpy).not.toHaveBeenCalled();
});
it('404s when the pin no longer exists', async () => {
pinRow = null;
- const { res, body } = await patch({ id: 'gone', avatar_manifest: { colors: { outfit: '#7a1f2b' } } });
+ const { res, body } = await patch({ id: MISSING_PIN_ID, avatar_manifest: { colors: { outfit: '#7a1f2b' } } });
expect(res.statusCode).toBe(404);
expect(body.error).toMatch(/not found/i);
});
it('403s a signed-in non-owner and never bakes or updates', async () => {
sessionUser = { id: 'someone-else' };
- const { res, body } = await patch({ id: 'pin-1', avatar_manifest: { colors: { outfit: '#7a1f2b' } } });
+ const { res, body } = await patch({ id: PIN_ID, avatar_manifest: { colors: { outfit: '#7a1f2b' } } });
expect(res.statusCode).toBe(403);
expect(body.error).toMatch(/only the owner/i);
expect(bakeSpy).not.toHaveBeenCalled();
@@ -132,21 +137,21 @@ describe('PATCH /api/irl/pins outfit — auth + ownership gate', () => {
describe('PATCH /api/irl/pins outfit — manifest validation (before bake)', () => {
it('400s a non-object manifest', async () => {
- const { res, body } = await patch({ id: 'pin-1', avatar_manifest: ['nope'] });
+ const { res, body } = await patch({ id: PIN_ID, avatar_manifest: ['nope'] });
expect(res.statusCode).toBe(400);
expect(body.error).toMatch(/must be an object or null/i);
expect(bakeSpy).not.toHaveBeenCalled();
});
it('400s an invented colour slot before any bake runs', async () => {
- const { res, body } = await patch({ id: 'pin-1', avatar_manifest: { colors: { cape: '#000000' } } });
+ const { res, body } = await patch({ id: PIN_ID, avatar_manifest: { colors: { cape: '#000000' } } });
expect(res.statusCode).toBe(400);
expect(body.error).toMatch(/unknown color slot/i);
expect(bakeSpy).not.toHaveBeenCalled();
});
it('400s an invented accessory preset id', async () => {
- const { res, body } = await patch({ id: 'pin-1', avatar_manifest: { accessories: ['jetpack-9000'] } });
+ const { res, body } = await patch({ id: PIN_ID, avatar_manifest: { accessories: ['jetpack-9000'] } });
expect(res.statusCode).toBe(400);
expect(body.error).toMatch(/unknown preset id/i);
expect(bakeSpy).not.toHaveBeenCalled();
@@ -156,10 +161,10 @@ describe('PATCH /api/irl/pins outfit — manifest validation (before bake)', ()
describe('PATCH /api/irl/pins outfit — owner re-skin persists for everyone', () => {
it('bakes onto the captured base, bumps version, returns the new avatar_url, and emits the realtime hook', async () => {
const manifest = { colors: { outfit: '#7a1f2b' }, hidden: ['glasses'] };
- const { res, body } = await patch({ id: 'pin-1', avatar_manifest: manifest });
+ const { res, body } = await patch({ id: PIN_ID, avatar_manifest: manifest });
expect(res.statusCode).toBe(200);
// Bake targets the pin's base GLB (avatar_base_url null → falls back to avatar_url).
- expect(bakeSpy).toHaveBeenCalledWith({ pinId: 'pin-1', baseUrl: '/api/avatars/av-1/glb', manifest });
+ expect(bakeSpy).toHaveBeenCalledWith({ pinId: PIN_ID, baseUrl: '/api/avatars/av-1/glb', manifest });
expect(body.pin.avatar_url).toBe(BAKED_URL);
expect(body.pin.avatar_version).toBe(1);
expect(body.pin.avatar_manifest).toEqual(manifest);
@@ -171,15 +176,15 @@ describe('PATCH /api/irl/pins outfit — owner re-skin persists for everyone', (
pinRow.avatar_url = 'https://three.ws/cdn/irl/pins/pin-1/oldhash.glb';
pinRow.avatar_version = 3;
const manifest = { accessories: ['hat-baseball'] };
- const { res, body } = await patch({ id: 'pin-1', avatar_manifest: manifest });
+ const { res, body } = await patch({ id: PIN_ID, avatar_manifest: manifest });
expect(res.statusCode).toBe(200);
// Critically: baseUrl is the captured base, NOT the already-baked avatar_url.
- expect(bakeSpy).toHaveBeenCalledWith({ pinId: 'pin-1', baseUrl: '/api/avatars/av-1/glb', manifest });
+ expect(bakeSpy).toHaveBeenCalledWith({ pinId: PIN_ID, baseUrl: '/api/avatars/av-1/glb', manifest });
expect(body.pin.avatar_version).toBe(4);
});
it('reverts to the bare base for an empty/cleared manifest (no bake)', async () => {
- const { res, body } = await patch({ id: 'pin-1', avatar_manifest: {} });
+ const { res, body } = await patch({ id: PIN_ID, avatar_manifest: {} });
expect(res.statusCode).toBe(200);
expect(bakeSpy).not.toHaveBeenCalled(); // nothing bakeable → skip the bake
expect(body.pin.avatar_url).toBe('/api/avatars/av-1/glb'); // served base again
@@ -188,7 +193,7 @@ describe('PATCH /api/irl/pins outfit — owner re-skin persists for everyone', (
it('502s and does not persist when the bake throws', async () => {
bakeSpy.mockRejectedValueOnce(new Error('libvips exploded'));
- const { res, body } = await patch({ id: 'pin-1', avatar_manifest: { colors: { hair: '#0e0e0e' } } });
+ const { res, body } = await patch({ id: PIN_ID, avatar_manifest: { colors: { hair: '#0e0e0e' } } });
expect(res.statusCode).toBe(502);
expect(body.error).toMatch(/could not bake/i);
expect(ranOutfitUpdate()).toBe(false);
diff --git a/tests/api/irl-pins-scale.test.js b/tests/api/irl-pins-scale.test.js
index 26732aeae..e992bcec8 100644
--- a/tests/api/irl-pins-scale.test.js
+++ b/tests/api/irl-pins-scale.test.js
@@ -63,7 +63,7 @@ beforeEach(() => {
sqlMock.mockClear();
sessionUser = null;
pinRow = {
- id: 'pin-1',
+ id: PIN_ID,
user_id: null,
device_token: 'device-A',
expires_at: null,
@@ -71,9 +71,14 @@ beforeEach(() => {
};
});
+// `irl_pins.id` is a UUID column and the handler rejects any non-UUID id at the
+// boundary, so the fixtures below are real UUIDs rather than readable slugs.
+const PIN_ID = '11111111-1111-4111-8111-111111111111';
+const MISSING_PIN_ID = '22222222-2222-4222-8222-222222222222';
+
describe('PATCH /api/irl/pins { scale } — resize persistence', () => {
it('lets the placing device resize its own pin', async () => {
- const { res, body } = await patch({ id: 'pin-1', deviceToken: 'device-A', scale: 2.5 });
+ const { res, body } = await patch({ id: PIN_ID, deviceToken: 'device-A', scale: 2.5 });
expect(res.statusCode).toBe(200);
expect(body.pin.anchor_scale).toBe(2.5);
});
@@ -82,49 +87,49 @@ describe('PATCH /api/irl/pins { scale } — resize persistence', () => {
pinRow.user_id = 'owner-uuid';
pinRow.device_token = null;
sessionUser = { id: 'owner-uuid' };
- const { res, body } = await patch({ id: 'pin-1', scale: 0.5 });
+ const { res, body } = await patch({ id: PIN_ID, scale: 0.5 });
expect(res.statusCode).toBe(200);
expect(body.pin.anchor_scale).toBe(0.5);
});
it('rejects a non-owner — resizing someone else’s agent is denied, never silent', async () => {
- const { res } = await patch({ id: 'pin-1', deviceToken: 'device-EVIL', scale: 4 });
+ const { res } = await patch({ id: PIN_ID, deviceToken: 'device-EVIL', scale: 4 });
expect(res.statusCode).toBe(403);
});
it('clamps to the shared 0.25–4 band', async () => {
- const { body: huge } = await patch({ id: 'pin-1', deviceToken: 'device-A', scale: 100 });
+ const { body: huge } = await patch({ id: PIN_ID, deviceToken: 'device-A', scale: 100 });
expect(huge.pin.anchor_scale).toBe(4);
- const { body: tiny } = await patch({ id: 'pin-1', deviceToken: 'device-A', scale: 0.001 });
+ const { body: tiny } = await patch({ id: PIN_ID, deviceToken: 'device-A', scale: 0.001 });
expect(tiny.pin.anchor_scale).toBe(0.25);
});
it('stores NULL for natural size (scale 1) so legacy readers see no change', async () => {
- const { res, body } = await patch({ id: 'pin-1', deviceToken: 'device-A', scale: 1 });
+ const { res, body } = await patch({ id: PIN_ID, deviceToken: 'device-A', scale: 1 });
expect(res.statusCode).toBe(200);
expect(body.pin.anchor_scale).toBeNull();
});
it('rejects garbage scales', async () => {
- const { res: nan } = await patch({ id: 'pin-1', deviceToken: 'device-A', scale: 'big' });
+ const { res: nan } = await patch({ id: PIN_ID, deviceToken: 'device-A', scale: 'big' });
expect(nan.statusCode).toBe(400);
- const { res: neg } = await patch({ id: 'pin-1', deviceToken: 'device-A', scale: -2 });
+ const { res: neg } = await patch({ id: PIN_ID, deviceToken: 'device-A', scale: -2 });
expect(neg.statusCode).toBe(400);
});
it('refuses an expired or hidden pin (nobody would ever see the new size)', async () => {
pinRow.expires_at = '2020-01-01T00:00:00Z';
- const { res: expired } = await patch({ id: 'pin-1', deviceToken: 'device-A', scale: 2 });
+ const { res: expired } = await patch({ id: PIN_ID, deviceToken: 'device-A', scale: 2 });
expect(expired.statusCode).toBe(404);
pinRow.expires_at = null;
pinRow.hidden_at = '2026-01-01T00:00:00Z';
- const { res: hidden } = await patch({ id: 'pin-1', deviceToken: 'device-A', scale: 2 });
+ const { res: hidden } = await patch({ id: PIN_ID, deviceToken: 'device-A', scale: 2 });
expect(hidden.statusCode).toBe(404);
});
it('404s on a pin that does not exist', async () => {
pinRow = null;
- const { res } = await patch({ id: 'pin-1', deviceToken: 'device-A', scale: 2 });
+ const { res } = await patch({ id: PIN_ID, deviceToken: 'device-A', scale: 2 });
expect(res.statusCode).toBe(404);
});
});