Skip to content

test(newsletters): audit Batch B core blocks (separator, button, social-links)#360

Draft
chickenn00dle wants to merge 1 commit into
epic/editor-refactorfrom
editor-refactor/blocks-separator-button-social
Draft

test(newsletters): audit Batch B core blocks (separator, button, social-links)#360
chickenn00dle wants to merge 1 commit into
epic/editor-refactorfrom
editor-refactor/blocks-separator-button-social

Conversation

@chickenn00dle

Copy link
Copy Markdown
Contributor

Summary

Batch B audit (NEWS-1904) for the WC email renderer found core/separator, core/button/core/buttons, and core/social-links already 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: separator isn't in the package's ALLOWED_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 when showLabels is 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

  1. From the plugin dir, run the new test:
    ./vendor/bin/phpunit --filter Test_Batch_B_Core_Blocks
    Expected: OK (6 tests, 14 assertions).
  2. Confirm no regression in the override harness:
    ./vendor/bin/phpunit --filter Test_Block_Renderer_Overrides
    Expected: OK (14 tests, 24 assertions).
  3. PHPCS on the changed file:
    ./vendor/bin/phpcs --standard=/newspack-monorepo/phpcs.xml tests/email-renderers/test-batch-b-core-blocks.php
    Expected: clean (no violations).
  4. (Optional, visual) In a newsletter with the WC renderer flag on, add a separator, a button, and a social-links block, refresh the editor preview, and confirm the rule shows, the button is a colored linked block, and social icons render as images (not blank).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.' );
}
@chickenn00dle chickenn00dle force-pushed the editor-refactor/blocks-separator-button-social branch from 0f3ca4a to 0453e9f Compare June 19, 2026 17:25
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chickenn00dle chickenn00dle force-pushed the editor-refactor/blocks-separator-button-social branch from 0453e9f to 0f902e7 Compare June 23, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants