Skip to content

RS-21803: Spacer Col test - #67

Open
SurreyHughesDisplayr wants to merge 2 commits into
RS-21803-sigleadercirclesfrom
RS-21803-spacercol
Open

RS-21803: Spacer Col test#67
SurreyHughesDisplayr wants to merge 2 commits into
RS-21803-sigleadercirclesfrom
RS-21803-spacercol

Conversation

@SurreyHughesDisplayr

Copy link
Copy Markdown

Summary

Adds unit test coverage for the spacer.col argument of CreateCustomTable (R/createcustomtable.R).

  • Pins the emitted class="spacer" header cell and the .spacer { … } CSS block, including the use.predefined.css variant.
  • Asserts the column-index shift caused by the row-header corner cell: with show.row.headers = TRUE the spacer lands one column later than with it off, verified by pinning the full <th …> strings on both sides.
  • Asserts the spacer cell keeps its own column label rather than being blanked.
  • Asserts the non-spacer header cells keep colheaderdefault1, pinned as exact strings.
  • Asserts col.header.fill genuinely displaces background: transparent, so the two CSS assertions discriminate rather than coincide.

Pinned production bug

One test deliberately pins current buggy behaviour. For an out-of-range spacer.col, col.header.styles[spacer.col] <- "spacer" silently extends the vector with NA_character_, and sprintf then emits literal class="NA" header cells. Because sprintf recycles, the header row also emits 6 <th> for a 3-column header, re-emitting labels X and Y. Both consequences are asserted, so the test fails loudly when the defect is fixed. No production code is changed in this PR, and no defect ticket is filed for it yet.

Note the test plan's own example for this scenario (spacer.col = 10 on the 4-cell header) does not reach the defect — it errors in sprintf with "arguments cannot be recycled to the same length". spacer.col = 6 on a 3-column header reaches the same NA-extension branch cleanly, and is what the test uses.

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

Stacked PR

Based on RS-21803-sigleadercircles (#66), not master — both plans add tests to tests/testthat/test-createcustomtable.R and share its tableHtml / normWs / countOccurrences helpers. Please merge #66 first. The diff shown against that base is this plan's work only.

Test plan

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

69 passing, 0 failures (22 test_that blocks; 11 added here).

🤖 Generated with Claude Code

SurreyHughesDisplayr and others added 2 commits August 20, 2026 17:53
…ol.header.fill CSS

Adds coverage for CreateCustomTable's spacer.col/col.header.fill column-header
behaviour, including the show.row.headers index shift, the show.col.headers
suppression path, and the confirmed out-of-range spacer.col defect where
sprintf emits a literal class="NA" header cell.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- comment the load-bearing narrowing from bare <th to <th class="
- pin exact colheaderdefault th strings instead of loose substring probes
- assert the 6-th-cell recycling consequence of the out-of-range spacer.col
- document why spacer.col = 3 (not 2) is required for the label-survival test

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