Files
automaker/apps/server/tests/unit/providers/gemini-provider.test.ts
gsxdsm 0330c70261 Feature: worktree view customization and stability fixes (#805)
* Changes from feature/worktree-view-customization

* Feature: Git sync, set-tracking, and push divergence handling (#796)

* Add quick-add feature with improved workflows (#802)

* Changes from feature/quick-add

* feat: Clarify system prompt and improve error handling across services. Address PR Feedback

* feat: Improve PR description parsing and refactor event handling

* feat: Add context options to pipeline orchestrator initialization

* fix: Deduplicate React and handle CJS interop for use-sync-external-store

Resolve "Cannot read properties of null (reading 'useState')" errors by
deduplicating React/react-dom and ensuring use-sync-external-store is
bundled together with React to prevent CJS packages from resolving to
different React instances.

* Changes from feature/worktree-view-customization

* refactor: Remove unused worktree swap and highlight props

* refactor: Consolidate feature completion logic and improve thinking level defaults

* feat: Increase max turn limit to 10000

- Update DEFAULT_MAX_TURNS from 1000 to 10000 in settings-helpers.ts and agent-executor.ts
- Update MAX_ALLOWED_TURNS from 2000 to 10000 in settings-helpers.ts
- Update UI clamping logic from 2000 to 10000 in app-store.ts
- Update fallback values from 1000 to 10000 in use-settings-sync.ts
- Update default value from 1000 to 10000 in DEFAULT_GLOBAL_SETTINGS
- Update documentation to reflect new range: 1-10000

Allows agents to perform up to 10000 turns for complex feature execution.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* feat: Add model resolution, improve session handling, and enhance UI stability

* refactor: Remove unused sync and tracking branch props from worktree components

* feat: Add PR number update functionality to worktrees. Address pr feedback

* feat: Optimize Gemini CLI startup and add tool result tracking

* refactor: Improve error handling and simplify worktree task cleanup

---------

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
2026-02-23 20:31:25 -08:00

120 lines
3.5 KiB
TypeScript

import { describe, it, expect, beforeEach } from 'vitest';
import { GeminiProvider } from '@/providers/gemini-provider.js';
describe('gemini-provider.ts', () => {
let provider: GeminiProvider;
beforeEach(() => {
provider = new GeminiProvider();
});
describe('buildCliArgs', () => {
it('should include --prompt with empty string to force headless mode', () => {
const args = provider.buildCliArgs({
prompt: 'Hello from Gemini',
model: '2.5-flash',
cwd: '/tmp/project',
});
const promptIndex = args.indexOf('--prompt');
expect(promptIndex).toBeGreaterThan(-1);
expect(args[promptIndex + 1]).toBe('');
});
it('should include --resume when sdkSessionId is provided', () => {
const args = provider.buildCliArgs({
prompt: 'Hello',
model: '2.5-flash',
cwd: '/tmp/project',
sdkSessionId: 'gemini-session-123',
});
const resumeIndex = args.indexOf('--resume');
expect(resumeIndex).toBeGreaterThan(-1);
expect(args[resumeIndex + 1]).toBe('gemini-session-123');
});
it('should not include --resume when sdkSessionId is missing', () => {
const args = provider.buildCliArgs({
prompt: 'Hello',
model: '2.5-flash',
cwd: '/tmp/project',
});
expect(args).not.toContain('--resume');
});
it('should include --sandbox false for faster execution', () => {
const args = provider.buildCliArgs({
prompt: 'Hello',
model: '2.5-flash',
cwd: '/tmp/project',
});
const sandboxIndex = args.indexOf('--sandbox');
expect(sandboxIndex).toBeGreaterThan(-1);
expect(args[sandboxIndex + 1]).toBe('false');
});
it('should include --approval-mode yolo for non-interactive use', () => {
const args = provider.buildCliArgs({
prompt: 'Hello',
model: '2.5-flash',
cwd: '/tmp/project',
});
const approvalIndex = args.indexOf('--approval-mode');
expect(approvalIndex).toBeGreaterThan(-1);
expect(args[approvalIndex + 1]).toBe('yolo');
});
it('should include --output-format stream-json', () => {
const args = provider.buildCliArgs({
prompt: 'Hello',
model: '2.5-flash',
cwd: '/tmp/project',
});
const formatIndex = args.indexOf('--output-format');
expect(formatIndex).toBeGreaterThan(-1);
expect(args[formatIndex + 1]).toBe('stream-json');
});
it('should include --include-directories with cwd', () => {
const args = provider.buildCliArgs({
prompt: 'Hello',
model: '2.5-flash',
cwd: '/tmp/my-project',
});
const dirIndex = args.indexOf('--include-directories');
expect(dirIndex).toBeGreaterThan(-1);
expect(args[dirIndex + 1]).toBe('/tmp/my-project');
});
it('should add gemini- prefix to bare model names', () => {
const args = provider.buildCliArgs({
prompt: 'Hello',
model: '2.5-flash',
cwd: '/tmp/project',
});
const modelIndex = args.indexOf('--model');
expect(modelIndex).toBeGreaterThan(-1);
expect(args[modelIndex + 1]).toBe('gemini-2.5-flash');
});
it('should not double-prefix model names that already have gemini-', () => {
const args = provider.buildCliArgs({
prompt: 'Hello',
model: 'gemini-2.5-pro',
cwd: '/tmp/project',
});
const modelIndex = args.indexOf('--model');
expect(modelIndex).toBeGreaterThan(-1);
expect(args[modelIndex + 1]).toBe('gemini-2.5-pro');
});
});
});