fix(frontend): call toBeDefined() matcher to clear eslint no-unused-expressions#1357
fix(frontend): call toBeDefined() matcher to clear eslint no-unused-expressions#1357cristim wants to merge 2 commits into
Conversation
…xpressions The assertion at users.test.ts:1861 was missing its call parentheses, causing two problems: (1) eslint @typescript-eslint/no-unused-expressions reported it as an error, failing the Build-frontend CI job on every open PR in the repo; (2) the assertion never actually ran, so the test was silently not checking anything. This was the sole error (1 error / 89 warnings) in `npm run lint`; after the fix lint exits 0. All 207 users.test.ts tests still pass.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 19 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA single-line test fix corrects a Jest matcher invocation in the users test file, changing an unreferenced ChangesTest Fix
Estimated code review effort: 1 (Trivial) | ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/__tests__/users.test.ts`:
- Line 1861: The submit-handler assertion in the users test is too weak because
the current `form?.onsubmit || form?.getAttribute('data-handler')` check can
still pass when no handler is wired. Update the assertion in the relevant test
case to verify the actual submit listener/handler attached to the form rather
than relying on a defined value, using the existing `form` reference in
`users.test.ts` to make the test fail when the submit wiring is missing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0bf7b7ac-a022-4293-b0be-1f362685f2d5
📒 Files selected for processing (1)
frontend/src/__tests__/users.test.ts
…-undefined
The prior assertion checked `.toBeDefined()` on
`form?.onsubmit || form?.getAttribute('data-handler')`, which always
evaluated to null: setupUserHandlers wires the submit handler via
addEventListener('submit', ...), so form.onsubmit stays null and no
data-handler attribute is set. toBeDefined() accepts null, so the
assertion passed unconditionally and never proved the handler was wired.
Now spy on userModals.saveUser, dispatch a real submit event on the form,
and assert saveUser was invoked once, matching how sibling handler tests
in this file assert wiring via observable side effects. Verified the
assertion fails (0 calls) when setupUserHandlers is not called.
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
frontend/src/__tests__/users.test.tsline 1861 was missing call parentheses on.toBeDefined, causingeslint @typescript-eslint/no-unused-expressionsto report 1 error and fail the Build-frontend CI job on every open PR in the repo.npm run lint(the other ~89 findings are non-blockingno-explicit-anywarnings).Verification
npm run lintbefore: 1 error, exit 1npm run lintafter: 0 errors, 89 warnings, exit 0npx jest users.test: 207 tests pass, 0 failuresImpact
Unblocks the Build-frontend CI check for all currently open PRs.
Summary by CodeRabbit