Skip to content

test(app): replace jest.Mock casts with jest.mocked - #3755

Open
pulpdrew wants to merge 1 commit into
drew/fix-trivial-lintsfrom
drew/jest-mocked
Open

pulpdrew wants to merge 1 commit into
drew/fix-trivial-lintsfrom
drew/jest-mocked

Conversation

@pulpdrew

Copy link
Copy Markdown
Contributor

Summary

This PR resolves various type lint warnings in test files by using jest.mocked and shoehorn's fromPartial. The lint warning baselines have been updated.

Screenshots or video

No behavior changes

How to reproduce

How to test on Vercel preview

References

  • Linear Issue:
  • Related PRs:

@pulpdrew
pulpdrew added this pull request to stack #3756 November 21, 2026 14:52
@pulpdrew
pulpdrew requested a review from a team as a code owner November 21, 2026 14:52
@changeset-bot

changeset-bot Bot commented Nov 21, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 64183d1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Nov 21, 2026 2:55pm UTC
hyperdx-storybook Ready Ready Preview Nov 21, 2026 2:55pm UTC

Request Review

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 473 passed • 1 skipped • 1079s

Status Count
✅ Passed 473
❌ Failed 0
⚠️ Flaky 11
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 2
  • Production lines changed: 4 (+ 2239 in test files, excluded from tier calculation)
  • Branch: drew/jest-mocked
  • Author: pulpdrew

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

Copy link
Copy Markdown
Contributor

PR Review

✅ No issues found.

@github-actions

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 108 in total (1.13%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

Copy link
Copy Markdown
Contributor

Deep Review

Scope: 26 files vs base f2b9d3a3 — 24 Jest test files under packages/app/src/**/__tests__/, plus packages/app/package.json and scripts/ci/ratchet-baseline.json.
Intent: Replace jest.Mock/jest.MockedFunction casts with jest.mocked() and shoehorn's fromPartial()/fromAny() to clear type lint warnings, and ratchet the oxlint (534→468) and app as-any (199→184) baselines down. Test-only; no product behavior change.

✅ No critical issues found.

All eight reviewers returned zero actionable defects. The refactor is mechanical and uniform: fromPartial/fromAny are compile-time identity helpers (runtime-unchanged), converted casts target genuinely-mocked values, and every optional-chaining conversion is paired with a toBeDefined() guard or a throwing narrowing helper, so no assertion was weakened, dropped, or made vacuous. The two baseline reductions are strict tightenings and the 184 value exactly matches the real as any count in packages/app. One strengthened assertion was noted: dashboard.remote.test.ts moved from raw call[1] indexing to toHaveBeenNthCalledWith(..., objectContaining(...)), which now also asserts the request URL.

🔵 P3 nitpicks (3)
  • packages/app/src/components/__tests__/DBTraceWaterfallChart.test.tsx — the refactored setupColumnsMock adds a branch where isLoading: true drops data; no current caller passes both, but a future test supplying data with isLoading: true would silently get no data.
    • Fix: Add a brief comment documenting that the loading branch intentionally discards data, or merge the branches so data is always honored.
  • packages/app/src/hooks/__tests__/useAutoCompleteOptions.test.tsx:204 — fromAny() fully escapes type-checking for the nested map-value mock, leaving this one payload entirely untyped.
    • Fix: Narrow the mock to a typed partial where the runtime shape allows, reserving fromAny() for the genuinely-unmodelable case.
  • packages/app/src/hooks/__tests__/useAutoCompleteOptions.test.tsx, packages/app/src/components/__tests__/NumberTileBackgroundChart.test.tsx — mocked hook results changed from data: null to data: undefined; equivalent only because the consumers normalize both via ??/optional chaining.
    • Fix: Keep as-is; optionally add a one-line comment noting the hooks return undefined at runtime so the value choice is intentional.

Reviewers (8): correctness, testing, maintainability, project-standards, kieran-typescript, previous-comments, learnings-researcher, agent-native.

Testing gaps: fromPartial/fromAny erase structural type-checking of mock return values across the converted files, so a future change that adds a required field a component reads would no longer surface at type-check time — a pre-existing blind spot now expressed more ergonomically, not a regression.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — 64183d16 Deployed Nov 21, 2026 by vercel[bot]
Preview – hyperdx-storybook — 64183d16 Deployed Nov 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant