Skip to content

RS-21803: Banded Rows test - #69

Open
SurreyHughesDisplayr wants to merge 3 commits into
RS-21803-rowspansfrom
RS-21803-bandedrows
Open

RS-21803: Banded Rows test#69
SurreyHughesDisplayr wants to merge 3 commits into
RS-21803-rowspansfrom
RS-21803-bandedrows

Conversation

@SurreyHughesDisplayr

Copy link
Copy Markdown

Summary

Adds unit test coverage for the banded.rows and banded.cols arguments of CreateCustomTable (R/createcustomtable.R).

  • Pins each banding rule as one contiguous exact string — both the odd and even clauses and both fill values — so inserting anything between the clauses, or swapping banded.odd.fill with banded.even.fill, fails the test.
  • Asserts no nth-child rule is emitted at all when banding is off.
  • Pins the column rule verbatim, including the td:nth-child(2n+3) / td:nth-child(even) pair as coded.
  • Asserts a cell-level fill suppresses the banded background, as a single-variable contrast against the unbanded case.
  • Asserts the banding rule is emitted once regardless of row count.
  • Extracts the generated container id and asserts the odd clause is scoped to it, guarded by expect_length(containerSel, 1) so the assertion cannot pass on an empty match.

Pinned production defect

The second clause of each banding rule is emitted without the container prefix — ;} tr:nth-child(even) for rows and ;} td:nth-child(even) for columns — so it is not scoped to this table and leaks to every table on the page. Both halves are pinned as current behaviour and will fail when the scoping is fixed. Genuine defect, no ticket filed.

Plan corrections

Two of the plan's expectations did not survive checking and were corrected rather than encoded:

  • The plan's example CSS strings have no space before ;. cata() writes via cat(..., sep = " "), so real output is background-color: rgb(250,250,250) ; — the plan's string never occurs. Tests pin the real text.
  • The plan records the 2n+3 / even column selectors as overlapping and asks for that to be logged as a defect. They are provably disjoint: 2n+3 = {3, 5, 7, …} and even = {2, 4, …}. With row headers shown the header cell occupies nth-child(1), so data columns land on 2, 3, 4 and alternate correctly. Not a defect. (One genuine gap the plan did not raise: with show.row.headers = FALSE, column 1 matches neither selector and is left unbanded. Noted in a comment, not asserted.)

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

Stacked PR

Based on RS-21803-rowspans (#68), not master — these plans all add tests to tests/testthat/test-createcustomtable.R and share its helpers. Merge order: #66, #67, #68, then this. The diff against that base is this plan's work only.

Test plan

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

137 passing, 0 failures, 0 warnings.

🤖 Generated with Claude Code

SurreyHughesDisplayr and others added 3 commits August 21, 2026 10:19
Adds unit tests for CreateCustomTable's banded.rows/banded.cols
behaviour: no CSS emitted by default, the odd/even row-banding rule
(pinning the confirmed unscoped tr:nth-child(even) clause), custom
fill colours, per-cell background suppression shared by both flags,
the verbatim td:nth-child(2n+3)/even column rule, both flags
together, and row-count independence of the emitted rule count.

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

Pins the whole banded.cols verbatim CSS rule (both the 2n+3 and even
clauses with their fill values) instead of only half of it, and adds a
scoping-leak check mirroring the existing banded.rows one, confirming
the unscoped `td:nth-child(even)` clause is a real, unticketed defect.
Removes the incorrect "defect"/"corrected odd/even split" framing for
the 2n+3/even selector pair, which is disjoint and correct as coded -
that was a plan-authoring mistake, not a production bug. Guards the
container-selector regex extraction with expect_length() so a failed
match can't pass vacuously. Pins the paired custom banded.odd.fill /
banded.even.fill values so swapping them would fail. Tightens two
cell-fill assertions to include the trailing " ;" for anchoring. Moves
the banded.rows/banded.cols section to after the last row.spans test
it had been accidentally inserted into the middle of.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Merge the odd/even grepl pairs for banded.rows (default and custom
fill cases) into single contiguous-string assertions, mirroring the
existing banded.cols test. As two independent greps, inserting
content between the odd and even clauses in production would not
have failed these assertions. Also drop "deliberately" from a
comment asserting unestablished author intent.

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