@@ -16,6 +16,7 @@ const {
1616 copyFileSyncMock,
1717 execFileSyncMock,
1818 readFileSyncMock,
19+ symlinkSyncMock,
1920} = vi . hoisted ( ( ) => ( {
2021 appendSwitchMock : vi . fn ( ) ,
2122 getSwitchValueMock : vi . fn ( ) ,
@@ -27,6 +28,7 @@ const {
2728 copyFileSyncMock : vi . fn ( ) ,
2829 execFileSyncMock : vi . fn ( ) ,
2930 readFileSyncMock : vi . fn ( ) ,
31+ symlinkSyncMock : vi . fn ( ) ,
3032} ) ) ;
3133
3234vi . mock ( "electron" , ( ) => ( {
@@ -51,6 +53,7 @@ vi.mock("node:fs", () => ({
5153 mkdirSync : mkdirSyncMock ,
5254 writeFileSync : writeFileSyncMock ,
5355 copyFileSync : copyFileSyncMock ,
56+ symlinkSync : symlinkSyncMock ,
5457} ) ) ;
5558
5659vi . mock ( "node:child_process" , ( ) => ( {
@@ -72,6 +75,7 @@ describe("DesktopPreReadyPlatform", () => {
7275 copyFileSyncMock . mockReset ( ) ;
7376 execFileSyncMock . mockReset ( ) ;
7477 readFileSyncMock . mockReset ( ) . mockReturnValue ( "{}" ) ;
78+ symlinkSyncMock . mockReset ( ) ;
7579 } ) ;
7680
7781 it . effect ( "persists Linux scaling synchronously across relaunches and settings rewrites" , ( ) => {
@@ -181,6 +185,47 @@ describe("DesktopPreReadyPlatform", () => {
181185 ) . pipe ( Effect . ensuring ( Effect . sync ( ( ) => vi . unstubAllEnvs ( ) ) ) ) ;
182186 } ) ;
183187
188+ it . effect . each ( [
189+ { relaunchedByUpdater : "true" , restored : true } ,
190+ { relaunchedByUpdater : "" , restored : false } ,
191+ ] ) (
192+ "restores the versioned AppImage path an update removed (updater relaunch: $relaunchedByUpdater)" ,
193+ ( { relaunchedByUpdater, restored } ) => {
194+ vi . stubEnv ( "VITE_DEV_SERVER_URL" , "" ) ;
195+ getSwitchValueMock . mockReturnValue ( "" ) ;
196+ const entryPath = "/xdg/applications/com.t3tools.T3Code.desktop" ;
197+ const files = new Map ( [ [ entryPath , "Exec=/Applications/T3-Code-0.1.8-x86_64.AppImage %U\n" ] ] ) ;
198+ readFileSyncMock . mockImplementation ( ( path : string ) => files . get ( path ) ?? "{}" ) ;
199+ writeFileSyncMock . mockImplementation ( ( path : string , contents : string | Buffer ) => {
200+ files . set ( path , String ( contents ) ) ;
201+ } ) ;
202+
203+ return Effect . scoped (
204+ Effect . gen ( function * ( ) {
205+ yield * Layer . build (
206+ DesktopPreReadyPlatform . layer . pipe (
207+ Layer . provide ( Layer . succeed ( HostProcess . Platform , "linux" ) ) ,
208+ Layer . provide (
209+ DesktopConfig . layerTest ( {
210+ XDG_DATA_HOME : "/xdg" ,
211+ APPIMAGE : "/Applications/T3-Code-x86_64.AppImage" ,
212+ APPIMAGE_SILENT_INSTALL : relaunchedByUpdater ,
213+ } ) ,
214+ ) ,
215+ ) ,
216+ ) ;
217+ assert . deepEqual (
218+ symlinkSyncMock . mock . calls ,
219+ restored
220+ ? [ [ "T3-Code-x86_64.AppImage" , "/Applications/T3-Code-0.1.8-x86_64.AppImage" ] ]
221+ : [ ] ,
222+ ) ;
223+ assert . include ( files . get ( entryPath ) , "Exec=/Applications/T3-Code-x86_64.AppImage %U" ) ;
224+ } ) ,
225+ ) . pipe ( Effect . ensuring ( Effect . sync ( ( ) => vi . unstubAllEnvs ( ) ) ) ) ;
226+ } ,
227+ ) ;
228+
184229 it . effect ( "points the early portal entry at a configured distribution launcher" , ( ) => {
185230 vi . stubEnv ( "VITE_DEV_SERVER_URL" , "" ) ;
186231 getSwitchValueMock . mockReturnValue ( "" ) ;
0 commit comments