@@ -96,7 +96,8 @@ test('should switch between sites', async ({ website, browserName }) => {
9696 await website . ensureSiteManagerIsOpen ( ) ;
9797
9898 // Save the temporary site using the modal
99- await saveSiteViaModal ( website . page ) ;
99+ const firstSiteName = 'Switching Test Site' ;
100+ await saveSiteViaModal ( website . page , { customName : firstSiteName } ) ;
100101
101102 await expect ( website . page . getByLabel ( 'Playground title' ) ) . not . toContainText (
102103 'Unsaved Playground' ,
@@ -105,19 +106,46 @@ test('should switch between sites', async ({ website, browserName }) => {
105106 timeout : 90000 ,
106107 }
107108 ) ;
109+ await expect ( website . page . getByLabel ( 'Playground title' ) ) . toContainText (
110+ firstSiteName
111+ ) ;
108112
109113 // Open the saved playgrounds overlay to switch sites
110114 await website . openSavedPlaygroundsOverlay ( ) ;
111115
112- // Click on Temporary Playground in the overlay's site list
116+ // Start another saved Playground, then switch back to the first one.
117+ await website . page . getByRole ( 'button' , { name : 'New Playground' } ) . click ( ) ;
118+ await website . waitForNestedIframes ( ) ;
119+ await website . ensureSiteManagerIsOpen ( ) ;
120+
121+ await expect ( website . page . getByLabel ( 'Playground title' ) ) . not . toContainText (
122+ firstSiteName
123+ ) ;
124+ await expect (
125+ website . page . getByText ( 'Autosaved in this browser' )
126+ ) . toBeVisible ( { timeout : 120000 } ) ;
127+ await expect
128+ . poll ( ( ) =>
129+ website . page . evaluate ( ( ) => {
130+ const activeSite = ( window as any ) . playgroundSites
131+ . list ( )
132+ . find ( ( site : any ) => site . isActive ) ;
133+ return activeSite
134+ ? `${ activeSite . storage } :${ activeSite . persistence } `
135+ : null ;
136+ } )
137+ )
138+ . toBe ( 'opfs:autosave' ) ;
139+
140+ await website . openSavedPlaygroundsOverlay ( ) ;
113141 await website . page
114142 . locator ( '[class*="siteRowContent"]' )
115- . filter ( { hasText : 'Unsaved Playground' } )
143+ . filter ( { hasText : firstSiteName } )
116144 . click ( ) ;
145+ await website . ensureSiteManagerIsOpen ( ) ;
117146
118- // The overlay closes and site manager opens with the selected site
119147 await expect ( website . page . getByLabel ( 'Playground title' ) ) . toContainText (
120- 'Unsaved Playground'
148+ firstSiteName
121149 ) ;
122150} ) ;
123151
@@ -169,11 +197,9 @@ test('should preserve PHP constants when saving a temporary site to OPFS', async
169197 // Open the saved playgrounds overlay to switch sites
170198 await website . openSavedPlaygroundsOverlay ( ) ;
171199
172- // Switch to Temporary Playground
173- await website . page
174- . locator ( '[class*="siteRowContent"]' )
175- . filter ( { hasText : 'Unsaved Playground' } )
176- . click ( ) ;
200+ // Create another Playground, then switch back.
201+ await website . page . getByRole ( 'button' , { name : 'New Playground' } ) . click ( ) ;
202+ await website . waitForNestedIframes ( ) ;
177203
178204 // Open the overlay again to switch back to the stored site
179205 await website . openSavedPlaygroundsOverlay ( ) ;
@@ -471,7 +497,7 @@ test('should display OPFS storage option as selected by default', async ({
471497 await dialog . getByRole ( 'button' , { name : 'Cancel' } ) . click ( ) ;
472498} ) ;
473499
474- test ( 'should import ZIP into temporary site when a saved site exists' , async ( {
500+ test ( 'should import ZIP into a new saved site when a saved site exists' , async ( {
475501 website,
476502 wordpress,
477503 browserName,
@@ -536,12 +562,14 @@ test('should import ZIP into temporary site when a saved site exists', async ({
536562 buffer : zipBuffer ,
537563 } ) ;
538564
539- // The import should switch us to a temporary playground.
540- // Wait for the site title to show "Temporary Playground"
541- await expect ( website . page . getByLabel ( 'Playground title' ) ) . toContainText (
542- 'Unsaved Playground' ,
565+ // The import should switch us to a new saved Playground by default.
566+ await expect ( website . page . getByLabel ( 'Playground title' ) ) . not . toContainText (
567+ savedSiteName ,
543568 { timeout : 30000 }
544569 ) ;
570+ await expect ( website . page . getByLabel ( 'Playground title' ) ) . not . toContainText (
571+ 'Unsaved Playground'
572+ ) ;
545573
546574 // Now verify the saved site still has the original content.
547575 // Open the saved playgrounds overlay and switch to the saved site
@@ -551,16 +579,17 @@ test('should import ZIP into temporary site when a saved site exists', async ({
551579 . locator ( '[class*="siteRowContent"]' )
552580 . filter ( { hasText : savedSiteName } )
553581 . click ( ) ;
582+ await website . ensureSiteManagerIsOpen ( ) ;
554583
555584 // Wait for the saved site to load - this verifies the saved site wasn't overwritten
556- // by the ZIP import (which went to a temporary site instead)
585+ // by the ZIP import (which went to a new saved site instead)
557586 await expect ( website . page . getByLabel ( 'Playground title' ) ) . toContainText (
558587 savedSiteName ,
559588 { timeout : 30000 }
560589 ) ;
561590} ) ;
562591
563- test ( 'should create temporary site when importing ZIP while on a saved site with no existing temporary site' , async ( {
592+ test ( 'should create a saved site when importing ZIP while on a saved site with no existing temporary site' , async ( {
564593 website,
565594 wordpress,
566595 browserName,
@@ -618,14 +647,10 @@ test('should create temporary site when importing ZIP while on a saved site with
618647 // Open the saved playgrounds overlay
619648 await website . openSavedPlaygroundsOverlay ( ) ;
620649
621- // Verify there's no "Temporary Playground" in the list initially
622- // (the temporary site row should show but clicking it would create one)
623- const tempPlaygroundRow = website . page
624- . locator ( '[class*="siteRowContent"]' )
625- . filter ( { hasText : 'Unsaved Playground' } ) ;
626-
627- // The row exists but it's for creating a new temporary playground
628- await expect ( tempPlaygroundRow ) . toBeVisible ( ) ;
650+ const importZipButton = website . page . getByRole ( 'button' , {
651+ name : 'Import a .zip' ,
652+ } ) ;
653+ await expect ( importZipButton ) . toBeVisible ( ) ;
629654
630655 // Create a test ZIP
631656 const importedMarker = 'FRESH_IMPORT_MARKER_BBBBB' ;
@@ -648,12 +673,14 @@ test('should create temporary site when importing ZIP while on a saved site with
648673 buffer : zipBuffer ,
649674 } ) ;
650675
651- // The import should trigger creation of a new temporary site.
652- // Wait for the site title to show "Temporary Playground"
653- await expect ( website . page . getByLabel ( 'Playground title' ) ) . toContainText (
654- 'Unsaved Playground' ,
676+ // The import should trigger creation of a new saved site by default.
677+ await expect ( website . page . getByLabel ( 'Playground title' ) ) . not . toContainText (
678+ savedSiteName ,
655679 { timeout : 30000 }
656680 ) ;
681+ await expect ( website . page . getByLabel ( 'Playground title' ) ) . not . toContainText (
682+ 'Unsaved Playground'
683+ ) ;
657684
658685 // Verify the saved site is still intact by switching to it
659686 await website . openSavedPlaygroundsOverlay ( ) ;
@@ -662,9 +689,10 @@ test('should create temporary site when importing ZIP while on a saved site with
662689 . locator ( '[class*="siteRowContent"]' )
663690 . filter ( { hasText : savedSiteName } )
664691 . click ( ) ;
692+ await website . ensureSiteManagerIsOpen ( ) ;
665693
666694 // Wait for the saved site to load - this verifies the saved site wasn't overwritten
667- // by the ZIP import (which went to a temporary site instead)
695+ // by the ZIP import (which went to a new saved site instead)
668696 await expect ( website . page . getByLabel ( 'Playground title' ) ) . toContainText (
669697 savedSiteName ,
670698 { timeout : 30000 }
0 commit comments