添加 Playwright E2E 测试及构建修复
- 修复 vite.config.mjs base 路径为 "./" 解决 file:// 协议加载失败 - 添加测试专用 mockDialog IPC 绕过原生文件选择对话框 - 重建 better-sqlite3 以适配 Electron 内嵌 Node ABI - 新增 6 个 E2E 测试:模板增删改、批量生成、文件解析 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
fcf3d5c7c2
commit
9738d2cd67
@@ -55,12 +55,19 @@ ipcMain.handle("template:parse", async (_, filePath) => {
|
||||
return callPython({ action: "parse_template", file_path: filePath });
|
||||
});
|
||||
|
||||
let _mockDialogPath = null;
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
ipcMain.handle("test:mockDialog", (_, p) => { _mockDialogPath = p; });
|
||||
}
|
||||
|
||||
ipcMain.handle("file:select", async (_, filters = []) => {
|
||||
if (_mockDialogPath) { const p = _mockDialogPath; _mockDialogPath = null; return p; }
|
||||
const result = await dialog.showOpenDialog({ filters, properties: ["openFile"] });
|
||||
return result.canceled ? null : result.filePaths[0];
|
||||
});
|
||||
|
||||
ipcMain.handle("file:selectDir", async () => {
|
||||
if (_mockDialogPath) { const p = _mockDialogPath; _mockDialogPath = null; return p; }
|
||||
const result = await dialog.showOpenDialog({ properties: ["openDirectory"] });
|
||||
return result.canceled ? null : result.filePaths[0];
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user