test(newsletters): audit Batch B core blocks (separator, button, social-links)#360
Draft
chickenn00dle wants to merge 1 commit into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds characterization coverage for the WooCommerce email-editor renderer to document and lock in that core/separator, core/button/core/buttons, and core/social-links already render in an email-safe way (so Newspack does not ship overrides for these blocks).
Changes:
- Introduces a new PHPUnit test suite that renders the audited core blocks through
Renderer_Controller::render_wc(). - Asserts key email-safety characteristics (inline separator/button colors, table-safe button rendering, social-links PNG icons + optional labels).
Comment on lines
+88
to
+92
| $this->assertStringContainsString( 'href="https://example.com"', $html, 'Expected the button link href to survive.' ); | ||
| $this->assertStringContainsString( 'target="_blank"', $html, 'Expected the button link to open in a new tab.' ); | ||
| $this->assertStringContainsString( '>Click me</a>', $html, 'Expected the button label to render.' ); | ||
| $this->assertStringContainsString( 'class=" wp-block-button"', $html, 'Expected the button to render inside a wp-block-button table cell.' ); | ||
| } |
Comment on lines
+101
to
+105
| $content = '<!-- wp:buttons --><div class="wp-block-buttons"><!-- wp:button {"backgroundColor":"vivid-red","textColor":"white"} --><div class="wp-block-button"><a class="wp-block-button__link has-white-color has-vivid-red-background-color has-text-color has-background wp-element-button" href="https://example.com">Buy</a></div><!-- /wp:button --></div><!-- /wp:buttons -->'; | ||
| $html = $this->render_newsletter( $content ); | ||
| $this->assertStringContainsString( 'background-color: #cf2e2e', $html, 'Expected the button background color to be inlined.' ); | ||
| $this->assertStringContainsString( 'color: #ffffff', $html, 'Expected the button text color to be inlined.' ); | ||
| } |
0f3ca4a to
0453e9f
Compare
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0453e9f to
0f902e7
Compare
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
Batch B audit (NEWS-1904) for the WC email renderer found
core/separator,core/button/core/buttons, andcore/social-linksalready render email-correctly — no overrides needed.These are core blocks the WooCommerce email-editor package already renders. The job was to verify each against vanilla WordPress output (the reference model — not legacy MJML) and add an override only where the package output genuinely diverges in a way that matters for email. For all three, it doesn't.
What changed, per block:
core/separator— no override needed. The package passes the<hr>through with its block classes, and preset colors are inlined onto the element (style="… background-color:#cf2e2e …") so they survive in email clients. This matches vanilla WP. (Note:separatorisn't in the package'sALLOWED_BLOCK_TYPES, so it renders via the generic fallback path — which is correct here.)core/button/core/buttons— no override needed. The button renders as an email-safe linked table cell: background color and text color inlined,target="_blank"set, href and label preserved, custom-width class kept. Audited the default, preset-color, and width variants.core/social-links— no override needed (and the package is better than vanilla for email). Vanilla WP emits inline<svg>icons, which Gmail and Outlook strip — leaving empty links. The package instead emits hosted PNG<img>icons (/icons/<service>/<service>-white.png, HTTP 200, 32 services incl. mastodon/x), with the service brand color as the pill background, real hrefs, alt text, and labels whenshowLabelsis on. That's the email-correct representation.Because there are zero overrides, this PR adds no production code — only a characterization test that renders all three blocks through
Renderer_Controller::render_wc()and asserts the audited email-safe output, so a future package regression that breaks one of these blocks (and would justify an override) fails loudly.Regression note: there is no behavior change. No block override is registered, so nothing attaches under the WC email engine, and the legacy MJML / web rendering paths are completely untouched.
Relates to NEWS-1904.
How to test
./vendor/bin/phpunit --filter Test_Batch_B_Core_BlocksExpected:
OK (6 tests, 14 assertions)../vendor/bin/phpunit --filter Test_Block_Renderer_OverridesExpected:
OK (14 tests, 24 assertions)../vendor/bin/phpcs --standard=/newspack-monorepo/phpcs.xml tests/email-renderers/test-batch-b-core-blocks.phpExpected: clean (no violations).