Skip to content

test(ui): de-duplicate page-test mock scaffolding and strengthen icon assertions #1629

Description

@ka1kqi

Part of #1630.

Three related bits of test debt surfaced while reviewing the domain-icon registry work. None is urgent; grouping them so they are fixed together.

Duplicated retention mock block

The same six-field useRetention + PricingDialog mock is copy-pasted across five files:

  • frontend/ui/src/app/projects/[projectId]/detectors/page.test.tsx
  • frontend/ui/src/app/projects/[projectId]/detectors/[detectorId]/page.test.tsx
  • frontend/ui/src/app/projects/[projectId]/sessions/page.test.tsx
  • frontend/ui/src/app/projects/[projectId]/users/page.test.tsx
  • frontend/ui/src/app/projects/[projectId]/traces/page.user-filter.test.tsx

A shared test helper would stop the next page test rediscovering which fields the hook returns. Deliberately not done during the registry work to avoid diverging from the established pattern mid-change.

Duplicated page-test scaffolding

traces/page.user-filter.test.tsx duplicates roughly 60 lines of mock scaffolding from its sibling traces/page.prefetch.test.tsx, which already uses mutable module-level state for exactly this "vary one input across cases" need. Making useSearchParams read a mutable variable there would let the badge case move in and the extra file be deleted.

Its useRetention / PricingDialog mocks are also redundant, since its QueryClientProvider wrapper lets the real hook run.

Icon changes that are covered but not asserted

Coverage counts these lines, but the tests would still pass with the icon deleted:

  • frontend/ui/src/features/traces/components/SessionDetailPanel.test.tsx asserts badge text only, across four migrated icon lines
  • The onboarding project-step glyph change (LayersFolderKanban) has no assertion at all

SpanTreeView.render.test.tsx and SpanTimelineView.test.tsx show the pattern to copy: assert badge.querySelector("svg") is present.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions