Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>&#x3C;!--<b data-testid=\\"raw\\">hello</b>--><!--[endif]----></body></html>"`;
29 changes: 29 additions & 0 deletions packages/jsx-email/test/conditional-raw-minimal.test.tsx
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 +20 to +27
Copy link
Copy Markdown
Contributor Author

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.snap do not match the test titles in this file. The snapshot file omits the parenthetical suffixes, while the it(...) 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:

-  it('renders a minimal MSO block with inlined Raw content (jsxToString)', async () => {
+  it('renders a minimal MSO block with inlined Raw content', async () => {
@@
-  it('renders final HTML via the render pipeline (with plugin stubs)', async () => {
+  it('renders final HTML via the render pipeline', async () => {

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.

Comment on lines +25 to +27
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

Suggestion

Replace 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.

});
});