mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
[codex] Tighten external migration prompt tests (#18768)
## Summary - tighten the external migration prompt snapshot around stable synthetic fixture text - add focused display_description tests for relative path rewriting and plugin summaries - split the path-format assertions into smaller, easier-to-read unit tests ## Why The previous prompt snapshot was coupled to path text that came from detected migration items, which made it noisier and more brittle than necessary. This change keeps the snapshot focused on stable UI structure and moves dynamic path formatting checks into targeted unit tests. ## Validation - cargo test -p codex-tui external_agent_config_migration::tests:: - cargo test -p codex-tui external_agent_config_migration::tests::display_description_ - just fmt ## Notes Per the repo instructions, I did not rerun tests after the final `just fmt` pass.
This commit is contained in:
committed by
GitHub
Unverified
parent
2202675632
commit
6bbd710496
@@ -775,7 +775,49 @@ mod tests {
|
||||
use ratatui::layout::Rect;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn sample_plugin_details() -> codex_app_server_protocol::MigrationDetails {
|
||||
codex_app_server_protocol::MigrationDetails {
|
||||
plugins: vec![
|
||||
PluginsMigration {
|
||||
marketplace_name: "acme-tools".to_string(),
|
||||
plugin_names: vec![
|
||||
"deployer".to_string(),
|
||||
"formatter".to_string(),
|
||||
"lint".to_string(),
|
||||
],
|
||||
},
|
||||
PluginsMigration {
|
||||
marketplace_name: "team-marketplace".to_string(),
|
||||
plugin_names: vec!["asana".to_string()],
|
||||
},
|
||||
PluginsMigration {
|
||||
marketplace_name: "debug".to_string(),
|
||||
plugin_names: vec!["sample".to_string()],
|
||||
},
|
||||
PluginsMigration {
|
||||
marketplace_name: "data-tools".to_string(),
|
||||
plugin_names: vec!["warehouse".to_string()],
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn sample_project_root() -> PathBuf {
|
||||
PathBuf::from(r"C:\workspace\project")
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn sample_project_root() -> PathBuf {
|
||||
PathBuf::from("/workspace/project")
|
||||
}
|
||||
|
||||
fn sample_project_path(path: &str) -> String {
|
||||
sample_project_root().join(path).display().to_string()
|
||||
}
|
||||
|
||||
fn sample_items() -> Vec<ExternalAgentConfigMigrationItem> {
|
||||
let project_root = sample_project_root();
|
||||
vec![
|
||||
ExternalAgentConfigMigrationItem {
|
||||
item_type: ExternalAgentConfigMigrationItemType::Config,
|
||||
@@ -787,40 +829,21 @@ mod tests {
|
||||
},
|
||||
ExternalAgentConfigMigrationItem {
|
||||
item_type: ExternalAgentConfigMigrationItemType::Plugins,
|
||||
description:
|
||||
"Migrate enabled plugins from /workspace/project/.claude/settings.json"
|
||||
.to_string(),
|
||||
cwd: Some(PathBuf::from("/workspace/project")),
|
||||
details: Some(codex_app_server_protocol::MigrationDetails {
|
||||
plugins: vec![
|
||||
PluginsMigration {
|
||||
marketplace_name: "acme-tools".to_string(),
|
||||
plugin_names: vec![
|
||||
"deployer".to_string(),
|
||||
"formatter".to_string(),
|
||||
"lint".to_string(),
|
||||
],
|
||||
},
|
||||
PluginsMigration {
|
||||
marketplace_name: "team-marketplace".to_string(),
|
||||
plugin_names: vec!["asana".to_string()],
|
||||
},
|
||||
PluginsMigration {
|
||||
marketplace_name: "debug".to_string(),
|
||||
plugin_names: vec!["sample".to_string()],
|
||||
},
|
||||
PluginsMigration {
|
||||
marketplace_name: "data-tools".to_string(),
|
||||
plugin_names: vec!["warehouse".to_string()],
|
||||
},
|
||||
],
|
||||
}),
|
||||
description: format!(
|
||||
"Migrate enabled plugins from {}",
|
||||
sample_project_path(".claude/settings.json")
|
||||
),
|
||||
cwd: Some(project_root.clone()),
|
||||
details: Some(sample_plugin_details()),
|
||||
},
|
||||
ExternalAgentConfigMigrationItem {
|
||||
item_type: ExternalAgentConfigMigrationItemType::AgentsMd,
|
||||
description: "Migrate /workspace/project/CLAUDE.md to /workspace/project/AGENTS.md"
|
||||
.to_string(),
|
||||
cwd: Some(PathBuf::from("/workspace/project")),
|
||||
description: format!(
|
||||
"Migrate {} to {}",
|
||||
sample_project_path("CLAUDE.md"),
|
||||
sample_project_path("AGENTS.md")
|
||||
),
|
||||
cwd: Some(project_root),
|
||||
details: None,
|
||||
},
|
||||
]
|
||||
@@ -853,6 +876,9 @@ mod tests {
|
||||
);
|
||||
|
||||
let rendered = render_screen(&screen, /*width*/ 80, /*height*/ 21);
|
||||
#[cfg(windows)]
|
||||
assert_snapshot!("external_agent_config_migration_prompt_windows", rendered);
|
||||
#[cfg(not(windows))]
|
||||
assert_snapshot!("external_agent_config_migration_prompt", rendered);
|
||||
}
|
||||
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
---
|
||||
source: tui/src/external_agent_config_migration.rs
|
||||
expression: rendered
|
||||
---
|
||||
> External agent config detected
|
||||
We found settings from another agent that you can add to this project.
|
||||
Select what to import
|
||||
Home
|
||||
[x] Migrate /Users/alex/.claude/settings.json into /Users/alex/.codex/con…
|
||||
|
||||
Project: C:\workspace\project
|
||||
[x] Migrate enabled plugins from .claude\settings.json (4 marketplaces, 6…
|
||||
• acme-tools: deployer, formatter, +1 more
|
||||
• team-marketplace: asana
|
||||
• debug: sample
|
||||
• +1 more marketplaces
|
||||
[x] Migrate CLAUDE.md to AGENTS.md
|
||||
|
||||
Selected 3 of 3 item(s).
|
||||
1. Proceed with selected
|
||||
2. Skip for now
|
||||
3. Don't ask again
|
||||
Use ↑/↓ to move, space to toggle, 1/2/3 to choose, a/n for all/none
|
||||
Reference in New Issue
Block a user