Skip to content

fix(frontend): call toBeDefined() matcher to clear eslint no-unused-expressions#1357

Open
cristim wants to merge 2 commits into
mainfrom
fix/frontend-eslint-unused-expr
Open

fix(frontend): call toBeDefined() matcher to clear eslint no-unused-expressions#1357
cristim wants to merge 2 commits into
mainfrom
fix/frontend-eslint-unused-expr

Conversation

@cristim

@cristim cristim commented Jul 5, 2026

Copy link
Copy Markdown
Member

Summary

  • frontend/src/__tests__/users.test.ts line 1861 was missing call parentheses on .toBeDefined, causing eslint @typescript-eslint/no-unused-expressions to report 1 error and fail the Build-frontend CI job on every open PR in the repo.
  • The missing parentheses also meant the assertion never actually ran, so the test was silently not checking anything.
  • This is the sole error in npm run lint (the other ~89 findings are non-blocking no-explicit-any warnings).

Verification

  • npm run lint before: 1 error, exit 1
  • npm run lint after: 0 errors, 89 warnings, exit 0
  • npx jest users.test: 207 tests pass, 0 failures

Impact

Unblocks the Build-frontend CI check for all currently open PRs.

Summary by CodeRabbit

  • Tests
    • Corrected a test assertion so it now properly verifies that the user form has a submit handler configured.

…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.
@cristim cristim added type/bug Defect priority/p2 Backlog-worthy severity/low Minor harm urgency/this-quarter Within the quarter impact/many Affects most users effort/xs Trivial / one-liner triaged Item has been triaged labels Jul 5, 2026
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 19 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 71da89f4-d562-49c1-84ff-fb2c029f9ca4

📥 Commits

Reviewing files that changed from the base of the PR and between 59ce979 and 6900476.

📒 Files selected for processing (1)
  • frontend/src/__tests__/users.test.ts
📝 Walkthrough

Walkthrough

A single-line test fix corrects a Jest matcher invocation in the users test file, changing an unreferenced toBeDefined property access into an actual toBeDefined() function call to properly perform the assertion.

Changes

Test Fix

Layer / File(s) Summary
Fix toBeDefined() matcher invocation
frontend/src/__tests__/users.test.ts
Corrects a Jest assertion by calling toBeDefined() instead of referencing it without invocation, so the check for the handler/attribute is actually performed.

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the fix to the missing toBeDefined() call and the related lint issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/frontend-eslint-unused-expr

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

@cristim

cristim commented Jul 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 60526ce and 59ce979.

📒 Files selected for processing (1)
  • frontend/src/__tests__/users.test.ts

Comment thread frontend/src/__tests__/users.test.ts Outdated
…-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.
@cristim

cristim commented Jul 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/xs Trivial / one-liner impact/many Affects most users priority/p2 Backlog-worthy severity/low Minor harm triaged Item has been triaged type/bug Defect urgency/this-quarter Within the quarter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant