Skip to content

RS-21803: Sig Leader Circles test - #66

Open
SurreyHughesDisplayr wants to merge 4 commits into
masterfrom
RS-21803-sigleadercircles
Open

RS-21803: Sig Leader Circles test#66
SurreyHughesDisplayr wants to merge 4 commits into
masterfrom
RS-21803-sigleadercircles

Conversation

@SurreyHughesDisplayr

Copy link
Copy Markdown

Summary

Adds unit test coverage for the sig.leader.circles branch of CreateCustomTable (R/createcustomtable.R), which had no tests anywhere in tests/testthat/.

  • Pins the three base circle classes (.circle2 leader, .circle1 tie, .circle0) and all nine filled variants (circle21 circle11 circle01 circle20 circle10 circle00 circle2-1 circle1-1 circle0-1) as exact full CSS declarations, so the up/nothing/down fill mapping and the border cycle are both asserted per variant.
  • Asserts circle.size drives the emitted geometry (line-height / border-radius / height / width) via one anchored declaration.
  • Asserts every data cell is wrapped in a <div class="circleN"> (count pinned to prod(dim(x))), and that cell text — including escaped entities — survives the wrapping.
  • Asserts no circle CSS and no circle divs are emitted when sig.leader.circles is NULL.

Pinned production bug

One test deliberately pins current buggy behaviour. The normalisation line in the sig.leader.circles branch is

sig.leader.circles[!which(sig.leader.circles == 1 | sig.leader.circles == 2)] <- 0

which() returns positive indices, so !which(...) is always all-FALSE and the assignment is a complete no-op — out-of-range codes are never coerced to 0, and <div class="circle5"> / <div class="circle-3"> are emitted instead of circle0. The test asserts the actual behaviour, not the documented intent, so it will fail loudly when the bug is fixed. No production code is changed in this PR. No defect ticket is filed for it yet.

Jira: https://numbers.atlassian.net/browse/RS-21803

Test plan

Rscript -e "devtools::load_all('.'); testthat::test_file('tests/testthat/test-createcustomtable.R')"

46 passing, 0 failures (11 test_that blocks; 8 added here, plus hardening of the helper used by the pre-existing ones).

🤖 Generated with Claude Code

SurreyHughesDisplayr and others added 4 commits August 20, 2026 17:19
Cover the sig.leader.circles branch of CreateCustomTable: no-op default,
base and filled circle CSS classes, per-cell circle div wrapping, content
preservation, circle.size-driven geometry, and the current (buggy)
out-of-range normalisation behaviour.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ertions

Address review findings on the sig.leader.circles tests: assert the full
9-way circle.colors/circle.border mapping instead of a spot-check, anchor
the circle.size geometry assertion to the exact circle CSS declaration
(fixed = TRUE) instead of loose token matches, make the "text survives
wrapping" test genuinely exercise text preservation with entity content,
switch CSS-only fixtures to a value-independent matrix with an explanatory
comment, add info= to loop assertions, rename helpers to camelCase to
match package style, and reference RS-21803 on the pinned-buggy-behaviour
test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Assert the divs half of the "no circle CSS or divs" title, pin full
base circle-class declarations with occurrence counts, express the
cell-count invariant via prod(dim(x22)), assert an in-range code still
works in the out-of-range test, correct the ticket attribution for the
unfiled negation-bug comment, and relocate helper definitions to the
top of the file per repo convention.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gregexpr returns -1L with attributes on no-match, so identical(m, -1L)
was always FALSE and the helper returned 1 for absent patterns,
making every "exactly once" assertion in this file vacuous. Compare
m[1] instead. Also corrected a copy-pasted comment on the nine-variant
loop that incorrectly claimed the trailing " {" is load-bearing there.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant