mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 06:42:03 +00:00
fix(tests): update terminal-service tests to work cross-platform
Updated terminal-service.test.ts to use path.resolve() in test expectations
so they work correctly on both Unix and Windows platforms.
The merge from main removed the skipIf conditions for Windows, expecting these
tests to work cross-platform. On Windows, path.resolve('/test/dir') converts
Unix-style paths to Windows paths (e.g., 'P:\test\dir'), so test expectations
needed to use path.resolve() as well to match the actual behavior.
Fixed tests:
- should create a new terminal session
- should fix double slashes in path
- should return all active sessions
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import { TerminalService, getTerminalService } from '@/services/terminal-service.js';
|
||||
import * as pty from 'node-pty';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as platform from '@automaker/platform';
|
||||
import * as secureFs from '@/lib/secure-fs.js';
|
||||
|
||||
@@ -288,13 +289,13 @@ describe('terminal-service.ts', () => {
|
||||
|
||||
expect(session).not.toBeNull();
|
||||
expect(session!.id).toMatch(/^term-/);
|
||||
expect(session!.cwd).toBe('/test/dir');
|
||||
expect(session!.cwd).toBe(path.resolve('/test/dir'));
|
||||
expect(session!.shell).toBe('/bin/bash');
|
||||
expect(pty.spawn).toHaveBeenCalledWith(
|
||||
'/bin/bash',
|
||||
['--login'],
|
||||
expect.objectContaining({
|
||||
cwd: '/test/dir',
|
||||
cwd: path.resolve('/test/dir'),
|
||||
cols: 100,
|
||||
rows: 30,
|
||||
})
|
||||
@@ -354,7 +355,7 @@ describe('terminal-service.ts', () => {
|
||||
});
|
||||
|
||||
expect(session).not.toBeNull();
|
||||
expect(session!.cwd).toBe('/test/dir');
|
||||
expect(session!.cwd).toBe(path.resolve('/test/dir'));
|
||||
});
|
||||
|
||||
it('should preserve WSL UNC paths', async () => {
|
||||
@@ -568,8 +569,8 @@ describe('terminal-service.ts', () => {
|
||||
expect(session2).not.toBeNull();
|
||||
expect(sessions[0].id).toBe(session1!.id);
|
||||
expect(sessions[1].id).toBe(session2!.id);
|
||||
expect(sessions[0].cwd).toBe('/dir1');
|
||||
expect(sessions[1].cwd).toBe('/dir2');
|
||||
expect(sessions[0].cwd).toBe(path.resolve('/dir1'));
|
||||
expect(sessions[1].cwd).toBe(path.resolve('/dir2'));
|
||||
});
|
||||
|
||||
it('should return empty array if no sessions', () => {
|
||||
|
||||
Reference in New Issue
Block a user