@@ -462,15 +462,22 @@ describe('pickLocalFolderPath', () => {
462462 } ) ;
463463} ) ;
464464
465- describe ( 'deleteProject tabs cache ' , ( ) => {
465+ describe ( 'deleteProject local caches ' , ( ) => {
466466 afterEach ( ( ) => {
467467 vi . unstubAllGlobals ( ) ;
468468 } ) ;
469469
470470 const tabsKey = 'open-design:project-tabs:v1:p1' ;
471+ // Keep in sync with DesignBrowserPanel historyStorageKey / viewportStorageKey.
472+ const historyKey = 'od:design-browser:p1:history:v1' ;
473+ const viewportKey = 'od:design-browser:p1:viewport:v1' ;
471474
472475 function stubWindowStore ( ) : Map < string , string > {
473- const store = new Map < string , string > ( [ [ tabsKey , JSON . stringify ( { tabs : [ ] , active : null } ) ] ] ) ;
476+ const store = new Map < string , string > ( [
477+ [ tabsKey , JSON . stringify ( { tabs : [ ] , active : null } ) ] ,
478+ [ historyKey , JSON . stringify ( [ { url : 'https://example.com' , title : 'Example' , lastVisitedAt : 1 } ] ) ] ,
479+ [ viewportKey , 'mobile' ] ,
480+ ] ) ;
474481 vi . stubGlobal ( 'window' , {
475482 localStorage : {
476483 getItem : ( k : string ) => store . get ( k ) ?? null ,
@@ -485,17 +492,21 @@ describe('deleteProject tabs cache', () => {
485492 return store ;
486493 }
487494
488- it ( 'prunes the project tabs cache on a successful delete' , async ( ) => {
495+ it ( 'prunes tabs and Design Browser caches on a successful delete' , async ( ) => {
489496 const store = stubWindowStore ( ) ;
490497 vi . stubGlobal ( 'fetch' , vi . fn < typeof fetch > ( async ( ) => new Response ( null , { status : 200 } ) ) ) ;
491498 await expect ( deleteProject ( 'p1' ) ) . resolves . toBe ( true ) ;
492499 expect ( store . has ( tabsKey ) ) . toBe ( false ) ;
500+ expect ( store . has ( historyKey ) ) . toBe ( false ) ;
501+ expect ( store . has ( viewportKey ) ) . toBe ( false ) ;
493502 } ) ;
494503
495- it ( 'keeps the tabs cache when the delete fails' , async ( ) => {
504+ it ( 'keeps tabs and Design Browser caches when the delete fails' , async ( ) => {
496505 const store = stubWindowStore ( ) ;
497506 vi . stubGlobal ( 'fetch' , vi . fn < typeof fetch > ( async ( ) => new Response ( null , { status : 500 } ) ) ) ;
498507 await expect ( deleteProject ( 'p1' ) ) . resolves . toBe ( false ) ;
499508 expect ( store . has ( tabsKey ) ) . toBe ( true ) ;
509+ expect ( store . has ( historyKey ) ) . toBe ( true ) ;
510+ expect ( store . has ( viewportKey ) ) . toBe ( true ) ;
500511 } ) ;
501512} ) ;
0 commit comments