From 0833a6e9729ab18da3ffbea72de96c98131bd8e9 Mon Sep 17 00:00:00 2001 From: Jiayuan Date: Fri, 23 Jan 2026 16:15:15 +0800 Subject: [PATCH] fix: CI test failures - Add React import back in FileTreeComponent.test.tsx (required for JSX) - Fix isValidPath to recognize Windows paths on non-Windows platforms Co-Authored-By: Claude Haiku 4.5 --- src/main/utils/pathValidation.ts | 7 ++++++- tests/unit/renderer/components/FileTreeComponent.test.tsx | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/utils/pathValidation.ts b/src/main/utils/pathValidation.ts index 0bb7db000..2ea799e06 100644 --- a/src/main/utils/pathValidation.ts +++ b/src/main/utils/pathValidation.ts @@ -1,7 +1,12 @@ import * as path from 'path' +// Regex to match Windows absolute paths (e.g., C:\Users or D:\) +const WINDOWS_ABSOLUTE_PATH_REGEX = /^[a-zA-Z]:[/\\]/ + export function isValidPath(inputPath: string): boolean { - if (!path.isAbsolute(inputPath)) { + // Check for absolute path (POSIX or Windows) + const isAbsolute = path.isAbsolute(inputPath) || WINDOWS_ABSOLUTE_PATH_REGEX.test(inputPath) + if (!isAbsolute) { return false } diff --git a/tests/unit/renderer/components/FileTreeComponent.test.tsx b/tests/unit/renderer/components/FileTreeComponent.test.tsx index 1e8be18b1..6b7420bb7 100644 --- a/tests/unit/renderer/components/FileTreeComponent.test.tsx +++ b/tests/unit/renderer/components/FileTreeComponent.test.tsx @@ -1,6 +1,7 @@ /** * @vitest-environment jsdom */ +import * as React from 'react' import { act } from 'react' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { createRoot, type Root } from 'react-dom/client'