Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix two bugs in the
_make_report_with_sparklineshelper method insideTestSparklineSvgRendering:Bug 1 — Inverted direction semantics (line 4409)
The
rework_cyclessparkline was constructed withdirection="down", butrework_cyclesis a lower-is-better metric. Values[1.5, 1.2, 0.9]are decreasing, which is an improvement — so the polarity-awaredirectionfield must be"up"(green/improving). Thevalue_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_classasserted"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_cyclesSparklineDatafixture usesdirection="up"(lower-is-better, values improving)test_rework_cycles_delta_badge_no_red_css_classchecks element class attribute, not CSS block contentTestSparklineSvgRendering: all 10 tests passReview Results
python-specialist (MINOR)
File:
tests/test_report_html.py:4435Pre-existing test
test_delta_badge_down_indicator_presentdocstring is misleading after the fixture fix — the ▼ arrow now comes fromvalue_direction="down"on rework_cycles, notdirection="down". Docstring updated to accurately reflect what the test verifies.rag-specialist (MINOR)
File:
tests/test_report_html.py:4512test_rework_cycles_lower_is_better_direction_is_upis a tautological test that validates fixture self-consistency rather than productionbuild_sparkline_data()polarity logic. Noted as acceptable regression guard; a stronger follow-up test intest_sparkline.pyexercisingbuild_sparkline_data()withmetric_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