mirror of
https://github.com/LHY0125/PathEditor.git
synced 2026-06-29 01:45:54 +08:00
bce2dc8641
E2E:
- createIpcMock 支持 overrides 参数,保持 default: throw 行为
- search-clean.spec.ts 删除 30 行内联 mock,改用 createIpcMock(overrides)
Rust:
- 新增 parse_csv_line: 支持引号包裹字段 + 双引号转义 (RFC 4180 子集)
- import_csv 改用 parse_csv_line 替代 split(',')
- 与 TS 端 parseCsvLine 逻辑对称
测试: Rust 48 → 52 (+4), Frontend 100
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
export type IpcOverrides = Partial<Record<string, unknown>>;
|
|
|
|
export function createIpcMock(overrides: IpcOverrides = {}) {
|
|
return `
|
|
window.__TAURI_INTERNALS__ = {
|
|
invoke: async (cmd, args) => {
|
|
const overrides = ${JSON.stringify(overrides)};
|
|
if (cmd in overrides) return overrides[cmd];
|
|
switch (cmd) {
|
|
case 'check_admin': return true;
|
|
case 'load_system_paths': return ['C:\\\\Windows', 'C:\\\\Program Files'];
|
|
case 'load_user_paths': return ['C:\\\\Users\\\\me\\\\AppData'];
|
|
case 'load_disabled_state': return [[], []];
|
|
case 'save_system_paths': return undefined;
|
|
case 'save_user_paths': return undefined;
|
|
case 'save_disabled_state': return undefined;
|
|
case 'backup_registry': return 'C:\\\\backup\\\\path.txt';
|
|
case 'broadcast_env_change': return undefined;
|
|
case 'validate_path': return true;
|
|
case 'expand_env_vars': return 'C:\\\\Expanded';
|
|
case 'read_text_file': return '';
|
|
case 'get_appdata_dir': return 'C:\\\\appdata';
|
|
case 'scan_conflicts': return [];
|
|
case 'scan_tools': return [];
|
|
case 'list_profiles': return [];
|
|
case 'save_profile': return undefined;
|
|
case 'load_profile': return null;
|
|
case 'delete_profile': return undefined;
|
|
case 'rename_profile': return undefined;
|
|
default: throw new Error('Unexpected invoke: ' + cmd);
|
|
}
|
|
}
|
|
};
|
|
`;
|
|
}
|