mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-10 12:05:53 +00:00
- Migrate GitHub Actions to Blacksmith runners for faster CI - Update ubuntu-latest to blacksmith-4vcpu-ubuntu-2404 - Update actions/setup-node@v4 to useblacksmith/setup-node@v5 - Update Swatinem/rust-cache@v2 to useblacksmith/rust-cache@v3 - Fix all linting warnings across all platforms - TypeScript: Fix any type warnings with proper type annotations - Rust: All clippy warnings resolved - Swift: Fix SwiftLint violations and format code - Update all dependencies to latest versions - npm: Major updates including Express 5 compatibility fixes - Rust: Update 7 crates to latest compatible versions - Swift: Dependencies already up-to-date - Add comprehensive test suite using Vitest - API endpoint tests for session CRUD operations - WebSocket connection and streaming tests - Session management lifecycle tests - Frontend component tests (terminal, session-list) - Critical functionality tests covering core features - Test infrastructure with proper mocking and utilities - All tests passing, ready for production use
69 lines
No EOL
1.5 KiB
TypeScript
69 lines
No EOL
1.5 KiB
TypeScript
import { Express } from 'express';
|
|
import { Server } from 'http';
|
|
import { vi } from 'vitest';
|
|
|
|
export interface MockSession {
|
|
id: string;
|
|
command: string;
|
|
workingDir: string;
|
|
name?: string;
|
|
status: 'running' | 'exited';
|
|
exitCode?: number;
|
|
startedAt: string;
|
|
lastModified: string;
|
|
pid?: number;
|
|
waiting?: boolean;
|
|
}
|
|
|
|
export const createMockSession = (overrides?: Partial<MockSession>): MockSession => ({
|
|
id: 'test-session-123',
|
|
command: 'bash',
|
|
workingDir: '/tmp',
|
|
status: 'running',
|
|
startedAt: new Date().toISOString(),
|
|
lastModified: new Date().toISOString(),
|
|
pid: 12345,
|
|
...overrides,
|
|
});
|
|
|
|
export const createTestServer = async (app: Express): Promise<Server> => {
|
|
return new Promise((resolve) => {
|
|
const server = app.listen(0, () => {
|
|
resolve(server);
|
|
});
|
|
});
|
|
};
|
|
|
|
export const closeTestServer = async (server: Server): Promise<void> => {
|
|
return new Promise((resolve) => {
|
|
server.close(() => resolve());
|
|
});
|
|
};
|
|
|
|
export const waitForWebSocket = (ms: number = 100): Promise<void> => {
|
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
};
|
|
|
|
export const mockWebSocketServer = () => {
|
|
const clients = new Set();
|
|
const broadcast = vi.fn();
|
|
|
|
return {
|
|
clients,
|
|
broadcast,
|
|
on: vi.fn(),
|
|
handleUpgrade: vi.fn(),
|
|
};
|
|
};
|
|
|
|
// Custom type declarations for test matchers
|
|
declare global {
|
|
namespace Vi {
|
|
interface Assertion<T = any> {
|
|
toBeValidSession(): T;
|
|
}
|
|
interface AsymmetricMatchersContaining {
|
|
toBeValidSession(): any;
|
|
}
|
|
}
|
|
} |