Improve user-facing error messages for IDE mode (#5522)

This commit is contained in:
Shreya Keshive
2025-08-04 17:06:17 -04:00
committed by GitHub
parent 11808ef7ed
commit 2180dd13dc
5 changed files with 43 additions and 54 deletions

View File

@@ -45,32 +45,6 @@ describe('ide-installer', () => {
vi.restoreAllMocks();
});
describe('isInstalled', () => {
it('should return true if command is in PATH', async () => {
expect(await installer.isInstalled()).toBe(true);
});
it('should return true if command is in a known location', async () => {
vi.spyOn(child_process, 'execSync').mockImplementation(() => {
throw new Error('Command not found');
});
vi.spyOn(fs, 'existsSync').mockReturnValue(true);
// Re-create the installer so it re-runs findVsCodeCommand
installer = getIdeInstaller(DetectedIde.VSCode)!;
expect(await installer.isInstalled()).toBe(true);
});
it('should return false if command is not found', async () => {
vi.spyOn(child_process, 'execSync').mockImplementation(() => {
throw new Error('Command not found');
});
vi.spyOn(fs, 'existsSync').mockReturnValue(false);
// Re-create the installer so it re-runs findVsCodeCommand
installer = getIdeInstaller(DetectedIde.VSCode)!;
expect(await installer.isInstalled()).toBe(false);
});
});
describe('install', () => {
it('should return a failure message if VS Code is not installed', async () => {
vi.spyOn(child_process, 'execSync').mockImplementation(() => {
@@ -81,9 +55,7 @@ describe('ide-installer', () => {
installer = getIdeInstaller(DetectedIde.VSCode)!;
const result = await installer.install();
expect(result.success).toBe(false);
expect(result.message).toContain(
'not found in your PATH or common installation locations',
);
expect(result.message).toContain('VS Code CLI not found');
});
});
});