Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

test(pa-cli): remove login tests that open real browser windows (#3286)

Seth Kartencca05169d2e6
diff --git a/crates/pa-cli/src/codex_subscription_login.rs b/crates/pa-cli/src/codex_subscription_login.rs
index 33d59bbf67..9bda9fe61a 100644
--- a/crates/pa-cli/src/codex_subscription_login.rs
+++ b/crates/pa-cli/src/codex_subscription_login.rs
@@ -133,7 +133,6 @@ mod tests {
use super::*;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
- use std::time::Duration;
use pa_ai::oauth::CodexHttpResponse;
@@ -387,72 +386,4 @@ mod tests {
Some(account_jwt("acct-2"))
);
}
-
- #[tokio::test]
- async fn the_panel_surface_mounts_the_ts_prompts() {
- // The panel adapter's seam: on_auth renders the url block, the
- // manual paste mounts with the TS prompt, and the fallback
- // prompt passes the flow's message. The paste/prompt futures
- // are LAZY (the request sends on first poll), so the test
- // spawns them and reads the requests off the channel's
- // receiving side, bounded by a recv timeout that fails the
- // test — never a green-on-timeout retry.
- let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();
- let panel = AuthPanelHandle::new(tx);
- let ui = PanelCodexLoginUi::new(panel);
- ui.on_auth("https://auth.example/authorize", "Open your browser.");
- // The url block sends immediately (a plain request, not a
- // future).
- let url_request = rx.recv().await.expect("the url block sends");
- let pa_tui::auth_panel::AuthPanelRequest::AuthUrl { url, instructions } = url_request
- else {
- panic!("expected the url block request")
- };
- assert_eq!(url, "https://auth.example/authorize");
- assert_eq!(instructions.as_deref(), Some("Open your browser."));
-
- // The manual paste: spawned (the boxed future sends its
- // PastePrompt on first poll, then pends on the answer this test
- // never gives).
- let manual = ui
- .on_manual_code_input()
- .expect("the panel supplies the paste");
- let manual_task = tokio::spawn(async move {
- let _ = manual.await;
- });
- let paste_request = tokio::time::timeout(Duration::from_secs(2), rx.recv())
- .await
- .expect("the paste request sends once polled")
- .expect("the channel stays open");
- let pa_tui::auth_panel::AuthPanelRequest::PastePrompt { prompt, .. } = paste_request else {
- panic!("expected the paste request")
- };
- assert_eq!(
- prompt,
- "Paste redirect URL below, or complete login in browser:"
- );
-
- // The fallback prompt carries the flow's own message.
- let prompt = ui.on_prompt("Paste the authorization code (or full redirect URL):");
- let prompt_task = tokio::spawn(async move {
- let _ = prompt.await;
- });
- let prompt_request = tokio::time::timeout(Duration::from_secs(2), rx.recv())
- .await
- .expect("the prompt request sends once polled")
- .expect("the channel stays open");
- let pa_tui::auth_panel::AuthPanelRequest::PastePrompt { prompt, .. } = prompt_request
- else {
- panic!("expected the prompt request")
- };
- assert_eq!(
- prompt,
- "Paste the authorization code (or full redirect URL):"
- );
-
- // The pending paste/prompt tasks are dropped: no answer is
- // expected (the test never mounts the panel).
- manual_task.abort();
- prompt_task.abort();
- }
}
diff --git a/crates/pa-cli/src/subscription_login.rs b/crates/pa-cli/src/subscription_login.rs
index f90f01b693..a3273bcba9 100644
--- a/crates/pa-cli/src/subscription_login.rs
+++ b/crates/pa-cli/src/subscription_login.rs
@@ -648,120 +648,4 @@ mod tests {
);
assert_eq!(expired.get_api_key("xai"), Some("grok-access".to_string()));
}
-
- #[tokio::test]
- async fn the_panel_surface_mounts_the_ts_prompts() {
- // The panel adapter's seam: on_auth renders the url block (the
- // Copilot provider adds its waiting line), the placeholder rides
- // the prompt as TS's example line, and the allow-empty prompt
- // keeps its blank answer. The url block sends immediately (a
- // plain request); the paste/prompt futures are LAZY (the request
- // sends on first poll), so the test spawns them and reads the
- // requests off the channel's receiving side, bounded by a recv
- // timeout that fails the test — never a green-on-timeout retry.
- // The prompt futures borrow their adapter, so they drive on a
- // select instead of a spawned 'static task (the first poll sends
- // the request; the pending future drops with this scope).
- let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();
- let panel = AuthPanelHandle::new(tx);
- let copilot = PanelSubscriptionLoginUi::new(panel, "github-copilot");
- copilot.on_auth(
- "https://github.com/login/device",
- Some("Enter code: ABCD-1234"),
- );
- let url_request = rx.recv().await.expect("the url block sends");
- match url_request {
- pa_tui::auth_panel::AuthPanelRequest::AuthUrl { url, instructions } => {
- assert_eq!(url, "https://github.com/login/device");
- assert_eq!(instructions.as_deref(), Some("Enter code: ABCD-1234"));
- }
- _ => panic!("expected the url block request"),
- }
- // TS `showWaiting` for the Copilot device flow: the dialog's own
- // method, on every surface — never the `onProgress` chatter arm.
- let waiting = rx.recv().await.expect("the waiting line sends");
- match waiting {
- pa_tui::auth_panel::AuthPanelRequest::Waiting { message } => {
- assert_eq!(message, "Waiting for browser authentication...");
- }
- _ => panic!("expected the waiting line request"),
- }
- // The domain prompt: the boxed future sends its PastePrompt on
- // first poll, then pends on the answer this test never gives.
- let mut domain = copilot.on_prompt(&OAuthPrompt {
- message: "GitHub Enterprise URL/domain (blank for github.com)".to_string(),
- placeholder: Some("company.ghe.com".to_string()),
- allow_empty: true,
- });
- let prompt_request = tokio::time::timeout(std::time::Duration::from_secs(2), async {
- tokio::select! {
- request = rx.recv() => request.expect("the channel stays open"),
- _ = &mut domain => {
- panic!("the prompt future settled without an answer")
- }
- }
- })
- .await
- .expect("the prompt request sends once polled");
- match prompt_request {
- // TS `showPrompt` renders the placeholder as an example.
- pa_tui::auth_panel::AuthPanelRequest::PastePrompt {
- prompt,
- allow_empty,
- ..
- } => {
- assert_eq!(
- prompt,
- "GitHub Enterprise URL/domain (blank for github.com) (e.g. company.ghe.com)"
- );
- assert!(allow_empty, "the blank entry is the valid default");
- }
- _ => panic!("expected the paste prompt request"),
- }
- // The pending prompt future drops with this scope: no answer is
- // expected (the test never mounts the panel).
-
- // The Anthropic adapter renders the url block without the
- // waiting line and arms the TS manual paste.
- let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();
- let panel = AuthPanelHandle::new(tx);
- let anthropic = PanelSubscriptionLoginUi::new(panel, "anthropic");
- anthropic.on_auth(
- "https://claude.ai/oauth/authorize",
- Some("Complete login in your browser."),
- );
- let url_request = rx.recv().await.expect("the url block sends");
- match url_request {
- pa_tui::auth_panel::AuthPanelRequest::AuthUrl { url, instructions } => {
- assert_eq!(url, "https://claude.ai/oauth/authorize");
- assert_eq!(
- instructions.as_deref(),
- Some("Complete login in your browser.")
- );
- }
- _ => panic!("expected the url block request"),
- }
- let mut manual = anthropic
- .on_manual_code_input()
- .expect("the panel supplies the paste");
- let paste_request = tokio::time::timeout(std::time::Duration::from_secs(2), async {
- tokio::select! {
- request = rx.recv() => request.expect("the channel stays open"),
- _ = &mut manual => {
- panic!("the paste future settled without an answer")
- }
- }
- })
- .await
- .expect("the paste request sends once polled");
- match paste_request {
- pa_tui::auth_panel::AuthPanelRequest::PastePrompt { prompt, .. } => {
- assert_eq!(
- prompt,
- "Paste redirect URL below, or complete login in browser:"
- );
- }
- _ => panic!("expected the paste request"),
- }
- }
}