Repository navigation
Tests: Don't rely on KSES rewriting comment closers - #788
Conversation
`test_content_rewritten_on_save_is_refused` assumed KSES normalizes a block comment closer with extra dashes (`--->`) to `-->`. WordPress nightly no longer does, so the content is stored unchanged, nothing is refused, and four cases fail. Split those cases out into two tests: - Apply the rewrite with a `content_save_pre` filter, so the `reject_unstable_blocks` check is still tested whatever version runs the suite. - With the real save filters, assert the content is either refused or stored with the blocks that were checked, which is the property the check protects. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe pull request updates pattern content validation tests. It adds save-rewrite cases, tests for block markup affected by comment-closer normalization, and shared helpers for submitting content through REST. ChangesPattern content validation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~12 minutes Change: Other Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change only updates tests so they no longer depend on KSES rewriting block-comment closers. It has no production behavior impact and is ready to merge. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PHP unit tests are failing on every branch (for example #787) because WordPress nightly changed how KSES treats block comment closers with extra dashes.
test_content_rewritten_on_save_is_refusedassumed KSES rewrites<!-- wp:wporg/modal /--->to<!-- wp:wporg/modal /-->, which turns text the parser ignored into a block.reject_unstable_blocksexists to refuse content like that. On nightly (7.2-alpha-64238) KSES leaves the comment as it is:So nothing is rewritten, the request is accepted, and the four "extra dash" cases fail. This isn't a security regression: what's stored is what was checked. The guard is still needed on WordPress versions that do rewrite these comments, so it stays.
Changes
The four cases move out of
test_content_rewritten_on_save_is_refusedinto two new tests that share a data provider:test_unstable_block_markup_is_refusedapplies the old rewrite with acontent_save_prefilter, so the check itself is still tested whatever version runs the suite. With the check disabled, all four cases fail.test_block_markup_is_refused_or_stored_unchangeduses the real save filters and asserts the content is either refused or stored with the same blocks that were checked.The shortcode and control-character cases are unchanged. The member-pattern setup moves into small helpers that the tests share.
Testing
npm run test:phppasses against nightly: 317 tests.🤖 Generated with Claude Code
Summary by CodeRabbit