mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 18:18:21 +00:00
feat(cursor): complete daemon wiring and add dedicated dashboard page
This commit is contained in:
1 parent
6c2083949f
commit
be9d7cf73e
18 files changed
+1581
-212
No files matched your search
@@ -17,6 +17,7 @@ import {
|
||||
} from '../../../src/cursor/cursor-daemon';
|
||||
import { getCcsDir } from '../../../src/utils/config-manager';
|
||||
import { handleCursorCommand } from '../../../src/commands/cursor-command';
|
||||
import { loadCredentials } from '../../../src/cursor/cursor-auth';
|
||||
|
||||
// Test isolation
|
||||
let originalCcsHome: string | undefined;
|
||||
@@ -121,19 +122,19 @@ describe('removePidFile', () => {
|
||||
|
||||
describe('startDaemon', () => {
|
||||
it('rejects invalid port (0)', async () => {
|
||||
const result = await startDaemon({ port: 0, model: 'test' });
|
||||
const result = await startDaemon({ port: 0 });
|
||||
expect(result.success).toBe(false);
|
||||
expect(result.error).toContain('Invalid port');
|
||||
});
|
||||
|
||||
it('rejects invalid port (65536)', async () => {
|
||||
const result = await startDaemon({ port: 65536, model: 'test' });
|
||||
const result = await startDaemon({ port: 65536 });
|
||||
expect(result.success).toBe(false);
|
||||
expect(result.error).toContain('Invalid port');
|
||||
});
|
||||
|
||||
it('rejects non-integer port', async () => {
|
||||
const result = await startDaemon({ port: 3.14, model: 'test' });
|
||||
const result = await startDaemon({ port: 3.14 });
|
||||
expect(result.success).toBe(false);
|
||||
expect(result.error).toContain('Invalid port');
|
||||
});
|
||||
@@ -142,7 +143,7 @@ describe('startDaemon', () => {
|
||||
'starts and stops daemon successfully',
|
||||
async () => {
|
||||
const port = 10000 + Math.floor(Math.random() * 50000);
|
||||
const result = await startDaemon({ port, model: 'test' });
|
||||
const result = await startDaemon({ port, ghost_mode: true });
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.pid).toBeDefined();
|
||||
|
||||
@@ -150,6 +151,17 @@ describe('startDaemon', () => {
|
||||
const running = await isDaemonRunning(port);
|
||||
expect(running).toBe(true);
|
||||
|
||||
// Verify chat endpoint exists (requires auth, should not be 404)
|
||||
const chatResponse = await fetch(`http://127.0.0.1:${port}/v1/chat/completions`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
model: 'gpt-4.1',
|
||||
messages: [{ role: 'user', content: 'hello' }],
|
||||
}),
|
||||
});
|
||||
expect(chatResponse.status).toBe(401);
|
||||
|
||||
// Stop
|
||||
const stopResult = await stopDaemon();
|
||||
expect(stopResult.success).toBe(true);
|
||||
@@ -212,4 +224,25 @@ describe('handleCursorCommand', () => {
|
||||
const exitCode = await handleCursorCommand(['nonexistent']);
|
||||
expect(exitCode).toBe(1);
|
||||
});
|
||||
|
||||
it('supports manual auth import from CLI flags', async () => {
|
||||
const token = 'a'.repeat(60);
|
||||
const machineId = '1234567890abcdef1234567890abcdef';
|
||||
|
||||
const exitCode = await handleCursorCommand([
|
||||
'auth',
|
||||
'--manual',
|
||||
'--token',
|
||||
token,
|
||||
'--machine-id',
|
||||
machineId,
|
||||
]);
|
||||
|
||||
expect(exitCode).toBe(0);
|
||||
|
||||
const credentials = loadCredentials();
|
||||
expect(credentials).not.toBeNull();
|
||||
expect(credentials?.authMethod).toBe('manual');
|
||||
expect(credentials?.machineId).toBe(machineId);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user