Files
jackwener__opencli/src/tui.test.ts
T
jakevin 9b425c7550 feat: Electron auto-launcher — zero-config CDP connection (#653)
* docs: add dingtalk and wecom CLI to external CLI hub

Add dingtalk-workspace-cli and wecom-cli as external CLI integrations
alongside lark-cli, gh, docker, etc.

* feat: add confirmPrompt() to TUI module

* feat: add Electron app registry with builtin + user-defined apps

* feat: add Electron app launcher with auto-detect and restart

* fix: launcher uses processName for path discovery, platform-guard tests

* feat: integrate Electron auto-launcher into execution pipeline

- CDPBridge.connect() accepts cdpEndpoint parameter instead of requiring env var
- getBrowserFactory() selects CDPBridge for registered Electron apps by site name
- executeCommand() calls resolveElectronEndpoint() for Electron apps, skips daemon check
- Remove requiredEnv/OPENCLI_CDP_ENDPOINT from all chatwise commands
- Remove chatwise-opencli.ps1 wrapper script and chatwise/shared.ts
- Update antigravity/serve.ts to use launcher instead of manual env var
- Replace hardcoded app names in scoreCDPTarget with registry lookup
- Fix Discord bundleId typo (com.iscord.app → com.discord.app)

* fix: resolve review issues — port collision and registry completeness

- Change ChatGPT CDP port from 9224 to 9236 (was colliding with Antigravity)
- scoreCDPTarget now uses full registry (builtin + user-defined) via getAllElectronApps()
- Use displayName (falling back to processName) for target score boosting

* fix: assign unique CDP ports — antigravity 9234, chatgpt 9236

Both were sharing port 9224, which could cause silent mis-connection.
2026-04-01 12:49:52 +08:00

24 lines
695 B
TypeScript

import { describe, it, expect, vi, beforeEach } from 'vitest';
import { confirmPrompt } from './tui.js';
describe('confirmPrompt', () => {
beforeEach(() => {
vi.restoreAllMocks();
});
it('returns defaultYes when stdin is not TTY', async () => {
const result = await confirmPrompt('Restart?', true);
expect(result).toBe(true);
});
it('returns false when defaultYes is false and non-TTY', async () => {
const result = await confirmPrompt('Restart?', false);
expect(result).toBe(false);
});
it('defaults to true when defaultYes is omitted and non-TTY', async () => {
const result = await confirmPrompt('Restart?');
expect(result).toBe(true);
});
});