//! Contract tests for server install-time operational defaults.
//!
//! Scope: statically guard the generated `/etc/lesavka/server.env` values.
//! Targets: `scripts/install/server.sh`.
//! Why: HDMI capture adapter settings should be reproducible after reboot or
//! reinstall instead of living as one-off shell state.

const SERVER_INSTALL: &str = include_str!("../../scripts/install/server.sh");

#[test]
fn server_install_pins_hdmi_camera_and_display_defaults() {
    for expected in [
        "LESAVKA_CAM_OUTPUT=%s",
        "LESAVKA_CAM_WIDTH=%s",
        "LESAVKA_CAM_HEIGHT=%s",
        "LESAVKA_CAM_FPS=%s",
        "LESAVKA_HDMI_WIDTH=%s",
        "LESAVKA_HDMI_HEIGHT=%s",
        "LESAVKA_HDMI_SINK=%s",
        "LESAVKA_HDMI_FBDEV=%s",
    ] {
        assert!(
            SERVER_INSTALL.contains(expected),
            "install script should emit {expected}"
        );
    }
    assert!(SERVER_INSTALL.contains("${LESAVKA_CAM_WIDTH:-1920}"));
    assert!(SERVER_INSTALL.contains("${LESAVKA_CAM_HEIGHT:-1080}"));
    assert!(SERVER_INSTALL.contains("${LESAVKA_CAM_FPS:-30}"));
    assert!(SERVER_INSTALL.contains("${LESAVKA_HDMI_WIDTH:-1920}"));
    assert!(SERVER_INSTALL.contains("${LESAVKA_HDMI_HEIGHT:-1080}"));
    assert!(SERVER_INSTALL.contains("${LESAVKA_HDMI_SINK:-fbdevsink}"));
}

#[test]
fn server_install_keeps_uac_sanity_helper_available() {
    assert!(
        SERVER_INSTALL.contains("run_uac_output_sanity.sh"),
        "install script should ship the root UAC sanity helper"
    );
    assert!(
        SERVER_INSTALL.contains("/usr/local/bin/lesavka-uac-sanity"),
        "install script should install the UAC sanity helper to a stable path"
    );
}
