@@ -39,7 +39,7 @@ const state = vi.hoisted(() => ({
3939 ( request : {
4040 environmentId : EnvironmentId ;
4141 input : UpdateProjectInput ;
42- } ) => Promise < AsyncResult . Success < void > >
42+ } ) => Promise < AsyncResult . Success < void > | AsyncResult . Failure < void , Error > >
4343 > ( ) ,
4444 delete :
4545 vi . fn <
@@ -134,6 +134,7 @@ vi.mock(import("../files/projectFilesQueryState"), async (original) => ({
134134
135135import { useComposerDraftStore } from "../../composerDraftStore" ;
136136import { appAtomRegistry } from "../../rpc/atomRegistry" ;
137+ import { assetEnvironment } from "../../state/assets" ;
137138import { buildSidebarProjectSnapshots } from "../../sidebarProjectGrouping" ;
138139import { ProjectSettingsPanel } from "./ProjectSettingsPanel" ;
139140import { ProjectsSettings } from "./ProjectsSettings" ;
@@ -532,6 +533,40 @@ describe("project identity reset", () => {
532533 } ,
533534 ] ) ;
534535 } ) ;
536+
537+ it ( "refreshes a saved checkout's icon when a later checkout update fails" , async ( ) => {
538+ setup ( ) ;
539+ state . projects = state . projects . map ( ( project ) => ( { ...project , faviconPath : "logo.png" } ) ) ;
540+ let iconExists = false ;
541+ const iconUrl = Atom . make ( ( ) =>
542+ AsyncResult . success ( {
543+ expiresAt : 4_000_000_000_000 ,
544+ relativeUrl : iconExists ? "/restored-icon.svg" : "/project-favicon-missing" ,
545+ } ) ,
546+ ) ;
547+ using _mount = { [ Symbol . dispose ] : appAtomRegistry . mount ( iconUrl ) } ;
548+ const createUrl = assetEnvironment . createUrl ;
549+ using _createUrl = vi
550+ . spyOn ( assetEnvironment , "createUrl" )
551+ . mockImplementation ( ( target ) =>
552+ target . environmentId === primaryId ? iconUrl : createUrl ( target ) ,
553+ ) ;
554+ state . update
555+ . mockResolvedValueOnce ( AsyncResult . success ( undefined ) )
556+ . mockResolvedValueOnce ( AsyncResult . failure ( Cause . fail ( new Error ( "Save failed" ) ) ) ) ;
557+ await using screen = await mountPanel ( ) ;
558+ expect ( appAtomRegistry . get ( iconUrl ) . value . relativeUrl ) . toBe ( "/project-favicon-missing" ) ;
559+
560+ iconExists = true ;
561+ await userEvent . click ( resetButton ( screen , "project icon" ) ! ) ;
562+
563+ await vi . waitFor ( ( ) =>
564+ expect ( appAtomRegistry . get ( iconUrl ) . value . relativeUrl ) . toBe ( "/restored-icon.svg" ) ,
565+ ) ;
566+ expect ( state . toast ) . toHaveBeenCalledWith (
567+ expect . objectContaining ( { title : "Failed to update project icon on remote" } ) ,
568+ ) ;
569+ } ) ;
535570} ) ;
536571
537572it ( "opens the fallback search target across all environments from a checkout" , async ( ) => {
0 commit comments