-
Notifications
You must be signed in to change notification settings - Fork 54
test(jsx-email): add minimal snapshot for <Raw> inside <Conditional> #321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
023c045
4f1c709
588b965
a9fc998
36de5c0
be7246e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
|
||
| exports[`snapshot: minimal <Raw> inside <Conditional mso> > renders a minimal MSO block with inlined Raw content (jsxToString) 1`] = `"<jsx-email-cond><!--[if mso]><jsx-email-raw><!--<b data-testid=\\"raw\\">hello</b>--></jsx-email-raw><![endif]--></jsx-email-cond>"`; | ||
|
|
||
| exports[`snapshot: minimal <Raw> inside <Conditional mso> > renders final HTML via the render pipeline 1`] = `"<!DOCTYPE html PUBLIC \\"-//W3C//DTD XHTML 1.0 Transitional//EN\\" \\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\\"><html><body><!--[if mso]><jsx-email-raw><!--<b data-testid=\\"raw\\">hello</b>--><!--[endif]----></body></html>"`; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { jsxToString } from '../src/renderer/jsx-to-string.js'; | ||
| import { render } from '../src/renderer/render.js'; | ||
| import { Conditional } from '../src/components/conditional.js'; | ||
| import { Raw } from '../src/components/raw.js'; | ||
|
|
||
| const minimalFragment = ( | ||
| <Conditional mso> | ||
| <Raw content={'<b data-testid="raw">hello</b>'} /> | ||
| </Conditional> | ||
| ); | ||
|
|
||
| /** | ||
| * Minimal snapshot fixture for `<Raw>` nested inside `<Conditional>`. | ||
| * | ||
| * This test intentionally asserts a snapshot of whatever the current | ||
| * render pipeline produces for this structure so we can iterate on it | ||
| * in follow‑ups. There are no behavioral assertions beyond the snapshot. | ||
| */ | ||
| describe('snapshot: minimal <Raw> inside <Conditional mso>', () => { | ||
| it('renders a minimal MSO block with inlined Raw content (jsxToString)', async () => { | ||
| const html = await jsxToString(minimalFragment); | ||
| expect(html).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it('renders final HTML via the render pipeline', async () => { | ||
| const html = await render(minimalFragment); | ||
| expect(html).toMatchSnapshot(); | ||
|
Comment on lines
+25
to
+27
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The render-based snapshot bakes in internal implementation details (e.g., custom tag names and how conditional comments are serialized). This increases maintenance friction and risks codifying a potentially incorrect output shape. To reduce brittleness and still guard behavior, assert high-level invariants (presence of the MSO conditional and the Raw content) instead of snapshotting the entire string. SuggestionReplace the broad snapshot with focused assertions that verify the key behavior: - it('renders final HTML via the render pipeline', async () => {
- const html = await render(minimalFragment);
- expect(html).toMatchSnapshot();
- });
+ it('renders final HTML via the render pipeline', async () => {
+ const html = await render(minimalFragment);
+ expect(html).toContain('<!--[if mso]');
+ expect(html).toContain('<b data-testid="raw">hello</b>');
+ // Optional invariant to add once the pipeline is corrected:
+ // expect(html).not.toContain('<jsx-email-raw');
+ });I can add a commit with this refinement—reply with "@CharlieHelps yes please" if you want me to proceed. |
||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Snapshot keys in
packages/jsx-email/test/.snapshots/conditional-raw-minimal.test.tsx.snapdo not match the test titles in this file. The snapshot file omits the parenthetical suffixes, while theit(...)names include them. This will cause snapshot lookups to miss and the test to fail. Align the test titles with the committed snapshot keys or update the snapshots to match the new titles.Suggestion
To immediately align with the committed snapshot keys, remove the parenthetical suffixes from the test names:
Alternatively, re-run the snapshots to capture the updated names:
vitest run --config shared/vitest.config.ts packages/jsx-email/test/conditional-raw-minimal.test.tsx -u. Reply with "@CharlieHelps yes please" if you'd like me to add a commit with this change.