Files
Garry Tan d7c732b282 fix: Windows support — Node.js server fallback for Playwright (#255)
* fix: Windows support — Node.js server fallback for Playwright

Setup hangs on Windows 11 because Bun's child_process can't handle
Playwright's --remote-debugging-pipe (fd 3/4 pipe handles). Fall back
to Node.js on Windows for both the setup verification and server
runtime. macOS/Linux completely unaffected — all Windows code behind
IS_WINDOWS / process.platform === 'win32' guards.

Based on community PR #194 by @sozairali. Fixed sed -i portability
(perl -pi -e) in build-node-server.sh for macOS compatibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: cross-platform path handling for Windows compatibility

Replace hardcoded '/tmp' and 'dir + "/"' path checks with
platform-aware constants from new platform.ts module. On macOS/Linux
this evaluates identically ('/tmp', '/'); on Windows it uses
os.tmpdir() and path.sep. Zero behavior change on Unix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: add tests for Windows polyfill, platform constants, and Node server resolution

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* docs: Windows support in README + CHANGELOG (v0.9.1.1)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: bump version and changelog (v0.9.3.0)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 12:22:11 -07:00

38 lines
1.0 KiB
TypeScript

import { describe, test, expect } from 'bun:test';
import { TEMP_DIR, isPathWithin, IS_WINDOWS } from '../src/platform';
describe('platform constants', () => {
test('TEMP_DIR is /tmp on non-Windows', () => {
if (!IS_WINDOWS) {
expect(TEMP_DIR).toBe('/tmp');
}
});
test('IS_WINDOWS reflects process.platform', () => {
expect(IS_WINDOWS).toBe(process.platform === 'win32');
});
});
describe('isPathWithin', () => {
test('path inside directory returns true', () => {
expect(isPathWithin('/tmp/foo', '/tmp')).toBe(true);
});
test('path outside directory returns false', () => {
expect(isPathWithin('/etc/foo', '/tmp')).toBe(false);
});
test('exact match returns true', () => {
expect(isPathWithin('/tmp', '/tmp')).toBe(true);
});
test('partial prefix does not match (path traversal)', () => {
// /tmp-evil should NOT match /tmp
expect(isPathWithin('/tmp-evil/foo', '/tmp')).toBe(false);
});
test('nested path returns true', () => {
expect(isPathWithin('/tmp/a/b/c', '/tmp')).toBe(true);
});
});