Skip to content

test(report): fix inverted SparklineData direction for lower-is-better metrics#353

Merged
decko merged 2 commits into
mainfrom
soda/305
May 26, 2026
Merged

test(report): fix inverted SparklineData direction for lower-is-better metrics#353
decko merged 2 commits into
mainfrom
soda/305

Conversation

@decko
Copy link
Copy Markdown
Owner

@decko decko commented May 26, 2026

Summary

Fix two bugs in the _make_report_with_sparklines helper method inside TestSparklineSvgRendering:

Bug 1 — Inverted direction semantics (line 4409)
The rework_cycles sparkline was constructed with direction="down", but rework_cycles is a lower-is-better metric. Values [1.5, 1.2, 0.9] are decreasing, which is an improvement — so the polarity-aware direction field must be "up" (green/improving). The value_direction="down" correctly stays as-is (it tracks raw numeric movement).

Bug 2 — Overly broad assertion (line 4542)
The test test_rework_cycles_delta_badge_no_red_css_class asserted "delta-down" not in content, but the HTML template always emits .delta-badge.delta-down { ... } in its inline CSS block. Fixed by checking for the HTML element class attribute pattern 'class="delta-badge delta-down"' instead, which only appears in actual badge elements and not in CSS definitions.

Acceptance Criteria

  • rework_cycles SparklineData fixture uses direction="up" (lower-is-better, values improving)
  • test_rework_cycles_delta_badge_no_red_css_class checks element class attribute, not CSS block content
  • TestSparklineSvgRendering: all 10 tests pass
  • Full suite: 1912 passed, 4 skipped

Review Results

python-specialist (MINOR)

File: tests/test_report_html.py:4435
Pre-existing test test_delta_badge_down_indicator_present docstring is misleading after the fixture fix — the ▼ arrow now comes from value_direction="down" on rework_cycles, not direction="down". Docstring updated to accurately reflect what the test verifies.

rag-specialist (MINOR)

File: tests/test_report_html.py:4512
test_rework_cycles_lower_is_better_direction_is_up is a tautological test that validates fixture self-consistency rather than production build_sparkline_data() polarity logic. Noted as acceptable regression guard; a stronger follow-up test in test_sparkline.py exercising build_sparkline_data() with metric_polarity={"rework_cycles": False} would test the production code path.

Refs #305


Assisted-by: Claude Opus 4.6 (1M context) noreply@anthropic.com
Assigned-by: decko

decko added 2 commits May 26, 2026 16:43
…r-is-better metrics in _make_report_with_sparklines (#305)

The _make_report_with_sparklines helper in TestSparklineSvgRendering had
rework_cycles SparklineData with direction='down', but since rework_cycles
is a lower-is-better metric and values [1.5, 1.2, 0.9] are decreasing
(improvement), the semantic direction field must be 'up' (green/improving).

Two fixes:
1. Change direction='down' to direction='up' in the rework_cycles fixture so
   it correctly reflects the polarity-aware improvement semantics.
2. Fix the test_rework_cycles_delta_badge_no_red_css_class assertion to check
   for the HTML element class attribute pattern ('class="delta-badge delta-down"')
   rather than the bare string 'delta-down', which also appears in the CSS
   definition (.delta-badge.delta-down { ... }) and would always fail.
@decko decko added the ai-assisted Implemented with AI assistance label May 26, 2026
@decko decko merged commit 692e7fc into main May 26, 2026
4 checks passed
@decko decko deleted the soda/305 branch May 26, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Implemented with AI assistance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant