Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

Tests: fix two timing flakes on main (mission control release, Dev mode switch) (#327)

Oleksandr Ivanchenko9abb184c97e9
diff --git a/frontend/tests/devMode.test.mjs b/frontend/tests/devMode.test.mjs
index bc22e1c9..5c20ccb7 100644
--- a/frontend/tests/devMode.test.mjs
+++ b/frontend/tests/devMode.test.mjs
@@ -302,7 +302,9 @@ test('DOM: on → off with two presses saves PUT {on:false}, announces, and call
);
assert.match(host.querySelector('[data-dv-live]').textContent, /Dev mode off for Demo/);
assert.equal(turnedOff, 1);
- await wait(m.SETTLE_MS + 30);
+ // The settle timer fires after SETTLE_MS; a busy CI runner can run it late, so poll for it
+ await wait(m.SETTLE_MS);
+ for (let i = 0; i < 100 && b.dataset.devSwitch !== 'covered'; i++) await wait(20);
assert.equal(b.dataset.devSwitch, 'covered');
assert.equal(b.dataset.on, undefined);
await click(b); // a render mid-save once left the switch stuck; the next press still lifts
diff --git a/tests/mission_control_test.rs b/tests/mission_control_test.rs
index 33863fdd..878c4cce 100644
--- a/tests/mission_control_test.rs
+++ b/tests/mission_control_test.rs
@@ -432,13 +432,15 @@ async fn the_run_hook_starts_one_turn_per_mission_and_releases_an_unfinished_tas
assert_eq!(out["started"][0]["kwant_id"], e.bot.id.as_str());
let (status, _) = call(&e.app, "POST", &format!("/api/missions/{}/run", id(&m)), None, Some(json!({"max_tasks": 9}))).await;
assert_eq!(status, StatusCode::BAD_REQUEST);
- // No engine is set up here, so the turn ends without a review: the lease is let go
+ // No engine is set up here, so the turn ends without a review: the lease is let go.
+ // GET /api/tasks/:id reads the task row before its events, so a release committed in between
+ // shows the event on a row still `working` with 0 attempts: wait for the row to show it too
let mut released = false;
for _ in 0..100 {
let t = task(&e, &tid).await;
- if t["events"].as_array().unwrap().iter().any(|ev| ev["kind"] == "released") {
- assert_eq!(t["task"]["attempts"], 1);
- assert_ne!(t["task"]["state"], "working");
+ let event = t["events"].as_array().unwrap().iter().any(|ev| ev["kind"] == "released");
+ if event && t["task"]["state"] != "working" {
+ assert_eq!(t["task"]["attempts"], 1, "{t}");
released = true;
break;
}