@@ -577,7 +577,7 @@ test('shows App-only error when auto render is disabled and App is missing', asy
577577 )
578578} )
579579
580- test ( 'auto render implicitly wraps source with App in dom and react modes' , async ( {
580+ test ( 'auto render shows App-only error in dom and react modes when App is missing ' , async ( {
581581 page,
582582} ) => {
583583 await waitForInitialRender ( page )
@@ -589,9 +589,9 @@ test('auto render implicitly wraps source with App in dom and react modes', asyn
589589 'const Button = () => <button type="button">implicit app dom</button>' ,
590590 )
591591
592- await expect ( page . getByRole ( 'status' , { name : 'App status' } ) ) . toHaveText ( 'Rendered ' )
593- await expect ( getPreviewFrame ( page ) . getByRole ( 'button ') ) . toContainText (
594- 'implicit app dom ' ,
592+ await expect ( page . getByRole ( 'status' , { name : 'App status' } ) ) . toHaveText ( 'Error ' )
593+ await expect ( page . locator ( '#preview-host pre ') ) . toContainText (
594+ 'Expected a function or const named App. ' ,
595595 )
596596
597597 await page . getByRole ( 'combobox' , { name : 'Render mode' } ) . selectOption ( 'react' )
@@ -604,13 +604,13 @@ test('auto render implicitly wraps source with App in dom and react modes', asyn
604604 page . locator ( '.editor-panel[data-editor-kind="component"] .cm-content' ) . first ( ) ,
605605 ) . toContainText ( 'implicit app react' )
606606
607- await expect ( page . getByRole ( 'status' , { name : 'App status' } ) ) . toHaveText ( 'Rendered ' )
608- await expect ( getPreviewFrame ( page ) . getByRole ( 'button ') ) . toContainText (
609- 'implicit app react ' ,
607+ await expect ( page . getByRole ( 'status' , { name : 'App status' } ) ) . toHaveText ( 'Error ' )
608+ await expect ( page . locator ( '#preview-host pre ') ) . toContainText (
609+ 'Expected a function or const named App. ' ,
610610 )
611611} )
612612
613- test ( 'auto render implicit App includes multiple component declarations ' , async ( {
613+ test ( 'auto render renders successfully when explicit App is defined in dom and react modes ' , async ( {
614614 page,
615615} ) => {
616616 await waitForInitialRender ( page )
@@ -619,15 +619,25 @@ test('auto render implicit App includes multiple component declarations', async
619619
620620 await setComponentEditorSource (
621621 page ,
622- [
623- 'const OtherButton = () => <button type="button">bar</button>' ,
624- 'const Button = () => <button type="button">foo</button>' ,
625- ] . join ( '\n' ) ,
622+ 'const App = () => <button type="button">explicit app dom</button>' ,
626623 )
627624
628625 await expect ( page . getByRole ( 'status' , { name : 'App status' } ) ) . toHaveText ( 'Rendered' )
629- await expect ( getPreviewFrame ( page ) . getByRole ( 'button' ) ) . toHaveCount ( 2 )
630- await expect ( getPreviewFrame ( page ) . getByRole ( 'button' ) ) . toContainText ( [ 'bar' , 'foo' ] )
626+ await expect ( getPreviewFrame ( page ) . getByRole ( 'button' ) ) . toContainText (
627+ 'explicit app dom' ,
628+ )
629+
630+ await page . getByRole ( 'combobox' , { name : 'Render mode' } ) . selectOption ( 'react' )
631+ await expect ( page . getByRole ( 'combobox' , { name : 'Render mode' } ) ) . toHaveValue ( 'react' )
632+ await setComponentEditorSource (
633+ page ,
634+ 'const App = () => <button type="button">explicit app react</button>' ,
635+ )
636+
637+ await expect ( page . getByRole ( 'status' , { name : 'App status' } ) ) . toHaveText ( 'Rendered' )
638+ await expect ( getPreviewFrame ( page ) . getByRole ( 'button' ) ) . toContainText (
639+ 'explicit app react' ,
640+ )
631641} )
632642
633643test ( 'auto render does not treat lowercase helpers as implicit components' , async ( {
@@ -651,7 +661,7 @@ test('auto render does not treat lowercase helpers as implicit components', asyn
651661 )
652662} )
653663
654- test ( 'auto render wraps standalone JSX with trailing semicolon and comment ' , async ( {
664+ test ( 'auto render shows App-only error for standalone JSX expression ' , async ( {
655665 page,
656666} ) => {
657667 await waitForInitialRender ( page )
@@ -663,13 +673,13 @@ test('auto render wraps standalone JSX with trailing semicolon and comment', asy
663673 '(<button type="button">implicit app from jsx expression</button>) as any; // trailing' ,
664674 )
665675
666- await expect ( page . getByRole ( 'status' , { name : 'App status' } ) ) . toHaveText ( 'Rendered ' )
667- await expect ( getPreviewFrame ( page ) . getByRole ( 'button ') ) . toContainText (
668- 'implicit app from jsx expression ' ,
676+ await expect ( page . getByRole ( 'status' , { name : 'App status' } ) ) . toHaveText ( 'Error ' )
677+ await expect ( page . locator ( '#preview-host pre ') ) . toContainText (
678+ 'Expected a function or const named App. ' ,
669679 )
670680} )
671681
672- test ( 'auto render requires explicit App for declarations plus top-level JSX expression' , async ( {
682+ test ( 'auto render shows App-only error for declarations plus top-level JSX expression' , async ( {
673683 page,
674684} ) => {
675685 await waitForInitialRender ( page )
@@ -687,7 +697,7 @@ test('auto render requires explicit App for declarations plus top-level JSX expr
687697
688698 await expect ( page . getByRole ( 'status' , { name : 'App status' } ) ) . toHaveText ( 'Error' )
689699 await expect ( page . locator ( '#preview-host pre' ) ) . toContainText (
690- 'Top-level JSX with declarations or imports requires an explicit App component .' ,
700+ 'Expected a function or const named App.' ,
691701 )
692702} )
693703
0 commit comments