@@ -223,6 +223,49 @@ ${fs.readdirSync(installerDownloadFolder).join(', ')}`);
223223 shouldNotExistOptionPath = await installer . getExpectedGlobalSDKPath ( sdkVersionThatShouldNotExist , os . arch ( ) ) ;
224224 assert . equal ( shouldNotExistOptionPath , standardHostPath , 'It wont use the emu path if it does not exist' ) ;
225225 }
226- }
227- } ) . timeout ( standardTimeoutTime ) ;
226+ }
227+ } ) . timeout ( standardTimeoutTime ) ;
228+
229+ test ( 'InterpretExitCode returns user-friendly messages for common exit codes' , ( ) =>
230+ {
231+ // Test exit code 5 - insufficient permissions
232+ const exitCode5Message = WinMacGlobalInstaller . InterpretExitCode ( '5' ) ;
233+ assert . equal ( exitCode5Message , 'Insufficient permissions are available to install .NET. Please run the installer as an administrator.' ) ;
234+ assert . isFalse ( exitCode5Message . includes ( 'report' ) , 'Exit code 5 should not ask for bug reports' ) ;
235+ assert . isTrue ( WinMacGlobalInstaller . IsUserFriendlyExitCode ( '5' ) , 'Exit code 5 should be marked as user-friendly' ) ;
236+
237+ // Test exit code 1618 - another installation in progress
238+ const exitCode1618Message = WinMacGlobalInstaller . InterpretExitCode ( '1618' ) ;
239+ assert . equal ( exitCode1618Message , 'Another installation is already in progress. Complete that installation before proceeding with this install.' ) ;
240+ assert . isFalse ( exitCode1618Message . includes ( 'report' ) , 'Exit code 1618 should not ask for bug reports' ) ;
241+ assert . isTrue ( WinMacGlobalInstaller . IsUserFriendlyExitCode ( '1618' ) , 'Exit code 1618 should be marked as user-friendly' ) ;
242+
243+ // Test exit code 112 - disk full
244+ const exitCode112Message = WinMacGlobalInstaller . InterpretExitCode ( '112' ) ;
245+ assert . equal ( exitCode112Message , 'The disk is full. Please free up space and try again.' ) ;
246+ assert . isFalse ( exitCode112Message . includes ( 'report' ) , 'Exit code 112 should not ask for bug reports' ) ;
247+ assert . isTrue ( WinMacGlobalInstaller . IsUserFriendlyExitCode ( '112' ) , 'Exit code 112 should be marked as user-friendly' ) ;
248+
249+ // Test exit code 255 - terminated by another process
250+ const exitCode255Message = WinMacGlobalInstaller . InterpretExitCode ( '255' ) ;
251+ assert . equal ( exitCode255Message , 'The .NET Installer was terminated by another process unexpectedly. Please try again.' ) ;
252+ assert . isFalse ( exitCode255Message . includes ( 'report' ) , 'Exit code 255 should not ask for bug reports' ) ;
253+ assert . isTrue ( WinMacGlobalInstaller . IsUserFriendlyExitCode ( '255' ) , 'Exit code 255 should be marked as user-friendly' ) ;
254+
255+ // Test exit code 2147942405 - insufficient permissions (alternative code)
256+ const exitCode2147942405Message = WinMacGlobalInstaller . InterpretExitCode ( '2147942405' ) ;
257+ assert . equal ( exitCode2147942405Message , 'Insufficient permissions are available to install .NET. Please try again as an administrator.' ) ;
258+ assert . isFalse ( exitCode2147942405Message . includes ( 'report' ) , 'Exit code 2147942405 should not ask for bug reports' ) ;
259+ assert . isTrue ( WinMacGlobalInstaller . IsUserFriendlyExitCode ( '2147942405' ) , 'Exit code 2147942405 should be marked as user-friendly' ) ;
260+
261+ // Test exit code 1 - generic failure (should include report message)
262+ const exitCode1Message = WinMacGlobalInstaller . InterpretExitCode ( '1' ) ;
263+ assert . isTrue ( exitCode1Message . includes ( 'report' ) , 'Exit code 1 should ask for bug reports' ) ;
264+ assert . isFalse ( WinMacGlobalInstaller . IsUserFriendlyExitCode ( '1' ) , 'Exit code 1 should not be marked as user-friendly' ) ;
265+
266+ // Test unknown exit code
267+ const unknownCodeMessage = WinMacGlobalInstaller . InterpretExitCode ( '9999' ) ;
268+ assert . equal ( unknownCodeMessage , '' , 'Unknown exit codes should return empty string' ) ;
269+ assert . isFalse ( WinMacGlobalInstaller . IsUserFriendlyExitCode ( '9999' ) , 'Unknown exit codes should not be marked as user-friendly' ) ;
270+ } ) ;
228271} ) ;
0 commit comments