@@ -557,3 +557,159 @@ test('should keep query arguments when updating settings', async ({
557557 await wordpress . locator ( 'body' ) . evaluate ( ( body ) => body . baseURI )
558558 ) . toMatch ( '/wp-admin/' ) ;
559559} ) ;
560+
561+ test ( 'should edit a file in the code editor and see changes in the viewport' , async ( {
562+ website,
563+ wordpress,
564+ } ) => {
565+ await website . goto ( './' ) ;
566+
567+ // Open site manager
568+ await website . ensureSiteManagerIsOpen ( ) ;
569+
570+ // Navigate to File Browser tab
571+ await website . page . getByRole ( 'tab' , { name : 'File Browser' } ) . click ( ) ;
572+
573+ // Wait for file tree to load
574+ await website . page . locator ( '[data-path="/wordpress"]' ) . waitFor ( ) ;
575+
576+ // Expand /wordpress folder
577+ const wordpressFolder = website . page . locator (
578+ 'button[data-path="/wordpress"]'
579+ ) ;
580+ if ( ( await wordpressFolder . getAttribute ( 'data-expanded' ) ) !== 'true' ) {
581+ await wordpressFolder . click ( ) ;
582+ }
583+
584+ // Double-click index.php to open it in the editor
585+ await website . page
586+ . locator ( 'button[data-path="/wordpress/index.php"]' )
587+ . dblclick ( ) ;
588+
589+ // Wait for CodeMirror editor to load
590+ const editor = website . page . locator ( '[class*="file-browser"] .cm-editor' ) ;
591+ await editor . waitFor ( { timeout : 10000 } ) ;
592+
593+ // Click on the editor to focus it
594+ await website . page . waitForTimeout ( 50 ) ;
595+
596+ await editor . click ( ) ;
597+
598+ await website . page . waitForTimeout ( 250 ) ;
599+
600+ // Select all content in the editor (Cmd+A or Ctrl+A)
601+ await website . page . keyboard . press (
602+ process . platform === 'darwin' ? 'Meta+A' : 'Control+A'
603+ ) ;
604+
605+ await website . page . keyboard . press ( 'Backspace' ) ;
606+ await website . page . waitForTimeout ( 200 ) ;
607+
608+ // Type the new content with a delay between keystrokes
609+ await website . page . keyboard . type ( 'Edited file' , { delay : 50 } ) ;
610+
611+ // Wait a moment for the change to be processed
612+ await website . page . waitForTimeout ( 500 ) ;
613+
614+ // Save the file (Cmd+S or Ctrl+S)
615+ await website . page . keyboard . press (
616+ process . platform === 'darwin' ? 'Meta+S' : 'Control+S'
617+ ) ;
618+
619+ // Wait for save to complete (look for save indicator if there is one)
620+ await website . page . waitForTimeout ( 1000 ) ;
621+
622+ // Close the site manager to see the viewport
623+ await website . ensureSiteManagerIsClosed ( ) ;
624+
625+ // Reload just the WordPress iframe to see the changes
626+ const playgroundViewport = website . page . frameLocator (
627+ '#playground-viewport:visible,.playground-viewport:visible'
628+ ) ;
629+ await playgroundViewport
630+ . locator ( '#wp' )
631+ . evaluate ( ( iframe : HTMLIFrameElement ) => {
632+ iframe . contentWindow ?. location . reload ( ) ;
633+ } ) ;
634+
635+ // Verify the page shows "Edited file"
636+ await expect ( wordpress . locator ( 'body' ) ) . toContainText ( 'Edited file' , {
637+ timeout : 10000 ,
638+ } ) ;
639+ } ) ;
640+
641+ test ( 'should edit a blueprint in the blueprint editor and recreate the playground' , async ( {
642+ website,
643+ wordpress,
644+ } ) => {
645+ await website . goto ( './' ) ;
646+
647+ // Open site manager
648+ await website . ensureSiteManagerIsOpen ( ) ;
649+
650+ // Navigate to Blueprint tab
651+ await website . page . getByRole ( 'tab' , { name : 'Blueprint' } ) . click ( ) ;
652+
653+ // Wait for CodeMirror editor to load
654+ const editor = website . page . locator (
655+ '[class*="blueprint-editor"] .cm-editor'
656+ ) ;
657+ await editor . waitFor ( { timeout : 10000 } ) ;
658+
659+ await editor . click ( ) ;
660+
661+ // Delete all content in the editor (Cmd+A or Ctrl+A)
662+ await website . page . keyboard . press (
663+ process . platform === 'darwin' ? 'Meta+A' : 'Control+A'
664+ ) ;
665+
666+ await website . page . keyboard . press ( 'Backspace' ) ;
667+ await website . page . waitForTimeout ( 200 ) ;
668+
669+ // Create a simple blueprint that writes "Blueprint test" to index.php
670+ const blueprint = JSON . stringify (
671+ {
672+ landingPage : '/index.php' ,
673+ steps : [
674+ {
675+ step : 'writeFile' ,
676+ path : '/wordpress/index.php' ,
677+ data : 'Blueprint test' ,
678+ } ,
679+ ] ,
680+ } ,
681+ null ,
682+ 2
683+ ) ;
684+
685+ // Type the new blueprint with a delay between keystrokes
686+ await website . page . keyboard . type ( blueprint , { delay : 50 } ) ;
687+
688+ // Remove the autoinserted brackets until the end of the Blueprint
689+ await website . page . keyboard . down ( 'Shift' ) ;
690+ for ( let i = 0 ; i < 4 ; i ++ ) {
691+ await website . page . keyboard . press ( 'ArrowDown' ) ;
692+ }
693+
694+ // Delete the selected lines
695+ await website . page . keyboard . press ( 'Backspace' ) ;
696+
697+ // Wait a moment for the change to be processed
698+ await website . page . waitForTimeout ( 500 ) ;
699+
700+ // Click the "Recreate Playground from this Blueprint" button
701+ await website . page
702+ . getByRole ( 'button' , {
703+ name : 'Recreate Playground from this Blueprint' ,
704+ } )
705+ . click ( ) ;
706+
707+ await website . page . waitForTimeout ( 1500 ) ;
708+ // Wait for the playground to recreate
709+ await website . waitForNestedIframes ( ) ;
710+
711+ // Verify the page shows "Blueprint test"
712+ await expect ( wordpress . locator ( 'body' ) ) . toContainText ( 'Blueprint test' , {
713+ timeout : 10000 ,
714+ } ) ;
715+ } ) ;
0 commit comments