Add tests for the inventory string dropdown #513

Merged
Vylpes merged 2 commits from cursor/487-inventory-dropdown-tests into release/0.12.0 2026-09-07 12:19:35 +01:00
Member

Follow-up 1 of 3 from #487, split out as you asked on the issue.

Adds tests/stringDropdowns/Inventory.test.ts, the last untested handler from the #487 coverage checklist. src/stringDropdowns/Inventory.ts is unchanged - this is test-only.

Nine cases, covering every branch of execute:

  • Member in the guild cache: interaction deferred, members.fetch not called, GenerateInventoryPage called with the parsed username / user id / page number, and the page sent via editReply with the image, embed and both button rows.
  • Member not in the cache: falls through to members.fetch(userid) and still renders.
  • No guild (DM): returns before deferring, helper never called.
  • Member cannot be found at all: replies "Unable to find user." and never calls the helper.
  • Helper returns undefined: follows up with "No page for user found." and does not editReply.
  • Helper rejects: error is logged and "An error has occurred running this command." is followed up.

The page-number assertion is the one with teeth: the handler splits interaction.values[0] on a space and passes Number(page), so the test pins both the parse and the string-to-number conversion.

Verified locally on release/0.12.0: new suite 9/9 passing, tsc --noEmit clean, eslint clean on the new file.

Mocking follows the local-factory pattern used by the dispatcher suites in #512 rather than the shared tests/__functions__ generators, because there is no StringSelectMenuInteraction generator yet and adding one for a single suite felt like the wrong trade. Worth extracting if more dropdown suites appear.

No overlap with #512 - that PR does not touch src/stringDropdowns/Inventory.ts or this test path, so the two can merge in either order.

Follow-up 1 of 3 from #487, split out as you asked on the issue. Adds `tests/stringDropdowns/Inventory.test.ts`, the last untested handler from the #487 coverage checklist. `src/stringDropdowns/Inventory.ts` is unchanged - this is test-only. **Nine cases, covering every branch of `execute`:** - Member in the guild cache: interaction deferred, `members.fetch` *not* called, `GenerateInventoryPage` called with the parsed username / user id / page number, and the page sent via `editReply` with the image, embed and both button rows. - Member not in the cache: falls through to `members.fetch(userid)` and still renders. - No guild (DM): returns before deferring, helper never called. - Member cannot be found at all: replies "Unable to find user." and never calls the helper. - Helper returns `undefined`: follows up with "No page for user found." and does not `editReply`. - Helper rejects: error is logged and "An error has occurred running this command." is followed up. The page-number assertion is the one with teeth: the handler splits `interaction.values[0]` on a space and passes `Number(page)`, so the test pins both the parse and the string-to-number conversion. **Verified locally on `release/0.12.0`:** new suite 9/9 passing, `tsc --noEmit` clean, `eslint` clean on the new file. Mocking follows the local-factory pattern used by the dispatcher suites in #512 rather than the shared `tests/__functions__` generators, because there is no `StringSelectMenuInteraction` generator yet and adding one for a single suite felt like the wrong trade. Worth extracting if more dropdown suites appear. No overlap with #512 - that PR does not touch `src/stringDropdowns/Inventory.ts` or this test path, so the two can merge in either order.
Vylpes approved these changes 2026-09-07 11:56:52 +01:00
Merge branch 'release/0.12.0' into cursor/487-inventory-dropdown-tests
All checks were successful
Test / build (push) Successful in 2m55s
3a29f32a34
Vylpes merged commit 5ab5a41846 into release/0.12.0 2026-09-07 12:19:35 +01:00
Vylpes deleted branch cursor/487-inventory-dropdown-tests 2026-09-07 12:19:37 +01:00
Sign in to join this conversation.
No description provided.