use crate::SettingsLayer;

#[test]
fn resolves_project_defaults_from_empty_settings() {
    let settings = SettingsLayer::default();

    let project = super::workflow_settings_from_layer(settings)
        .expect("empty settings should resolve")
        .project;

    let json = serde_json::to_value(&project).expect("project settings should serialize");
    assert!(
        json.get("directory").is_none(),
        "resolved project settings should not expose deprecated directory"
    );
    assert!(project.name.is_none());
    assert!(project.description.is_none());
    assert!(project.metadata.is_empty());
}

#[test]
fn resolves_project_metadata_and_ignores_deprecated_directory() {
    let project = super::workflow_settings_from_toml(
        r#"
_version = 1

[project]
name = "Acme"
description = "Automation"
directory = ".fabro"

[project.metadata]
team = "platform"
"#,
    )
    .expect("project settings should resolve")
    .project;

    assert_eq!(project.name.as_deref(), Some("Acme"));
    assert_eq!(project.description.as_deref(), Some("Automation"));
    let json = serde_json::to_value(&project).expect("project settings should serialize");
    assert!(
        json.get("directory").is_none(),
        "resolved project settings should not expose deprecated directory"
    );
    assert_eq!(
        project.metadata.get("team").map(String::as_str),
        Some("platform")
    );
}
