Skip to content

test(plexus): add zoom utils coverage#3716

Merged
yurishkuro merged 3 commits intojaegertracing:mainfrom
jkowall:codex/plexus-zoom-utils-tests
Apr 11, 2026
Merged

test(plexus): add zoom utils coverage#3716
yurishkuro merged 3 commits intojaegertracing:mainfrom
jkowall:codex/plexus-zoom-utils-tests

Conversation

@jkowall
Copy link
Copy Markdown
Contributor

@jkowall jkowall commented Apr 10, 2026

Summary

  • add unit coverage for packages/plexus/src/zoom/utils.ts, including scale bounds, centering, constraint clamping, and zoom formatting helpers
  • fold in the follow-up review fixes by using the current-year header, avoiding brittle referential assertions, and reusing DEFAULT_SCALE_EXTENT in the bound checks
  • make getZoomStyle() / getZoomAttr() and ZoomManager strictly require typed argument and fix tests to pass one

Why

The plexus zoom helpers did not have direct unit coverage, which left the zoom math and formatting behavior unguarded. While addressing that gap, automated review feedback surfaced a few follow-up fixes in the new tests: one brittle identity assertion, missing explicit null cases, and a type mismatch where the implementation already handled null but the TypeScript signatures did not.

Impact

This change increases confidence in the zoom utility behavior without changing the underlying zoom math. The only source change outside the tests is the type widening for the formatting helpers so the types match the existing null-safe implementation.

Validation

  • npm run fmt
  • npm test -- src/zoom/utils.test.ts
  • npm run build
  • npm run lint currently fails on unrelated existing 2026 copyright-header issues in packages/jaeger-ui/src/components/TraceDiff/duck.test.js, packages/jaeger-ui/src/components/TraceDiff/duck.ts, packages/jaeger-ui/src/components/TracePage/ArchiveNotifier/duck.test.js, and packages/jaeger-ui/src/components/TracePage/ArchiveNotifier/duck.ts
  • npm test currently fails on an unrelated existing missing-module issue in packages/jaeger-ui/src/utils/zustand-class-bridge.test.tsx (Cannot find module 'zustand')

Add unit tests for the plexus zoom helpers and fold in the follow-up fixes from automated review feedback. The updated tests cover the exported scale bounds, avoid brittle referential assertions, and explicitly verify null handling for the zoom formatting helpers.

Signed-off-by: Jonah Kowall <jkowall@kowall.net>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.90%. Comparing base (bdcf63b) to head (927dd26).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3716      +/-   ##
==========================================
+ Coverage   89.22%   89.90%   +0.67%     
==========================================
  Files         331      327       -4     
  Lines        9970     9845     -125     
  Branches     2591     2569      -22     
==========================================
- Hits         8896     8851      -45     
+ Misses        931      861      -70     
+ Partials      143      133      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jkowall jkowall marked this pull request as ready for review April 10, 2026 06:57
@jkowall jkowall requested a review from a team as a code owner April 10, 2026 06:57
Copilot AI review requested due to automatic review settings April 10, 2026 06:57
@jkowall jkowall added the changelog:test Change that's adding missing tests or correcting existing tests label Apr 10, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Jest unit coverage for the Plexus zoom helper utilities and aligns TypeScript signatures with existing null-safe runtime behavior.

Changes:

  • Add packages/plexus/src/zoom/utils.test.ts to cover scale extent bounds, fit/centering, constrain clamping, and formatting helpers.
  • Widen getZoomStyle() / getZoomAttr() (and ZoomManager wrappers) to accept null in addition to undefined.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/plexus/src/zoom/ZoomManager.ts Widens wrapper method parameter types to accept null transforms.
packages/plexus/src/zoom/utils.ts Widens helper function parameter types to accept null transforms; keeps behavior unchanged.
packages/plexus/src/zoom/utils.test.ts New Jest test coverage for zoom scale/fit/constrain and formatting helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

yurishkuro and others added 2 commits April 11, 2026 01:20
Remove nullable parameters from getZoomAttr and getZoomStyle since
all callers always pass a ZoomTransform. Update test mocks to provide
zoomTransform: zoomIdentity and restrict vitest to src/ directory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Copilot AI review requested due to automatic review settings April 11, 2026 04:30
@yurishkuro yurishkuro enabled auto-merge April 11, 2026 04:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +67 to 72
export function getZoomStyle(transform: ZoomTransform): React.CSSProperties {
const { x, y, k } = transform;
const rv: React.CSSProperties = {
return {
transform: `translate(${x.toFixed()}px, ${y.toFixed()}px) scale(${k})`,
transformOrigin: '0 0',
};
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

The previous implementation of getZoomStyle() handled null/undefined transforms by returning a default (identity) style. This change removes that guard and will now throw at runtime if any caller passes a missing transform (and it also contradicts the PR description about explicitly accepting null). Consider restoring the null-safe behavior (and typing the param as ZoomTransform | null | undefined) or ensure all call sites always pass zoomIdentity and update the PR description/API docs accordingly.

Copilot uses AI. Check for mistakes.
if (!transform) {
return undefined;
}
export function getZoomAttr(transform: ZoomTransform): string {
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

getZoomAttr() used to return undefined when transform was falsy, which is safe to pass through to the SVG transform attribute. It now unconditionally formats x/y/k and will throw if transform is null/undefined, so this is a runtime behavior change and potential breaking change for any deep-import consumers. Consider reintroducing the null/undefined guard (and reflect it in the return type) or explicitly guarantee a non-null transform everywhere this is called.

Suggested change
export function getZoomAttr(transform: ZoomTransform): string {
export function getZoomAttr(transform: ZoomTransform | null | undefined): string | undefined {
if (!transform) {
return undefined;
}

Copilot uses AI. Check for mistakes.
Comment on lines +44 to 49
static getZoomAttr(zoomTransform: ZoomTransform): string {
return getZoomAttr(zoomTransform);
}

static getZoomStyle(zoomTransform: ZoomTransform | void): React.CSSProperties {
static getZoomStyle(zoomTransform: ZoomTransform): React.CSSProperties {
return getZoomStyle(zoomTransform);
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

These wrappers were changed from accepting an optional transform (ZoomTransform | void) to requiring a ZoomTransform. Since ZoomManager is a public-ish API (deep import) and getZoomAttr/getZoomStyle previously tolerated missing transforms, this is a potentially breaking change and also conflicts with the PR description about explicitly accepting null. If the intent is to stay backward compatible, keep the parameter optional/nullable and preserve the null-safe fallback behavior in utils.

Copilot uses AI. Check for mistakes.
Comment on lines +121 to +126
describe('getZoomStyle', () => {
it('returns CSS properties for identity transform', () => {
expect(getZoomStyle(zoomIdentity)).toEqual({
transform: 'translate(0px, 0px) scale(1)',
transformOrigin: '0 0',
});
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

The new tests cover only non-null transforms for getZoomStyle() / getZoomAttr(). Given the prior behavior (and PR description) around explicitly handling null/undefined, add explicit test cases for missing transforms (or, if missing transforms are no longer supported, update the PR description and consider adding a negative test/assertion so the behavior change is intentional and documented).

Copilot uses AI. Check for mistakes.
@yurishkuro yurishkuro added this pull request to the merge queue Apr 11, 2026
Merged via the queue into jaegertracing:main with commit 52dd392 Apr 11, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:test Change that's adding missing tests or correcting existing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants