def test_job_attach_tty(helper: Helper) -> None:
    job_id = helper.run_job_and_wait_state(UBUNTU_IMAGE_NAME, "sh", tty=True)

    status = helper.job_info(job_id)
    assert status.container.tty

    expect = helper.pexpect(["job", "attach", job_id])
    expect.expect("========== Job is running in terminal mode =========")
    expect.sendline("\n")  # prompt may be missing after the connection.
    repl = REPLWrapper(expect, "# ", None)
    ret = repl.run_command("echo abc\n")
    assert ret.strip() == "echo abc\r\r\nabc"

    helper.kill_job(job_id)
def test_e2e_ssh_exec_tty(helper: Helper) -> None:
    command = 'bash -c "sleep 15m; false"'
    job_id = helper.run_job_and_wait_state(UBUNTU_IMAGE_NAME, command)

    expect = helper.pexpect(
        [
            "--quiet",
            "job",
            "exec",
            "--no-key-check",
            "--timeout",
            str(EXEC_TIMEOUT),
            job_id,
            "[ -t 1 ]",
        ]
    )
    assert expect.wait() == 0
    helper.kill_job(job_id, wait=False)