Skip to content

test(ui): formatReversalEventType's headline 'merge reverted' branch has zero direct test coverage #8665

Description

@JSONbored

⚠️ Definition of Done: this issue must be completed in full, in a single PR. Do not split this
work across multiple PRs, and do not defer any Deliverable below to a follow-up issue. A PR that
satisfies only some of the Deliverables, stubs a required test, or leaves a checkbox
partially-done does NOT resolve this issue and will be closed.

Context

apps/loopover-ui/src/components/site/app-panels/reversal-health-card-model.ts:28-32's
formatReversalEventType has three branches:

export function formatReversalEventType(eventType: string): string {
  if (eventType === "reversal_reverted") return "merge reverted";
  if (eventType === "reversal_reopened") return "close reopened";
  return eventType.replaceAll("_", " ");
}

Only the "reversal_reopened" branch is exercised today, indirectly, via
reversal-health-card.test.tsx's render of a reversedTargets entry. The "reversal_reverted"
branch — the case that names bot-merge reverts, the headline event this entire card exists to
surface — and the generic fallback branch are never called anywhere in the test suite (confirmed by
repo-wide grep: formatReversalEventType appears only in its own definition and its one .tsx call
site). A typo or refactor regression in the "reversal_reverted" string comparison would go
completely undetected by the current test suite.

Requirements

  • Add direct unit test coverage for all three branches of formatReversalEventType, not just the
    one currently exercised indirectly through a component render.

Deliverables

  • A new test asserts formatReversalEventType("reversal_reverted") === "merge reverted".
  • A new test asserts formatReversalEventType("reversal_reopened") === "close reopened"
    (may already be indirectly covered, but must exist as a direct unit assertion on the function
    itself, not just inferred from a component snapshot).
  • A new test asserts the fallback branch, e.g. formatReversalEventType("some_new_event") === "some new event".

All three Deliverables are required in the same PR.

Test Coverage Requirements

apps/** is excluded from codecov/patch gating (see codecov.yml), but
apps/loopover-ui's own local vitest coverage thresholds still apply — the three new assertions
must be direct unit tests on formatReversalEventType itself (not indirect component-render
inference), so all three branches show real, attributable coverage.

Expected Outcome

All three branches of formatReversalEventType — including the headline "merge reverted" case —
have direct, explicit test coverage, so a future regression in any one of them is caught
immediately.

Links & Resources

  • apps/loopover-ui/src/components/site/app-panels/reversal-health-card-model.ts:28-32
  • apps/loopover-ui/src/components/site/app-panels/reversal-health-card.test.tsx (existing test file
    to extend)

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions