fix: Update tests for requiresPromptToStart capability and slash command behavior

- Update InputArea tests: slash commands now shown for all agents
  (built-in commands always available regardless of supportsSlashCommands)
- Update useSessionManager test: Claude Code now spawns process immediately
  since requiresPromptToStart: false (was previously testing old batch mode behavior)
- Add missing capability fields to mock objects (supportsModelSelection, requiresPromptToStart)

Claude ID: 207f9996-7530-493f-bb99-96a3bb26c6f7
Maestro ID: b9bc0d08-5be2-4fdf-93cd-5618a8d53b35
This commit is contained in:
Pedram Amini
2025-12-17 14:54:34 -06:00
parent 86220f7d28
commit 66e198fe05
2 changed files with 12 additions and 61 deletions

View File

@@ -670,32 +670,9 @@ describe('InputArea', () => {
expect(setSlashCommandOpen).toHaveBeenCalledWith(false);
});
it('hides slash command autocomplete when agent does not support slash commands', async () => {
// Mock capabilities to return false for supportsSlashCommands
const useAgentCapabilitiesMock = await import('../../../renderer/hooks/useAgentCapabilities');
vi.mocked(useAgentCapabilitiesMock.useAgentCapabilities).mockReturnValueOnce({
capabilities: {
supportsResume: true,
supportsReadOnlyMode: true,
supportsJsonOutput: true,
supportsSessionId: true,
supportsImageInput: true,
supportsSlashCommands: false, // Not supported
supportsSessionStorage: false,
supportsCostTracking: false,
supportsUsageStats: false,
supportsBatchMode: false,
supportsStreaming: true,
supportsResultMessages: true,
supportsModelSelection: false,
requiresPromptToStart: false,
},
loading: false,
error: null,
refresh: vi.fn(),
hasCapability: vi.fn((cap: string) => cap !== 'supportsSlashCommands'),
});
it('shows slash command autocomplete for all agents (built-in commands always available)', async () => {
// Slash commands are now always available regardless of agent capability
// Built-in commands like /clear are shown for all agents
const props = createDefaultProps({
session: createMockSession({ inputMode: 'ai', toolType: 'opencode' }),
slashCommandOpen: true,
@@ -703,37 +680,12 @@ describe('InputArea', () => {
});
render(<InputArea {...props} />);
// Slash command autocomplete should not be shown
expect(screen.queryByText('/clear')).not.toBeInTheDocument();
expect(screen.queryByText('/help')).not.toBeInTheDocument();
// Slash command autocomplete should be shown for all agents
expect(screen.getByText('/clear')).toBeInTheDocument();
});
it('does not open slash command autocomplete when agent does not support slash commands', async () => {
// Mock capabilities to return false for supportsSlashCommands
const useAgentCapabilitiesMock = await import('../../../renderer/hooks/useAgentCapabilities');
vi.mocked(useAgentCapabilitiesMock.useAgentCapabilities).mockReturnValueOnce({
capabilities: {
supportsResume: true,
supportsReadOnlyMode: true,
supportsJsonOutput: true,
supportsSessionId: true,
supportsImageInput: true,
supportsSlashCommands: false, // Not supported
supportsSessionStorage: false,
supportsCostTracking: false,
supportsUsageStats: false,
supportsBatchMode: false,
supportsStreaming: true,
supportsResultMessages: true,
supportsModelSelection: false,
requiresPromptToStart: false,
},
loading: false,
error: null,
refresh: vi.fn(),
hasCapability: vi.fn((cap: string) => cap !== 'supportsSlashCommands'),
});
it('opens slash command autocomplete when typing / for any agent', async () => {
// Slash commands are now always available regardless of supportsSlashCommands capability
const setSlashCommandOpen = vi.fn();
const setSelectedSlashCommandIndex = vi.fn();
const props = createDefaultProps({
@@ -746,9 +698,8 @@ describe('InputArea', () => {
// Type "/" to trigger slash command detection
fireEvent.change(screen.getByRole('textbox'), { target: { value: '/' } });
// Should NOT open slash command autocomplete
expect(setSlashCommandOpen).toHaveBeenCalledWith(false);
expect(setSelectedSlashCommandIndex).not.toHaveBeenCalled();
// Should open slash command autocomplete for all agents
expect(setSlashCommandOpen).toHaveBeenCalledWith(true);
});
});

View File

@@ -554,7 +554,7 @@ describe('useSessionManager', () => {
expect(typeof result.current.createNewSession).toBe('function');
});
it('should create a new session for claude-code (batch mode)', async () => {
it('should create a new session for claude-code (spawns process)', async () => {
vi.mocked(window.maestro.agents.get).mockResolvedValue({
id: 'claude-code',
name: 'Claude Code',
@@ -576,8 +576,8 @@ describe('useSessionManager', () => {
expect(result.current.sessions[0].name).toBe('New Session');
expect(result.current.sessions[0].cwd).toBe('/test/path');
expect(result.current.sessions[0].toolType).toBe('claude-code');
// Batch mode skips spawning, so pid should be 0
expect(result.current.sessions[0].aiPid).toBe(0);
// Claude Code has requiresPromptToStart: false, so it spawns immediately
expect(result.current.sessions[0].aiPid).toBe(12345);
});
});