Skip to content

test(backend): improve addResult test coverage (@NINJA-1029)#8239

Open
NINJA-1029 wants to merge 1 commit into
monkeytypegame:masterfrom
NINJA-1029:test/improve-addResult-coverage
Open

test(backend): improve addResult test coverage (@NINJA-1029)#8239
NINJA-1029 wants to merge 1 commit into
monkeytypegame:masterfrom
NINJA-1029:test/improve-addResult-coverage

Conversation

@NINJA-1029

Copy link
Copy Markdown

Description

This PR adds more tests for the addResult controller in result.spec.ts.

I noticed that some validation and error paths were not covered by the existing tests, so I added tests for those cases. I also updated the existing success test to check that xpBreakdown.daily is updated correctly.

Changes

  • Added tests for validation and guard clause cases, including:

    • TEST_TOO_SHORT
    • RESULT_HASH_INVALID
    • RESULT_SPACING_INVALID
    • MISSING_KEY_DATA
    • DUPLICATE_RESULT
    • username/name validation
    • accuracy and leaderboard opt-out cases
  • Added helper configuration for enableObjectHashCheck and enableLastHashesCheck where needed by the tests.

  • Updated the existing "should add result" test to verify the xpBreakdown.daily field.

Verification

  • Ran pnpm vitest run backend/__tests__/api/controllers/result.spec.ts — all 43 tests passed.
  • Ran pnpm oxlint --type-aware --type-check — no warnings or errors.

@monkeytypegeorge monkeytypegeorge added the backend Server stuff label Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Server stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants