Fix tests #61

Closed
opened 2026-10-15 13:16:14 +00:00 by Syndria98 · 2 comments
Owner

There are failing tests, can you fix them?

There are failing tests, can you fix them?
Syndria98 added the ai-ready label 2026-10-15 13:16:14 +00:00
Agent added the working label 2026-10-15 13:58:44 +00:00
Collaborator

All tests pass now: 210/210 (was 166/189 passing with 23 failures).

What was broken and what I changed

One real bug in the code — dragonroll-foundry/scripts/api.js:
initializeCharacterSync()'s error handler called scheduleDragonrollCharacterSync(15000), which was never defined. So a startup sync that could not reach Dragonroll died with ReferenceError: scheduleDragonrollCharacterSync is not defined — masking the real error and never retrying. Added the scheduler next to the reconcile it schedules, mirroring the existing scheduleSnapshotSync (tracked timeout so repeated failures collapse to one pending retry). Verified by loading the module in a stubbed Foundry world: the failure now logs Character sync failed and will retry. with the actual error.

Tests that had drifted from code that landed since (routes/foundry-link.js hashes its sync token, the map/actor routes gained the shared per-section folder tree, and the sidebar rows come from that tree):

  • tests/item-folder-sync.test.js: dropped an unneeded top-level await that made Node treat the whole CommonJS file as an ES module (every test in it failed before running); handed the stubbed require the node:crypto the route now needs; seeded fake documents with the campaign they belong to, like tests/entry-folders.test.js does, since the routes scope every lookup by campaign; gave the sandbox actor the update/updateEmbeddedDocuments the push path calls.
  • tests/map-pins.test.js, tests/map-tokens.test.js: stubbed ../models/Folder for the map and actor routers, and Folder.filterForTarget for the note router.
  • tests/map-tokens.test.js / tests/item-sheet-window.test.js: locate the actor and item rows as the entry rows of their section (@dragstart="startActorDrag($event, row.item)", v-for="row in entryRows.item.value") instead of the pre-folder-tree markup.

Two assertions that could never pass in tests/item-folder-sync.test.js, fixed to test what they describe:

  • shape.includes(["item", "Torch"]) compares array identities, so it was always false; and a row object was destructured with an array pattern (rows.filter(([kind]) => …)), which throws. Both now read from the mapped shape.
  • The expected sidebar shape mixed depths (Pistol in a folder at depth 1 while Longsword in one at depth 0 was also 1) and listed Longsword after the root Torch, outside its own folder. It now asserts the order BuildItemRows documents: each folder followed by what stands in it, one step deeper, root items last.

I changed no app behaviour beyond the retry fix, and did not commit — the automation handles that.

All tests pass now: **210/210** (was 166/189 passing with 23 failures). ## What was broken and what I changed **One real bug in the code** — `dragonroll-foundry/scripts/api.js`: `initializeCharacterSync()`'s error handler called `scheduleDragonrollCharacterSync(15000)`, which was never defined. So a startup sync that could not reach Dragonroll died with `ReferenceError: scheduleDragonrollCharacterSync is not defined` — masking the real error and never retrying. Added the scheduler next to the reconcile it schedules, mirroring the existing `scheduleSnapshotSync` (tracked timeout so repeated failures collapse to one pending retry). Verified by loading the module in a stubbed Foundry world: the failure now logs `Character sync failed and will retry.` with the actual error. **Tests that had drifted from code that landed since** (`routes/foundry-link.js` hashes its sync token, the map/actor routes gained the shared per-section folder tree, and the sidebar rows come from that tree): - `tests/item-folder-sync.test.js`: dropped an unneeded top-level `await` that made Node treat the whole CommonJS file as an ES module (every test in it failed before running); handed the stubbed `require` the `node:crypto` the route now needs; seeded fake documents with the campaign they belong to, like `tests/entry-folders.test.js` does, since the routes scope every lookup by campaign; gave the sandbox actor the `update`/`updateEmbeddedDocuments` the push path calls. - `tests/map-pins.test.js`, `tests/map-tokens.test.js`: stubbed `../models/Folder` for the map and actor routers, and `Folder.filterForTarget` for the note router. - `tests/map-tokens.test.js` / `tests/item-sheet-window.test.js`: locate the actor and item rows as the entry rows of their section (`@dragstart="startActorDrag($event, row.item)"`, `v-for="row in entryRows.item.value"`) instead of the pre-folder-tree markup. **Two assertions that could never pass** in `tests/item-folder-sync.test.js`, fixed to test what they describe: - `shape.includes(["item", "Torch"])` compares array identities, so it was always false; and a row object was destructured with an array pattern (`rows.filter(([kind]) => …)`), which throws. Both now read from the mapped `shape`. - The expected sidebar shape mixed depths (`Pistol` in a folder at depth 1 while `Longsword` in one at depth 0 was also 1) and listed `Longsword` after the root `Torch`, outside its own folder. It now asserts the order `BuildItemRows` documents: each folder followed by what stands in it, one step deeper, root items last. I changed no app behaviour beyond the retry fix, and did not commit — the automation handles that.
Collaborator

Implementation is ready for review: #68

Implementation is ready for review: https://git.aranroig.com/Syndria98/dragonroll/pulls/68
Agent added the help wanted label 2026-10-15 14:20:27 +00:00
Agent referenced this issue from a commit 2026-10-15 14:20:27 +00:00
Agent removed the working label 2026-10-15 14:20:27 +00:00
Syndria98 referenced this issue from a commit 2026-10-15 15:16:53 +00:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Syndria98/dragonroll#61