zero-cli 2.6.0

A command line tool for Zero Secrets Manager
use rexpect::error::Error;
use rexpect::spawn;

#[test]
fn test_teams_create() -> Result<(), Error> {
    let mut p = spawn("./target/debug/zero-cli teams create", Some(15000))?;
    p.exp_string("Type a name for the team")?;
    p.send_line("tested team")?;
    p.exp_string("Team link")?;
    p.exp_string("Team ID")?;
    Ok(())
}

#[test]
fn test_teams_delete() -> Result<(), Error> {
    let mut p = spawn(
        "./target/debug/zero-cli teams delete --id 1cae",
        Some(15000),
    )?;

    p.exp_string("Type 1cae to confirm deletion")?;
    p.send_line("1cae")?;
    p.exp_string("Team successfully deleted")?;
    Ok(())
}

#[test]
fn test_teams_edit() -> Result<(), Error> {
    let mut p = spawn("./target/debug/zero-cli teams edit --id 2cae", Some(15000))?;
    p.exp_string("Type a new team name")?;
    p.send_line("update team name")?;
    p.exp_string("Type a new team description")?;
    p.send_line("update team description")?;
    p.exp_string("The team has been successfully updated")?;
    Ok(())
}

#[test]
fn test_teams_leave() -> Result<(), Error> {
    let mut p = spawn("./target/debug/zero-cli teams leave --id 4cae", Some(15000))?;
    p.exp_string("Type 4cae to confirm leaving the team")?;
    p.send_line("4cae")?;
    p.exp_string("You have successfully left")?;
    Ok(())
}

#[test]
fn test_teams_list_my() -> Result<(), Error> {
    let mut p = spawn("./target/debug/zero-cli teams list", Some(15000))?;
    p.exp_string("Show teams from")?;
    p.exp_string("My Teams")?;
    p.send_line("")?;
    p.exp_string("Personal projects")?;
    Ok(())
}

#[test]
fn test_teams_list_shared() -> Result<(), Error> {
    let mut p = spawn("./target/debug/zero-cli teams list", Some(15000))?;
    p.exp_string("Show teams from")?;
    p.exp_string("Shared Teams")?;
    p.send("\x1B[B")?;
    p.send_line("")?;
    p.exp_string("You don't have any teams yet.")?;
    Ok(())
}

#[test]
fn test_teams_view() -> Result<(), Error> {
    let mut p = spawn("./target/debug/zero-cli teams view --id 3cae", Some(15000))?;
    p.exp_string("URL")?;
    p.exp_string("Personal projects")?;
    p.exp_string("Owner")?;
    p.exp_string("Members")?;
    Ok(())
}

#[test]
fn test_teams_user_invite() -> Result<(), Error> {
    let mut p = spawn(
        "./target/debug/zero-cli teams user invite --email test@test.com --id 2cae",
        Some(15000),
    )?;

    p.exp_string("The invitation was successfully sent to the user. test@test.com")?;
    Ok(())
}

#[test]
fn test_teams_user_remove() -> Result<(), Error> {
    let mut p = spawn(
        "./target/debug/zero-cli teams user remove --id 2cae --user-id d541",
        Some(15000),
    )?;

    p.exp_string("Type 2cae to confirm deletion")?;
    p.send_line("2cae")?;
    p.exp_string("User successfully removed from the team")?;
    Ok(())
}