Skip to content

test(backend): unskip validateBody 400-on-invalid-body tests - #769

Merged
LucasSantana-Dev merged 5 commits into
mainfrom
fix/unskip-validatebody-tests
Apr 22, 2026
Merged

LucasSantana-Dev merged 5 commits into
mainfrom
fix/unskip-validatebody-tests

Conversation

@LucasSantana-Dev

Copy link
Copy Markdown
Owner

Summary

Two integration tests in `packages/backend/tests/integration/routes/management.test.ts` were marked `.skip` with a note that `validateBody` wasn't catching errors in certain scenarios. Backlog item (`.claude/plans/backlog-2026-04-21.md`) flagged them.

Evidence that unskipping is safe

Middleware chain for both endpoints:

```
requireAuth
→ requireGuildModuleAccess('settings'|'commands', 'manage')
→ writeLimiter
→ validateParams(guildIdParam)
→ validateBody(...) ← the check under test
→ asyncHandler
```

`beforeEach` (file line 76) sets up:

  • `sessionService.getSession` → `MOCK_SESSION_DATA` (authenticated, `fixtures/mock-data.ts:46`)
  • `guildAccessService.resolveGuildContext` → `MOCK_GUILD_CONTEXT` with full `manage` access on every module (`fixtures/mock-data.ts:65`)
  • `guildAccessService.hasAccess` → `true`
  • `jest.clearAllMocks()` for isolation

Given this, a request to `PATCH /api/guilds/:guildId/automod/settings` with `{ spamThreshold: 'not a number' }` should reach `validateBody` with the body parsed (`spamThreshold: z.number().int().min(1).max(100).optional()` in `schemas/management.ts:16`), fail Zod's type check, and return 400. Same for `POST /api/guilds/:guildId/commands` with empty body — `name` is required per `createCommandBody`.

The skip comment was likely a carryover from an earlier middleware state. Unskipping in this PR to verify; if CI surfaces a real failure, we get actionable evidence instead of a silent skip.

Test plan

  • CI: `Quality Gates` must run `npm run test --workspace=packages/backend` and both tests pass.
  • If they fail, the failure output tells us whether it's a mock-setup gap or a real middleware bug — either actionable.

Risk

Zero. If the tests fail, CI catches it and this PR doesn't merge. If they pass, we eliminate 2 skipped negative-path tests from the backlog.

🤖 Generated with Claude Code

Both tests were marked .skip with a comment claiming validateBody
didn't catch errors in certain scenarios. Tracing the middleware
chain (requireAuth → requireGuildModuleAccess → writeLimiter →
validateParams → validateBody) against the fixture setup in
beforeEach (MOCK_SESSION_DATA authenticated, MOCK_GUILD_CONTEXT with
full manage access, guildAccessService.hasAccess → true), validateBody
should reach the Zod safeParse and return 400 on type-mismatch /
missing-required-fields. Unskipping to verify; if a real regression
surfaces, CI will show the actual failure rather than a silent skip.
@LucasSantana-Dev
LucasSantana-Dev enabled auto-merge (squash) April 22, 2026 05:54
@vercel

vercel Bot commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lucky Canceled Canceled Apr 22, 2026 6:23am

Request Review

@coderabbitai

coderabbitai Bot commented Apr 22, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@LucasSantana-Dev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 46 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 9 minutes and 46 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c02d17a7-e282-4008-81de-6e1df745048d

📥 Commits

Reviewing files that changed from the base of the PR and between ee2f05f and fe4f7dc.

📒 Files selected for processing (1)
  • packages/backend/tests/integration/routes/management.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/unskip-validatebody-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit 8ddda49 into main Apr 22, 2026
12 checks passed
LucasSantana-Dev added a commit that referenced this pull request Apr 22, 2026
…ce (#775)

* docs(backlog): mark completed 2026-04-21 backlog items with PR evidence

10 of the 16 tasks in docs/specs/2026-04-21-backlog-map/tasks.md
already shipped — the unchecked state was sending future agents
down dead ends. Splits the list into Open / Completed, cites the
landing PR for each done item, and promotes the truly-remaining
work to the top.

Completed:
- A-R2 token aliases (#763)
- A-R3 SectionHeader eyebrowIcon + statusBand (#765)
- PR #729 webhook coverage (ef06904)
- tar Dependabot alerts (#766, replacing #755 which was closed)
- PR queue rebase sweep — 14 PRs landed 2026-04-22
- Shared Top.gg constants (already in packages/shared/src/constants/topgg.ts)
- validateBody + unskipped tests (#769)
- Frontend token/font decision (#763)
- Sonar coverage on #737 and #740 (both merged)

Still open: follow-redirects/hono lock refresh, release/tag drift
(production-visible), autoplay diversity dedup, queueManipulation
refactor, /integrations page collapse (B-R4), BRANDING_GUIDE update
(D-R2), per-page ports (13 pages).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs(backlog): normalize version prefix (v2.6.148) per CodeRabbit

Use `v` prefix consistently alongside `v2.6.132`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
LucasSantana-Dev added a commit that referenced this pull request May 13, 2026
Both tests were marked .skip with a comment claiming validateBody
didn't catch errors in certain scenarios. Tracing the middleware
chain (requireAuth → requireGuildModuleAccess → writeLimiter →
validateParams → validateBody) against the fixture setup in
beforeEach (MOCK_SESSION_DATA authenticated, MOCK_GUILD_CONTEXT with
full manage access, guildAccessService.hasAccess → true), validateBody
should reach the Zod safeParse and return 400 on type-mismatch /
missing-required-fields. Unskipping to verify; if a real regression
surfaces, CI will show the actual failure rather than a silent skip.
LucasSantana-Dev added a commit that referenced this pull request May 13, 2026
…ce (#775)

* docs(backlog): mark completed 2026-04-21 backlog items with PR evidence

10 of the 16 tasks in docs/specs/2026-04-21-backlog-map/tasks.md
already shipped — the unchecked state was sending future agents
down dead ends. Splits the list into Open / Completed, cites the
landing PR for each done item, and promotes the truly-remaining
work to the top.

Completed:
- A-R2 token aliases (#763)
- A-R3 SectionHeader eyebrowIcon + statusBand (#765)
- PR #729 webhook coverage (a8edbe8)
- tar Dependabot alerts (#766, replacing #755 which was closed)
- PR queue rebase sweep — 14 PRs landed 2026-04-22
- Shared Top.gg constants (already in packages/shared/src/constants/topgg.ts)
- validateBody + unskipped tests (#769)
- Frontend token/font decision (#763)
- Sonar coverage on #737 and #740 (both merged)

Still open: follow-redirects/hono lock refresh, release/tag drift
(production-visible), autoplay diversity dedup, queueManipulation
refactor, /integrations page collapse (B-R4), BRANDING_GUIDE update
(D-R2), per-page ports (13 pages).

* docs(backlog): normalize version prefix (v2.6.148) per CodeRabbit

Use `v` prefix consistently alongside `v2.6.132`.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@LucasSantana-Dev
LucasSantana-Dev deleted the fix/unskip-validatebody-tests branch May 14, 2026 02:02

This branch was successfully deployed

1 active deployment
Preview — fe4f7dc3 Deployed Apr 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant