@@ -3,6 +3,7 @@ import * as NodePath from "node:path";
33import { assert , describe , it } from "@effect/vitest" ;
44
55import {
6+ restoreEarlyLinuxDeviceScaleFactor ,
67 resolveEarlyLinuxElectronOptions ,
78 resolveEarlyLinuxPasswordStorePreference ,
89 resolveLinuxDisableFeaturesSwitch ,
@@ -269,3 +270,70 @@ describe("DesktopEarlyElectronStartup", () => {
269270 } ) ;
270271 } ) ;
271272} ) ;
273+
274+ describe ( "Linux device scale persistence failures" , ( ) => {
275+ const input = {
276+ env : { T3CODE_HOME : "/isolated" } ,
277+ homeDirectory : "/home/user" ,
278+ joinPath : NodePath . posix . join ,
279+ } ;
280+
281+ it . each ( [ "0" , "Infinity" , "garbage" ] ) ( "ignores invalid persisted scale %j" , ( value ) => {
282+ const applied : Array < [ string , string ] > = [ ] ;
283+ const writes : Array < string > = [ ] ;
284+ restoreEarlyLinuxDeviceScaleFactor ( {
285+ ...input ,
286+ commandLine : {
287+ hasSwitch : ( ) => false ,
288+ getSwitchValue : ( ) => "" ,
289+ appendSwitch : ( name , scale ) => applied . push ( [ name , scale ] ) ,
290+ } ,
291+ readFileString : ( ) => value ,
292+ writeFileString : ( _path , contents ) => writes . push ( contents ) ,
293+ } ) ;
294+ assert . deepEqual ( applied , [ ] ) ;
295+ assert . deepEqual ( writes , [ ] ) ;
296+ } ) ;
297+
298+ it ( "keeps startup available with default scaling when saved state cannot be read" , ( ) => {
299+ const applied : Array < [ string , string ] > = [ ] ;
300+ restoreEarlyLinuxDeviceScaleFactor ( {
301+ ...input ,
302+ commandLine : {
303+ hasSwitch : ( ) => false ,
304+ getSwitchValue : ( ) => "" ,
305+ appendSwitch : ( name , value ) => applied . push ( [ name , value ] ) ,
306+ } ,
307+ readFileString : ( ) => {
308+ throw new Error ( "ENOENT" ) ;
309+ } ,
310+ writeFileString : ( ) => { } ,
311+ } ) ;
312+ assert . deepEqual ( applied , [ ] ) ;
313+ } ) ;
314+
315+ it ( "keeps an explicit scale when saving it fails, without falling back to saved state" , ( ) => {
316+ const applied : Array < [ string , string ] > = [ ] ;
317+ const reads : Array < string > = [ ] ;
318+ const writes : Array < string > = [ ] ;
319+ restoreEarlyLinuxDeviceScaleFactor ( {
320+ ...input ,
321+ commandLine : {
322+ hasSwitch : ( ) => true ,
323+ getSwitchValue : ( ) => "1" ,
324+ appendSwitch : ( name , value ) => applied . push ( [ name , value ] ) ,
325+ } ,
326+ readFileString : ( path ) => {
327+ reads . push ( path ) ;
328+ return "1.75" ;
329+ } ,
330+ writeFileString : ( _path , value ) => {
331+ writes . push ( value ) ;
332+ throw new Error ( "EACCES" ) ;
333+ } ,
334+ } ) ;
335+ assert . deepEqual ( writes , [ "1" ] ) ;
336+ assert . deepEqual ( reads , [ ] ) ;
337+ assert . deepEqual ( applied , [ ] ) ;
338+ } ) ;
339+ } ) ;
0 commit comments