@@ -9,15 +9,29 @@ describe('buildSrcdoc', () => {
99 expect ( out ) . not . toContain ( 'Content-Security-Policy' ) ;
1010 } ) ;
1111
12- it ( 'passes legacy full-HTML documents through verbatim (pre-JSX-only snapshots) ' , ( ) => {
12+ it ( 'keeps legacy full-HTML documents as HTML but injects the preview overlay ' , ( ) => {
1313 // Snapshots written before the JSX-only switchover contain raw HTML
1414 // documents. Wrapping those as JSX makes Babel bark on the DOCTYPE /
15- // <html> tokens, so buildSrcdoc short-circuits when it detects a
16- // full HTML document and returns it unchanged .
15+ // <html> tokens, so buildSrcdoc injects the preview overlay without
16+ // routing them through the React+Babel wrapper .
1717 const html = '<html><body><p>x</p></body></html>' ;
18- expect ( buildSrcdoc ( html ) ) . toBe ( html ) ;
18+ const out = buildSrcdoc ( html ) ;
19+ expect ( out ) . toContain ( '<p>x</p>' ) ;
20+ expect ( out ) . toContain ( 'CODESIGN_OVERLAY_SCRIPT' ) ;
21+ expect ( out ) . toContain ( 'ELEMENT_SELECTED' ) ;
22+ expect ( out ) . not . toContain ( 'AGENT_BODY_BEGIN' ) ;
23+
1924 const doctyped = '<!DOCTYPE html><html><body><p>y</p></body></html>' ;
20- expect ( buildSrcdoc ( doctyped ) ) . toBe ( doctyped ) ;
25+ const doctypedOut = buildSrcdoc ( doctyped ) ;
26+ expect ( doctypedOut ) . toContain ( '<p>y</p>' ) ;
27+ expect ( doctypedOut ) . toContain ( 'CODESIGN_OVERLAY_SCRIPT' ) ;
28+ expect ( doctypedOut ) . not . toContain ( 'AGENT_BODY_BEGIN' ) ;
29+ } ) ;
30+
31+ it ( 'does not duplicate the overlay when a full-HTML document is rebuilt' , ( ) => {
32+ const once = buildSrcdoc ( '<html><body><p>x</p></body></html>' ) ;
33+ const twice = buildSrcdoc ( once ) ;
34+ expect ( twice ) . toBe ( once ) ;
2135 } ) ;
2236
2337 it ( 'wraps a fragment via the JSX path (no legacy HTML branch)' , ( ) => {
0 commit comments