Files
zed/crates/project/tests/integration/agent_registry_store.rs
Mohamad Khani b72a46db68
Some checks failed
Update All Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Triage Project Sync (#84) / Sync triage project (push) Has been cancelled
release_nightly / notify_on_failure (push) Has been cancelled
release_nightly / check_style (push) Has been cancelled
release_nightly / run_tests_windows (push) Has been cancelled
release_nightly / clippy_windows (push) Has been cancelled
release_nightly / bundle_linux_aarch64 (push) Has been cancelled
release_nightly / bundle_linux_x86_64 (push) Has been cancelled
release_nightly / bundle_mac_aarch64 (push) Has been cancelled
release_nightly / bundle_mac_x86_64 (push) Has been cancelled
release_nightly / bundle_windows_aarch64 (push) Has been cancelled
release_nightly / bundle_windows_x86_64 (push) Has been cancelled
release_nightly / build_nix_linux_x86_64 (push) Has been cancelled
release_nightly / build_nix_mac_aarch64 (push) Has been cancelled
release_nightly / update_nightly_tag (push) Has been cancelled
Hotfix Review Monitor / check-hotfix-reviews (push) Has been cancelled
Stale PR Review Reminder / check-stale-prs (push) Has been cancelled
Update Weekly Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Bump collab-staging Tag / update-collab-staging-tag (push) Has been cancelled
compliance_check / scheduled_compliance_check (push) Has been cancelled
logiguard fork: GPUI xdg-activation keyboard-focus serial fix
Single-commit orphan branch: full zed-industries/zed @ 8c74db0 source tree
with a 3-file patch applied (no upstream history).

Patch (crates/gpui_linux/src/linux/wayland/):
  - serial.rs: add SerialKind::KeyboardEnter
  - client.rs: store wl_keyboard.enter serial; add latest_serial_of()
  - window.rs: activate() uses keyboard-enter serial (Mutter focus gate)

Mutter honors window activation only when the token carries the keyboard-
focus serial from wl_keyboard.enter; GPUI used a stale mouse-press serial.
See docs/tray-window-focus-wayland.md in logiguard.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 02:22:17 +03:30

116 lines
4.3 KiB
Rust

use std::{future, sync::Arc, time::Duration};
use fs::FakeFs;
use gpui::TestAppContext;
use http_client::{AsyncBody, FakeHttpClient, HttpClient, Response};
use project::AgentRegistryStore;
use serde_json::json;
use crate::init_test;
#[gpui::test]
async fn registry_refresh_times_out_when_fetch_never_completes(cx: &mut TestAppContext) {
init_test(cx);
let fs = FakeFs::new(cx.executor());
let http_client =
FakeHttpClient::create(|_| future::pending::<anyhow::Result<Response<AsyncBody>>>())
as Arc<dyn HttpClient>;
let registry_store =
cx.update(|cx| AgentRegistryStore::init_global(cx, fs.clone(), http_client));
cx.run_until_parked();
cx.executor().advance_clock(Duration::from_secs(31));
cx.run_until_parked();
registry_store.update(cx, |store, _| {
assert!(!store.is_fetching());
assert!(
store
.fetch_error()
.is_some_and(|error| error.contains("timed out after 30s")),
"expected registry fetch timeout error, got {:?}",
store.fetch_error()
);
});
}
#[gpui::test]
async fn registry_refresh_does_not_block_sequentially_on_hung_icon_downloads(
cx: &mut TestAppContext,
) {
init_test(cx);
let fs = FakeFs::new(cx.executor());
let http_client = FakeHttpClient::create(|request| async move {
if request.uri().to_string().contains("registry.json") {
Ok(Response::builder()
.status(200)
.body(AsyncBody::from(
serde_json::to_string(&json!({
"version": "1",
"agents": [
{
"id": "slow-icon-a",
"name": "Slow Icon A",
"version": "1.0.0",
"description": "An agent with a slow icon.",
"icon": "https://example.test/slow-icon-a.svg",
"distribution": {
"npx": {
"package": "slow-icon-a"
}
}
},
{
"id": "slow-icon-b",
"name": "Slow Icon B",
"version": "1.0.0",
"description": "Another agent with a slow icon.",
"icon": "https://example.test/slow-icon-b.svg",
"distribution": {
"npx": {
"package": "slow-icon-b"
}
}
},
{
"id": "slow-icon-c",
"name": "Slow Icon C",
"version": "1.0.0",
"description": "A third agent with a slow icon.",
"icon": "https://example.test/slow-icon-c.svg",
"distribution": {
"npx": {
"package": "slow-icon-c"
}
}
}
]
}))
.unwrap(),
))
.unwrap())
} else {
future::pending::<anyhow::Result<Response<AsyncBody>>>().await
}
}) as Arc<dyn HttpClient>;
let registry_store =
cx.update(|cx| AgentRegistryStore::init_global(cx, fs.clone(), http_client));
cx.run_until_parked();
cx.executor().advance_clock(Duration::from_secs(11));
cx.run_until_parked();
registry_store.update(cx, |store, _| {
assert!(!store.is_fetching());
assert_eq!(store.agents().len(), 3);
assert_eq!(store.agents()[0].id().as_ref(), "slow-icon-a");
assert_eq!(store.agents()[1].id().as_ref(), "slow-icon-b");
assert_eq!(store.agents()[2].id().as_ref(), "slow-icon-c");
assert_eq!(store.fetch_error(), None);
});
}