Wait for login completion in recommended plugin tests (#47828)

## Why

Login clears the recommendation cache after its RPC response, allowing thread startup to race with cache invalidation in the external login tests.

## What changed

Wait for `account/login/completed` and assert a successful notification before starting the thread. This keeps thread startup and the background refresh on the same cache generation in both variants of the recommended plugin test, with `tool_suggest` enabled and disabled.

GitOrigin-RevId: 7be46dacd947b30a28c83176dc2e3b5f730005f1
This commit is contained in:
felixxia-oai
2026-09-24 12:26:05 +00:00
committed by copyberry
parent 4083a68f88
commit b15718acfc
@@ -1,12 +1,15 @@
use anyhow::Result;
use anyhow::bail;
use app_test_support::ChatGptIdTokenClaims;
use app_test_support::TestAppServer;
use app_test_support::encode_id_token;
use app_test_support::to_response;
use app_test_support::write_mock_responses_config_toml_with_chatgpt_base_url;
use codex_app_server_protocol::AccountLoginCompletedNotification;
use codex_app_server_protocol::JSONRPCResponse;
use codex_app_server_protocol::LoginAccountResponse;
use codex_app_server_protocol::RequestId;
use codex_app_server_protocol::ServerNotification;
use codex_app_server_protocol::ThreadStartParams;
use codex_app_server_protocol::ThreadStartResponse;
use codex_app_server_protocol::TurnStartParams;
@@ -127,6 +130,26 @@ async fn recommended_plugins_after_external_login(
LoginAccountResponse::ChatgptAuthTokens {}
);
// Login clears the recommendation cache after its RPC response. Wait for completion so
// thread startup and the background refresh share the same cache generation.
let notification = timeout(
DEFAULT_READ_TIMEOUT,
app_server.read_stream_until_notification_message("account/login/completed"),
)
.await??;
let ServerNotification::AccountLoginCompleted(payload) = notification.try_into()? else {
bail!("unexpected notification")
};
assert_eq!(
payload,
AccountLoginCompletedNotification {
login_id: None,
success: true,
error: None,
onboarding_entrypoint: None,
}
);
let thread_id = app_server
.send_thread_start_request_with_auto_env(ThreadStartParams {
model: Some("mock-model".to_string()),