Implement all 30 test.todo stubs across the test suite #502

Open
Copilot wants to merge 2 commits from copilot/add-tests-for-todos into release/0.12.0
Member

30 test.todo stubs existed across the codebase with no implementations, leaving core flows (drop lifecycle, claim, reroll, multidrop, timers, effect purchasing) without test coverage.

Mock infrastructure

  • Added deferReply to ButtonInteraction mock type and generator (used by Reroll)
  • Added reply and options.get to ChatInputCommandInteraction mock type and generator (used by error paths and effects/Buy)

New test implementations

  • timers/PurgeClaims — verifies FetchAll, RemoveMany receives only claims older than 2 minutes, and LogInfo is called
  • helpers/DropEmbedHelper — verifies GenerateDropButtons returns an ActionRowBuilder with 3 ButtonBuilder components
  • helpers/EffectHelperGenerateEffectBuyEmbed — covers invalid effect id, new user auto-creation, insufficient currency, success path, and disabled-button state
  • commands/effects/Buy — string error reply, embed/row reply, and quantity defaulting to 1
  • buttonEvents/Effects — routes buy action to Buy.Execute
  • commands/drop — local file path (readFileSync called, files array populated), new user creation, RemoveCurrency failure reply, null card warn+reply, and inner try/catch error path
  • commands/multidrop — local vs. http:// vs. https:// image hosting (file attachment vs. empty files array)
  • buttonEvents/RerollRemoveCurrency called with ClaimCost, user saved, insufficient currency reply
  • buttonEvents/Multidrop — same local/http/https image hosting coverage for the Keep action

Key implementation notes

fs must be mocked with jest.requireActual spread to preserve typeorm's native bindings:

jest.mock("fs", () => ({
    ...jest.requireActual("fs"),
    readFileSync: jest.fn().mockReturnValue(Buffer.from("fake-image")),
}));

Tests using beforeAll to run the SUT once must not pair with a file-level beforeEach(() => jest.resetAllMocks()), as that clears call records before assertions execute.

30 `test.todo` stubs existed across the codebase with no implementations, leaving core flows (drop lifecycle, claim, reroll, multidrop, timers, effect purchasing) without test coverage. ## Mock infrastructure - Added `deferReply` to `ButtonInteraction` mock type and generator (used by `Reroll`) - Added `reply` and `options.get` to `ChatInputCommandInteraction` mock type and generator (used by error paths and `effects/Buy`) ## New test implementations - **`timers/PurgeClaims`** — verifies `FetchAll`, `RemoveMany` receives only claims older than 2 minutes, and `LogInfo` is called - **`helpers/DropEmbedHelper`** — verifies `GenerateDropButtons` returns an `ActionRowBuilder` with 3 `ButtonBuilder` components - **`helpers/EffectHelper` — `GenerateEffectBuyEmbed`** — covers invalid effect id, new user auto-creation, insufficient currency, success path, and disabled-button state - **`commands/effects/Buy`** — string error reply, embed/row reply, and quantity defaulting to `1` - **`buttonEvents/Effects`** — routes `buy` action to `Buy.Execute` - **`commands/drop`** — local file path (`readFileSync` called, `files` array populated), new user creation, `RemoveCurrency` failure reply, null card warn+reply, and inner try/catch error path - **`commands/multidrop`** — local vs. `http://` vs. `https://` image hosting (file attachment vs. empty `files` array) - **`buttonEvents/Reroll`** — `RemoveCurrency` called with `ClaimCost`, user saved, insufficient currency reply - **`buttonEvents/Multidrop`** — same local/http/https image hosting coverage for the Keep action ## Key implementation notes `fs` must be mocked with `jest.requireActual` spread to preserve typeorm's native bindings: ```ts jest.mock("fs", () => ({ ...jest.requireActual("fs"), readFileSync: jest.fn().mockReturnValue(Buffer.from("fake-image")), })); ``` Tests using `beforeAll` to run the SUT once must not pair with a file-level `beforeEach(() => jest.resetAllMocks())`, as that clears call records before assertions execute.
Copilot requested review from Vylpes 2026-05-05 20:35:32 +01:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin copilot/add-tests-for-todos:copilot/add-tests-for-todos
git switch copilot/add-tests-for-todos

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch release/0.12.0
git merge --no-ff copilot/add-tests-for-todos
git switch copilot/add-tests-for-todos
git rebase release/0.12.0
git switch release/0.12.0
git merge --ff-only copilot/add-tests-for-todos
git switch copilot/add-tests-for-todos
git rebase release/0.12.0
git switch release/0.12.0
git merge --no-ff copilot/add-tests-for-todos
git switch release/0.12.0
git merge --squash copilot/add-tests-for-todos
git switch release/0.12.0
git merge --ff-only copilot/add-tests-for-todos
git switch release/0.12.0
git merge copilot/add-tests-for-todos
git push origin release/0.12.0
Sign in to join this conversation.
No description provided.