RS-21803: checkImageTag style attribute test - #72
Open
SurreyHughesDisplayr wants to merge 2 commits into
Open
Conversation
Adds scenarios for style and width attributes preceding src, attribute order independence, double-quoted and unquoted src values, a missing src attribute, surrounding text preservation, and a decoy substring "src=" match that is not silently treated as a valid link. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace unfailable identical() check and network-dependent warning match in the src= decoy block with pinned real values (result "" and warning text including the captured "x"); pin echoed input in the missing-src syntax-error message to distinguish it from the tag-regex-miss branch; drop redundant duplicate expect_warning call; hoist repeated txt.style literal to a file-level constant and remove dangling duplicate txt.dq assignment; rename reused txt.dq in the double-quote block; document network dependency of success-path blocks. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Adds unit test coverage for
checkImageTag's handling of thestyleattribute and its surrounding link-cleaning paths (R/checkimagetag.R) — 7 test blocks in the existingtest-checkimagetag.R.styleattribute before and aftersrc, exercising the two different quote/bracket cleaning paths rather than the same one twice.srcvalues, andsrcfollowed by trailing text.srcbranch, pinning the echoed input in the warning so it is distinguishable from the tag-regex-miss branch that emits a byte-identicalsyntax errorprefix.text, not the matchedimgtag.expect_equalrather than several substring greps.Also closes a pre-existing gap: the file's
txt.dqcase was single-quoted and identical totxt.sq, so double quotes were never actually tested. Thestyleliteral is now a single hoisted constant, replacing a dangling unused assignment.Note on the
src=regexThe last block pins current behaviour for a decoy input where an earlier attribute value contains
src=.regexpr("src=(\S+)", ...)is unanchored, soalt='mysrc=x'is matched in preference to the realsrc, and a valid image is silently removed with a user-visibleinvalid link which has been removed: xwarning. The test pins the warning text — deliberately, so that the assertion fails for the decoy and not merely because a network fetch failed, since the same warning is emitted on any failed GET.This looks like a genuine low-severity defect rather than intended behaviour: nothing in the function or its callers suggests the loose match is deliberate, and a boundary requirement such as
(?:^|\s)src=would be safe because the enclosing<img [^>]+>match guarantees whitespace before every attribute. Not fixed here; worth a ticket. Separately, the trailing-whitespacesub()in the same function is unreachable, since(\S+)cannot capture whitespace — inert rather than wrong.Network dependency
The success-path blocks perform a live HTTP GET of a real wiki image URL — the pre-existing convention in this file, not introduced here. They fail offline. Documented in a comment at the top of the file so the failure mode is obvious to the next reader.
Jira: https://numbers.atlassian.net/browse/RS-21803
Stacked PR
Based on
RS-21803-colwidthsandcustomcss(#71). Merge order: #66, #67, #68, #69, #70, #71, then this. This is the last of the seven RS-21803 plans; it is the only one touchingcheckimagetag.Rrather thancreatecustomtable.R, so it shares no test file with the others.Test plan
24 passing, 0 failures, 0 warnings (requires network access).
🤖 Generated with Claude Code