use crate::commands::install::{install_to_with, test_content, test_roster};
#[test]
fn install_skill_step_preserves_user_tier_override() {
let dir = tempfile::tempdir().unwrap();
let paths = trusty_mpm::core::paths::FrameworkPaths::under(dir.path());
install_to_with(&paths, false, &test_roster(), &test_content()).unwrap();
let user_source = paths.user_skill_source_dir();
std::fs::create_dir_all(&user_source).unwrap();
std::fs::write(
user_source.join("tm-doctor.md"),
"---\nname: tm-doctor\n---\n\nUSER OVERRIDE BODY\n",
)
.unwrap();
trusty_mpm::core::skill_tiers::deploy_all_skill_tiers(
&paths.skill_source_dir(),
&paths.user_skill_source_dir(),
&paths.claude_skills_dir(),
|_| true,
)
.unwrap();
let deployed_path = paths.claude_skills_dir().join("tm-doctor").join("SKILL.md");
let after_launch = std::fs::read_to_string(&deployed_path).unwrap();
assert!(
after_launch.contains("USER OVERRIDE BODY"),
"user tier must win at launch: {after_launch}"
);
trusty_mpm::core::skill_tiers::deploy_all_skill_tiers(
&paths.skill_source_dir(),
&paths.user_skill_source_dir(),
&paths.claude_skills_dir(),
|_| true,
)
.unwrap();
let after_install = std::fs::read_to_string(&deployed_path).unwrap();
assert_eq!(
after_install, after_launch,
"tm install must preserve the user-tier override byte-identical"
);
assert!(
after_install.contains("USER OVERRIDE BODY"),
"override must survive install: {after_install}"
);
}