Skip to content

🔧 chore: restore test coverage for the Mesh timeline renderers #1075

Description

@lukecotter

🔧 Chore Description

The Sprite timeline render path was deleted in #1066, along with the two suites that
covered it: features/timeline/__tests__/markers.test.ts (699 lines) and
batching.test.ts (564 lines). Their coverage was not ported to the Mesh replacements
that took over, so both Mesh renderers now have no direct tests.

rg -l 'MeshMarkerRenderer|MeshRectangleRenderer|MARKER_COLORS|MARKER_ALPHA' -- '*.test.ts'

returns nothing.

Nothing is broken for a user today. The risk is that a change to either renderer now
lands with nothing to catch it.

What is unguarded

MeshMarkerRenderer:

  • Viewport culling of markers — MeshMarkerRenderer.ts:133,
    resolvedEndTime < bounds.timeStart || marker.startTime > bounds.timeEnd.
    TemporalSegmentTree covers frame culling, which is a different path.
  • Marker type to colour and alpha — MeshMarkerRenderer.ts:153-154, MARKER_COLORS[marker.type]
    and MARKER_ALPHA_BY_TYPE[marker.type]. MarkerProcessor.test.ts and MarkerHitTest.test.ts
    hardcode literal colours in their fixtures, so neither exercises the lookup.
  • End-time resolution and the min-width clamp — MeshMarkerRenderer.ts:129,140,144,
    endTime ?? startTime then Math.max(exactWidth, MARKER_MIN_WIDTH_PX). markerDuration has
    these as a pure function, but the renderer inlines the ?? rather than calling it, so the
    named regression "a marker with no endTime is not extended to the next marker" is unguarded
    where it lives.
  • updateMarkers() — no test calls it. Worth knowing the behaviour changed in the port: the
    Sprite class re-sorted by startTime, the Mesh class uses sortMarkersByTimeAndSeverity.
  • The real MARKER_MIN_WIDTH_PX (2), MARKER_GAP_PX (1) and MARKER_BUCKET_PX (4)
    (flamechart.types.ts:683-697) are never proved to be what the renderer wires in —
    MarkerProcessor.test.ts passes its own MIN = 3.

MeshRectangleRenderer and the production culling path:

  • No test asserts a visible rectangle's x, y, width, height or eventRef.
    TemporalSegmentTree.ts:585-586 sets x and width from zoom; RectangleCache.ts:289-291
    sets y and height. Bucket y is still asserted, but that is the bucket path.
  • An unknown category is dropped — RectangleCache.ts:279 if (rects) and the
    if (!batch) { continue; } in MeshRectangleRenderer.render.
  • A zero-duration event yields no rect — RectangleCache.ts:274, if (duration.total && category).
  • Batch dirty/clear bookkeeping. MeshRectangleRenderer keeps it and its own comment says it is
    "for tests and debugging", but nothing reads batches any more.
  • Depth culling under a vertical pan. No culling test passes a non-zero offsetY —
    the shared makeViewport helper defaults it to 0 and neither culling suite overrides it.

Notes

  • RectangleCache.getCulledRectangles() is the production path. It is currently called by one
    test (TemporalSegmentTree.test.ts:319) for a legacy-parity event count only;
    RectangleCache.bucket.test.ts drives legacyCullRectangles, which is the oracle, not production.
  • Marker hit testing is well covered by MarkerHitTest.test.ts, severity and offsetX included.
    The gap is the renderer, not the hit test.
  • Some of the old cases were weak and need not be ported as written: four of the five old T014
    hit-test cases wrapped their assertions in if (markerScreenX >= 0 && ...), so they could pass
    having executed no assertion, and "should handle zero zoom gracefully" had no assertion at all.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions