summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/commands/ideCommand.test.ts
diff options
context:
space:
mode:
authorchristine betts <[email protected]>2025-07-30 22:36:24 +0000
committerGitHub <[email protected]>2025-07-30 22:36:24 +0000
commit325bb8913776c60b763ee5f66375a4ca90d22ce0 (patch)
treeeb2aaf9fa1f826e9cfeff3e1507457aeb61d8fdf /packages/cli/src/ui/commands/ideCommand.test.ts
parentac1bb5ee4275e508dfc2256bbd5ca012e4a4f469 (diff)
Add toggleable IDE mode setting (#5146)
Diffstat (limited to 'packages/cli/src/ui/commands/ideCommand.test.ts')
-rw-r--r--packages/cli/src/ui/commands/ideCommand.test.ts52
1 files changed, 37 insertions, 15 deletions
diff --git a/packages/cli/src/ui/commands/ideCommand.test.ts b/packages/cli/src/ui/commands/ideCommand.test.ts
index 3c73f52c..3c73549c 100644
--- a/packages/cli/src/ui/commands/ideCommand.test.ts
+++ b/packages/cli/src/ui/commands/ideCommand.test.ts
@@ -32,11 +32,19 @@ describe('ideCommand', () => {
ui: {
addItem: vi.fn(),
},
+ services: {
+ settings: {
+ setValue: vi.fn(),
+ },
+ },
} as unknown as CommandContext;
mockConfig = {
+ getIdeModeFeature: vi.fn(),
getIdeMode: vi.fn(),
getIdeClient: vi.fn(),
+ setIdeMode: vi.fn(),
+ setIdeClientDisconnected: vi.fn(),
} as unknown as Config;
platformSpy = vi.spyOn(process, 'platform', 'get');
@@ -46,13 +54,14 @@ describe('ideCommand', () => {
vi.restoreAllMocks();
});
- it('should return null if ideMode is not enabled', () => {
- vi.mocked(mockConfig.getIdeMode).mockReturnValue(false);
+ it('should return null if ideModeFeature is not enabled', () => {
+ vi.mocked(mockConfig.getIdeModeFeature).mockReturnValue(false);
const command = ideCommand(mockConfig);
expect(command).toBeNull();
});
- it('should return the ide command if ideMode is enabled', () => {
+ it('should return the ide command if ideModeFeature is enabled', () => {
+ vi.mocked(mockConfig.getIdeModeFeature).mockReturnValue(true);
vi.mocked(mockConfig.getIdeMode).mockReturnValue(true);
vi.mocked(mockConfig.getIdeClient).mockReturnValue({
getCurrentIde: () => DetectedIde.VSCode,
@@ -60,19 +69,20 @@ describe('ideCommand', () => {
const command = ideCommand(mockConfig);
expect(command).not.toBeNull();
expect(command?.name).toBe('ide');
- expect(command?.subCommands).toHaveLength(2);
- expect(command?.subCommands?.[0].name).toBe('status');
- expect(command?.subCommands?.[1].name).toBe('install');
+ expect(command?.subCommands).toHaveLength(3);
+ expect(command?.subCommands?.[0].name).toBe('disable');
+ expect(command?.subCommands?.[1].name).toBe('status');
+ expect(command?.subCommands?.[2].name).toBe('install');
});
describe('status subcommand', () => {
const mockGetConnectionStatus = vi.fn();
beforeEach(() => {
- vi.mocked(mockConfig.getIdeMode).mockReturnValue(true);
+ vi.mocked(mockConfig.getIdeModeFeature).mockReturnValue(true);
vi.mocked(mockConfig.getIdeClient).mockReturnValue({
getConnectionStatus: mockGetConnectionStatus,
getCurrentIde: () => DetectedIde.VSCode,
- } as ReturnType<Config['getIdeClient']>);
+ } as unknown as ReturnType<Config['getIdeClient']>);
});
it('should show connected status', () => {
@@ -80,7 +90,8 @@ describe('ideCommand', () => {
status: core.IDEConnectionStatus.Connected,
});
const command = ideCommand(mockConfig);
- const result = command!.subCommands![0].action!(mockContext, '');
+ const result = command!.subCommands!.find((c) => c.name === 'status')!
+ .action!(mockContext, '');
expect(mockGetConnectionStatus).toHaveBeenCalled();
expect(result).toEqual({
type: 'message',
@@ -94,7 +105,8 @@ describe('ideCommand', () => {
status: core.IDEConnectionStatus.Connecting,
});
const command = ideCommand(mockConfig);
- const result = command!.subCommands![0].action!(mockContext, '');
+ const result = command!.subCommands!.find((c) => c.name === 'status')!
+ .action!(mockContext, '');
expect(mockGetConnectionStatus).toHaveBeenCalled();
expect(result).toEqual({
type: 'message',
@@ -107,7 +119,8 @@ describe('ideCommand', () => {
status: core.IDEConnectionStatus.Disconnected,
});
const command = ideCommand(mockConfig);
- const result = command!.subCommands![0].action!(mockContext, '');
+ const result = command!.subCommands!.find((c) => c.name === 'status')!
+ .action!(mockContext, '');
expect(mockGetConnectionStatus).toHaveBeenCalled();
expect(result).toEqual({
type: 'message',
@@ -123,7 +136,8 @@ describe('ideCommand', () => {
details,
});
const command = ideCommand(mockConfig);
- const result = command!.subCommands![0].action!(mockContext, '');
+ const result = command!.subCommands!.find((c) => c.name === 'status')!
+ .action!(mockContext, '');
expect(mockGetConnectionStatus).toHaveBeenCalled();
expect(result).toEqual({
type: 'message',
@@ -136,10 +150,12 @@ describe('ideCommand', () => {
describe('install subcommand', () => {
const mockInstall = vi.fn();
beforeEach(() => {
+ vi.mocked(mockConfig.getIdeModeFeature).mockReturnValue(true);
vi.mocked(mockConfig.getIdeMode).mockReturnValue(true);
vi.mocked(mockConfig.getIdeClient).mockReturnValue({
getCurrentIde: () => DetectedIde.VSCode,
- } as ReturnType<Config['getIdeClient']>);
+ getConnectionStatus: vi.fn(),
+ } as unknown as ReturnType<Config['getIdeClient']>);
vi.mocked(core.getIdeInstaller).mockReturnValue({
install: mockInstall,
isInstalled: vi.fn(),
@@ -154,7 +170,10 @@ describe('ideCommand', () => {
});
const command = ideCommand(mockConfig);
- await command!.subCommands![1].action!(mockContext, '');
+ await command!.subCommands!.find((c) => c.name === 'install')!.action!(
+ mockContext,
+ '',
+ );
expect(core.getIdeInstaller).toHaveBeenCalledWith('vscode');
expect(mockInstall).toHaveBeenCalled();
@@ -181,7 +200,10 @@ describe('ideCommand', () => {
});
const command = ideCommand(mockConfig);
- await command!.subCommands![1].action!(mockContext, '');
+ await command!.subCommands!.find((c) => c.name === 'install')!.action!(
+ mockContext,
+ '',
+ );
expect(core.getIdeInstaller).toHaveBeenCalledWith('vscode');
expect(mockInstall).toHaveBeenCalled();