Skip to content

test(app): replace unsafe mock assertions with shoehorn - #2980

Open
k4its1t wants to merge 4 commits into
hyperdxio:mainfrom
k4its1t:ai/replace-test-any-with-shoehorn
Open

test(app): replace unsafe mock assertions with shoehorn#2980
k4its1t wants to merge 4 commits into
hyperdxio:mainfrom
k4its1t:ai/replace-test-any-with-shoehorn

Conversation

@k4its1t

@k4its1t k4its1t commented Aug 23, 2026

Copy link
Copy Markdown

Summary

  • add @total-typescript/shoehorn as an app test dependency
  • replace unsafe partial mock assertions in the three test files identified by the issue with type-checked fromPartial fixtures
  • use exported enum members where a complete typed value is available, and lower the app ratchet baselines from 215 to 206 as any occurrences and from 144 to 141 ESLint disables

How to test on Vercel preview

N/A — non-UI test maintenance change.

Validation

  • make ci-lint
  • affected Jest suites: 3 suites, 41 tests passed
  • pre-commit lint-staged and knip --no-config-hints
  • make ci-unit: the app run hit four failures in an unrelated DBEditTimeChartForm suite under full parallel load; that suite passed 34/34 immediately when rerun in isolation

References

Implemented with Codex assistance.

@changeset-bot

changeset-bot Bot commented Aug 23, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 08ad3e0

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 Aug 23, 2026

Copy link
Copy Markdown

@k4its1t is attempting to deploy a commit to the HyperDX Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added external needs-vouch Author needs a maintainer to vouch for them labels Aug 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi @k4its1t, thanks for the pull request!

Before we review code from a first-time contributor we ask that a maintainer vouches for you, and you're not on our list yet. This PR stays open — it just isn't in the review queue until someone vouches.

To get vouched, open an issue saying hello and what you're working on:

https://github.com/hyperdxio/hyperdx/issues/new?template=introduce-yourself.md

A maintainer will usually reply within a day or two, and then this PR gets picked up as normal. More detail in our contributing guide.

@greptile-apps

greptile-apps Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR replaces unsafe test assertions with typed fromPartial fixtures and adds the corresponding development dependency.

  • Uses exported source and display-type enum members in three component test suites.
  • Lowers the app’s ratchet baselines to reflect the removed assertions and lint suppressions.
  • Updates the Yarn lockfile for @total-typescript/shoehorn.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/app/src/components/tests/DBRowSidePanel.viewTraceTimeFilter.test.tsx Replaces asserted source fixtures with typed partial fixtures and enum-backed source kinds without changing tested behavior.
packages/app/src/components/tests/DBTimeChart.test.tsx Converts hook result fixtures to typed partials and replaces the raw display-type assertion with an enum member.
packages/app/src/components/tests/MetricTableModelForm.test.tsx Uses typed metric-source fixtures and explicitly removes metric-table state when constructing the switched-kind fixture.
packages/app/package.json Adds the test-only shoehorn package as an app development dependency.
scripts/ci/ratchet-baseline.json Reduces app baselines to match the removed unsafe assertions and ESLint disables.
yarn.lock Records the new shoehorn dependency and complete resolved package entry.

Reviews (4): Last reviewed commit: "test(app): apply typed fixture review fe..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

This is a clean, well-scoped test-only refactor. Six reviewers independently confirmed no correctness, type-safety, standards, or coverage regressions. Key facts were verified against the repo:

  • @total-typescript/shoehorn's fromPartial is a runtime identity function, so every converted fixture keeps its exact prior runtime shape — no test behavior changes, only compile-time strictness improves.
  • Ratchet baselines match the actual repo counts after the change (as-any = 206, eslint-disable = 141).
  • Enum substitutions are value-identical: DisplayType.Line === 'line', SourceKind.Log === 'log', SourceKind.Metric === 'metric'; TMetricSource = Extract<TSource, { kind: SourceKind.Metric }>.
  • In MetricTableModelForm, dropping the explicit metricTables: undefined key (now omitted via destructuring) is behavior-neutral because the component reads only savedSource?.kind and savedSource?.from?.databaseName, never metricTables nor object keys.
  • The @total-typescript/shoehorn addition sits in devDependencies with a correctly formatted yarn.lock entry; per AGENTS.md, test/CI/dev-only changes are exempt from changesets, so the changeset-bot notice is informational.
🔵 P3 nitpicks (1)
  • packages/app/src/components/__tests__/DBRowSidePanel.viewTraceTimeFilter.test.tsx:71 -- the sibling TRACE_SOURCE (line 71) and LOG_DEST_SOURCE (line 83) fixtures remain untyped object literals with string-literal kind values while the adjacent ROOT_SOURCE was converted to a typed fromPartial<TSource>, leaving fixture typing uneven within the file; these were pre-existing and outside the diff's conversion targets.
    • Fix: Optionally convert TRACE_SOURCE and LOG_DEST_SOURCE to fromPartial<TSource> with SourceKind members for consistency.
    • correctness, maintainability, kieran-typescript

Reviewers (6): correctness, testing, maintainability, project-standards, kieran-typescript, previous-comments.

@jordan-simonovski

Copy link
Copy Markdown
Contributor

/vouch @pttydou wants to improve FE type safety

@github-actions github-actions Bot mentioned this pull request Aug 24, 2026
kodiakhq Bot pushed a commit that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external needs-vouch Author needs a maintainer to vouch for them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace as any mock fixtures in three app test files with shoehorn

2 participants