refactor(backend): phase 3 - expand integration tests for Codex and MCP sync

Expand test suite from 3 to 11 integration tests, adding comprehensive coverage
for Codex dual-file atomicity and bidirectional MCP synchronization:

New Codex sync tests:
- sync_codex_provider_writes_auth_and_config: validates atomic write of auth.json
  and config.toml, plus SSOT backfill of latest toml content
- sync_enabled_to_codex_writes_enabled_servers: MCP projection to config.toml
- sync_enabled_to_codex_removes_servers_when_none_enabled: cleanup when all disabled
- sync_enabled_to_codex_returns_error_on_invalid_toml: error handling for malformed TOML

New Codex MCP import tests:
- import_from_codex_adds_servers_from_mcp_servers_table: imports new servers from live config
- import_from_codex_merges_into_existing_entries: smart merge preserving SSOT server configs

New Claude MCP tests:
- sync_claude_enabled_mcp_projects_to_user_config: enabled/disabled filtering for .claude.json
- import_from_claude_merges_into_config: intelligent merge preserving existing configurations

Expand lib.rs API exports:
- Codex paths: get_codex_auth_path, get_codex_config_path
- Claude MCP: get_claude_mcp_path
- MCP sync: sync_enabled_to_claude, sync_enabled_to_codex
- MCP import: import_from_claude, import_from_codex
- Error type: AppError (for test assertions)

Test infrastructure improvements:
- Enhanced reset_test_fs() to clean .claude.json
- All tests use isolated HOME directory with sequential execution via mutex

Test results: 11/11 passed
Files changed: 3 (+394/-6 lines)

Next steps: Command layer integration tests and error recovery scenarios
This commit is contained in:
Jason
2025-10-27 23:26:42 +08:00
parent 6a9aa7aeb5
commit 10abdfa096
3 changed files with 394 additions and 6 deletions

View File

@@ -16,10 +16,13 @@ mod store;
mod usage_script;
pub use app_config::{AppType, MultiAppConfig};
pub use config::{get_claude_settings_path, read_json_file};
pub use codex_config::{get_codex_auth_path, get_codex_config_path};
pub use config::{get_claude_mcp_path, get_claude_settings_path, read_json_file};
pub use import_export::{create_backup, sync_current_providers_to_live};
pub use provider::Provider;
pub use settings::{update_settings, AppSettings};
pub use mcp::{import_from_claude, import_from_codex, sync_enabled_to_claude, sync_enabled_to_codex};
pub use error::AppError;
use store::AppState;
use tauri::{
@@ -30,8 +33,6 @@ use tauri::{
use tauri::{ActivationPolicy, RunEvent};
use tauri::{Emitter, Manager};
use crate::error::AppError;
/// 创建动态托盘菜单
fn create_tray_menu(
app: &tauri::AppHandle,