Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions frontend/src/components/LeftoverMapPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from "../leftoverMapPlotAxisShare";
import {
formatLeftoverMapPlotAxisSingular,
leftoverMapCompareAxisBadge,
leftoverMapComparePlotAxisBadge,
leftoverSingularForAxis,
LEFTOVER_MAP_COMPARE_PLOT_AXIS_SINGULAR,
LEFTOVER_MAP_COMPARE_PLOT_AXIS_SINGULAR_SHARE,
Expand Down Expand Up @@ -77,10 +77,12 @@ export type LeftoverMapPlotProps = {
variant?: LeftoverMapPlotVariant;
};

/** Return the four vertices for a diamond marker centered at the persisted plot point. */
function diamondPoints(x: number, y: number, radius: number): string {
return `${x},${y - radius} ${x + radius},${y} ${x},${y + radius} ${x - radius},${y}`;
}

/** Compose one axis caption from persisted share and singular evidence for the requested surface. */
function leftoverMapPlotAxisText(
axisIndex: 1 | 2,
leftoverMapAxes: LeftoverMapAxis[] | undefined,
Expand Down Expand Up @@ -234,7 +236,7 @@ export function LeftoverMapPlot({
const comparisonAxisBadges =
variant === "comparison"
? (leftoverMapAxes ?? [])
.map((axis) => leftoverMapCompareAxisBadge(axis))
.map((axis) => leftoverMapComparePlotAxisBadge(axis))
.filter((badge): badge is NonNullable<typeof badge> => badge !== null)
: [];

Expand Down
11 changes: 11 additions & 0 deletions tests/test_grouping_comparison_graphic_axis_badge_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

ROOT = Path(__file__).resolve().parents[1]
SINGULAR_SOURCE = ROOT / "frontend" / "src" / "leftoverMapPlotAxisSingular.ts"
PLOT_SOURCE = ROOT / "frontend" / "src" / "components" / "LeftoverMapPlot.tsx"


def test_comparison_graphic_axis_badge_preserves_singular_when_share_is_missing() -> None:
Expand All @@ -31,3 +32,13 @@ def test_comparison_graphic_axis_badge_keeps_sigma_and_share_independent() -> No
assert "Number.isFinite" in source
assert "Math.sqrt" not in source
assert "Math.max" not in source


def test_comparison_graphic_renders_graphic_specific_axis_badges() -> None:
"""Comparison plot badges must use graphic naming, not comparison-strip naming."""
assert PLOT_SOURCE.exists(), "comparison plot component is missing"
source = PLOT_SOURCE.read_text(encoding="utf-8")

assert "leftoverMapComparePlotAxisBadge" in source
assert ".map((axis) => leftoverMapComparePlotAxisBadge(axis))" in source
assert ".map((axis) => leftoverMapCompareAxisBadge(axis))" not in source
Loading