//! L10 DTO tests: `move_tab_to_new_window` result mapping + tab-id parsing.

use app_tauri_lib::dto::{parse_tab_id, MoveTabResultDto};
use application::MoveTabToNewWindowOutput;
use domain::ids::WindowId;
use domain::layout::Workspace;
use uuid::Uuid;

#[test]
fn move_tab_result_serializes_new_window_id_camel_case() {
    let out = MoveTabToNewWindowOutput {
        new_window_id: WindowId::from_uuid(Uuid::from_u128(42)),
        workspace: Workspace::default(),
    };
    let dto = MoveTabResultDto::from(out);
    let json = serde_json::to_string(&dto).unwrap();
    assert!(json.contains("\"newWindowId\""), "json was {json}");
    assert!(
        !json.contains("new_window_id"),
        "no snake_case leak: {json}"
    );
}

#[test]
fn parse_tab_id_accepts_uuid_and_rejects_garbage() {
    let uuid = Uuid::from_u128(7).to_string();
    assert!(parse_tab_id(&uuid).is_ok());

    let err = parse_tab_id("not-a-uuid").unwrap_err();
    assert_eq!(err.code, "INVALID");
}
