Repository navigation
Extract the template preview compile request for reuse - #534
Merged
Merged
Conversation
…view a template TemplatePreviewDrawer builds its templates.compile request through buildTemplatePreviewRequest, and compileTemplatePreview compiles it for the broadcast, automation and transactional screens of the console redesign. Also adds the plan of the Broadcasts screens.
pierre-b
marked this pull request as ready for review
November 12, 2026 15:29
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #534 +/- ##
=======================================
Coverage 88.97% 88.97%
=======================================
Files 377 377
Lines 73836 73836
=======================================
Hits 65692 65692
Misses 5435 5435
Partials 2709 2709
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
First PR of the Broadcasts screens of the console redesign (spec 5). Console only.
What changes
console/src/components/templates/compileTemplatePreview.ts:buildTemplatePreviewRequest({ workspace, email, testData })returns{ request }(thetemplates.compilerequest: MJML source in code mode, the visual tree otherwise, subject, preview text, custom text when not blank, test data, tracking settings) or{ error: 'missing_content' | 'invalid_tree' }. A tree string that parses to something other than an object ("null","42") isinvalid_treeand is not sent.compileTemplatePreview(input)compiles it, and rejects withTemplatePreviewError(code) when no request can be built.TemplatePreviewDrawerbuilds its request through it. Missing content still shows "Missing workspace ID or template data."; an invalid tree now always shows "Invalid template structure data." (a tree that parsed tonullused to show "Template structure data is missing or invalid.").plans/console-redesign-screens-5-broadcasts-plan.md, reviewed before any code; its review corrections are in the plan.The Broadcasts composer and detail page, the automation email step and the transactional notification page will use it for their template previews (later PRs).
Tests
compileTemplatePreview.test.ts: code mode, visual mode with an object tree and a JSON string tree, unparsable tree, tree strings that parse to no object, missing content in each mode and only the editor mode's content counting, custom text only when not blank, test data, tracking settings, compile called with the request, rejection without a server call.TemplatePreviewDrawer.test.tsx: the two error messages, without a compile call; existing cases unchanged.Known, not handled
TemplatePreviewErrorCodesays "a tree that is not JSON";invalid_treealso covers JSON that is not an object.