use core::num::NonZeroU32;

use bone_ui::layout::{DockState, PanelId};

fn pid(n: u32) -> PanelId {
    PanelId::new(NonZeroU32::new(n).unwrap_or(NonZeroU32::MIN))
}

fn classic_dock() -> DockState {
    let Ok(state) = DockState::classic_default(pid(1), pid(2), pid(3), pid(4), pid(5), pid(6))
    else {
        panic!("classic_default rejected distinct ids");
    };
    state
}

#[test]
fn classic_default_dock_layout_snapshot() {
    insta::assert_ron_snapshot!("dock_classic_default", classic_dock());
}

#[test]
fn classic_default_dock_round_trip_is_stable() {
    let original = classic_dock();
    let Ok(first) = ron::ser::to_string(&original) else {
        panic!("first serialize failed");
    };
    let Ok(parsed) = ron::de::from_str::<DockState>(&first) else {
        panic!("deserialize failed");
    };
    let Ok(second) = ron::ser::to_string(&parsed) else {
        panic!("second serialize failed");
    };
    assert_eq!(first, second);
    assert_eq!(original, parsed);
}
