Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(e2e): address review — panic-safe stall guard, tighter bounds, fresh-bearer proof

M3gA-Mind0a3f6d6268c8
diff --git a/app/test/playwright/specs/core-rpc-bearer-401.spec.ts b/app/test/playwright/specs/core-rpc-bearer-401.spec.ts
index 66080114c7..ffa05ef6e2 100644
--- a/app/test/playwright/specs/core-rpc-bearer-401.spec.ts
+++ b/app/test/playwright/specs/core-rpc-bearer-401.spec.ts
@@ -40,10 +40,14 @@ test.describe('Core RPC bearer 401 — recovery, not logout', () => {
await waitForAppReady(page);
await dismissWalkthroughIfPresent(page);
- // Fault injection: reject the bearer for the FIRST occurrence of the
- // trigger method only, exactly as a core that restarted mid-session would,
- // then serve normally so the refreshed-bearer retry can succeed.
- let seen = 0;
+ // Fault injection modelled on a real core restart: the FIRST call to the
+ // trigger method is rejected AND the stored bearer is rotated, exactly as a
+ // core that restarted and minted a fresh per-launch token would leave
+ // things. The retry must therefore present a DIFFERENT bearer to succeed —
+ // counting requests alone would let a retry that reused the stale cached
+ // token pass, which is the very regression #5876 guards against.
+ const ROTATED = 'openhuman-playwright-token-rotated';
+ const seenAuth: string[] = [];
await page.route('**/rpc', async (route, request) => {
let body: { method?: string } = {};
try {
@@ -52,8 +56,14 @@ test.describe('Core RPC bearer 401 — recovery, not logout', () => {
/* not JSON — pass through */
}
if (body.method === TRIGGER_METHOD) {
- seen += 1;
- if (seen === 1) {
+ seenAuth.push(request.headers()['authorization'] ?? '');
+ if (seenAuth.length === 1) {
+ // Rotate the stored bearer before rejecting, so a refreshed read
+ // picks up the new value and a cached read does not.
+ await page.evaluate(
+ token => window.localStorage.setItem('openhuman_core_rpc_token', token),
+ ROTATED
+ );
return route.fulfill({
status: 401,
contentType: 'text/plain',
@@ -69,27 +79,29 @@ test.describe('Core RPC bearer 401 — recovery, not logout', () => {
window.location.hash = '/connections?tab=embeddings';
});
- // (1) The retry. `core_auth` drops the token cache and reissues the SAME
- // call once. Without #5876 the 401 classifies as `auth_expired`, nothing
- // retries, and this stays at 1.
- await expect.poll(() => seen, { timeout: 20_000 }).toBeGreaterThanOrEqual(2);
+ // (1) The retry happened at all. Without #5876 the 401 classifies as
+ // `auth_expired`, nothing retries, and this stays at 1.
+ await expect.poll(() => seenAuth.length, { timeout: 20_000 }).toBeGreaterThanOrEqual(2);
+
+ // (2) And it used a FRESH bearer — the assertion that distinguishes a real
+ // recovery from a blind re-send. `clearCoreRpcTokenCache()` is what makes
+ // the second read see the rotated value.
+ expect(seenAuth[0]).toContain('openhuman-playwright-token');
+ expect(seenAuth[1]).toContain(ROTATED);
+ expect(seenAuth[1]).not.toEqual(seenAuth[0]);
// Bounded to a single extra attempt — a retry loop against a core that is
// genuinely rejecting us would be worse than the bug.
- expect(seen).toBeLessThanOrEqual(2);
+ expect(seenAuth.length).toBeLessThanOrEqual(2);
- // (2) The session survives. Without #5876 `clearSession()` wipes the auth
- // profile and the app falls back to the signed-out surface.
- await expect
- .poll(async () => page.evaluate(() => window.location.hash), { timeout: 15_000 })
- .toContain('/connections');
- await expect
- .poll(async () => page.evaluate(() => window.location.hash))
- .not.toContain('/welcome');
- await expect
- .poll(async () =>
- page.evaluate(() => window.localStorage.getItem('openhuman_core_rpc_token'))
- )
- .not.toBeNull();
+ // (3) The session survives. Without #5876 `clearSession()` wipes the auth
+ // profile and the app falls back to the signed-out surface. Assert the
+ // embeddings panel actually rendered rather than merely that the hash is
+ // unchanged — the page was already on /connections before the fault.
+ await expect(page.getByTestId('two-pane-nav-embeddings')).toHaveAttribute(
+ 'aria-current',
+ 'page',
+ { timeout: 20_000 }
+ );
});
});
diff --git a/app/test/playwright/specs/embeddings-setup-modal.spec.ts b/app/test/playwright/specs/embeddings-setup-modal.spec.ts
index 1b51dc598c..dfc2888621 100644
--- a/app/test/playwright/specs/embeddings-setup-modal.spec.ts
+++ b/app/test/playwright/specs/embeddings-setup-modal.spec.ts
@@ -87,7 +87,11 @@ test.describe('Embeddings setup — Test connection for a custom endpoint', () =
// Empty key → disabled by the `!setupKey.trim()` arm, not by `isCustom`.
await expect(testButton).toBeDisabled();
- const keyField = page.getByRole('textbox').first();
+ // Located by placeholder, not by the `textbox` role: `setupShowKey` starts
+ // false so the field renders as `<input type="password">`, which has no
+ // implicit textbox role and would never match.
+ const keyField = page.getByPlaceholder('Paste your API key…');
+ await expect(keyField).toBeVisible();
await keyField.fill('sk-not-a-real-key-0000000000');
await expect(testButton).toBeEnabled();
});
diff --git a/tests/agent_harness_e2e.rs b/tests/agent_harness_e2e.rs
index 0d2fe80269..dc0c439e93 100644
--- a/tests/agent_harness_e2e.rs
+++ b/tests/agent_harness_e2e.rs
@@ -184,12 +184,25 @@ fn error_completion(status: u16, message: &str) -> Value {
/// instantly by the default completion, hiding the timeout.
static SCRIPTED_STALL_MS: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
-fn arm_scripted_stall(ms: u64) {
- SCRIPTED_STALL_MS.store(ms, std::sync::atomic::Ordering::SeqCst);
+/// Arms the stall and disarms it on drop.
+///
+/// The guard exists because the atomic is process-global and the env lock is
+/// deliberately recovered from poisoning: if a test panicked between arming and
+/// a bare `disarm`, every later test sharing this scripted handler would inherit
+/// a 25s delay on every completion, turning one failure into a cascade of
+/// unrelated timeouts.
+struct ScriptedStallGuard;
+
+impl Drop for ScriptedStallGuard {
+ fn drop(&mut self) {
+ SCRIPTED_STALL_MS.store(0, std::sync::atomic::Ordering::SeqCst);
+ }
}
-fn disarm_scripted_stall() {
- SCRIPTED_STALL_MS.store(0, std::sync::atomic::Ordering::SeqCst);
+#[must_use = "the stall is disarmed when the guard drops; binding it to `_` disarms it immediately"]
+fn arm_scripted_stall(ms: u64) -> ScriptedStallGuard {
+ SCRIPTED_STALL_MS.store(ms, std::sync::atomic::Ordering::SeqCst);
+ ScriptedStallGuard
}
static CANARY_BARRIER: OnceLock<Mutex<Vec<String>>> = OnceLock::new();
@@ -3107,7 +3120,7 @@ async fn model_call_ceiling_bounds_a_wedged_call_below_the_turn_deadline_inner()
// Every upstream reply is held for 25s — comfortably past the 2s per-call
// ceiling and comfortably short of the 600s turn deadline. Armed globally
// so retry attempts stall too.
- arm_scripted_stall(25_000);
+ let _stall = arm_scripted_stall(25_000);
reset_script(vec![text_completion(
"this reply is never delivered in time",
)]);
@@ -3135,7 +3148,6 @@ async fn model_call_ceiling_bounds_a_wedged_call_below_the_turn_deadline_inner()
// per-call ceiling were not in force.
let terminal = wait_for_terminal(&mut events, Duration::from_secs(120)).await;
let elapsed = started.elapsed();
- disarm_scripted_stall();
// The turn is stopped rather than completing.
assert_eq!(
@@ -3154,8 +3166,12 @@ async fn model_call_ceiling_bounds_a_wedged_call_below_the_turn_deadline_inner()
// — the pre-#5767 behaviour — that stall completes well inside the 600s
// budget and the turn SUCCEEDS. Only a per-call ceiling can stop it at ~2s.
// Measured: 2.4s with the ceiling wired, 25.5s with it reverted.
+ // 8s, not a looser bound: the ceiling under test is 2s, so anything up to
+ // ~4x it still fails while leaving room for boot and SSE delivery. A 15s
+ // bound would also admit an implementation that ignored
+ // `OPENHUMAN_MODEL_CALL_TIMEOUT_SECS` and used a fixed 10s ceiling.
assert!(
- elapsed < Duration::from_secs(15),
+ elapsed < Duration::from_secs(8),
"the turn must be cut off by the 2s per-call ceiling, not by the 25s \
upstream stall completing under the 600s turn deadline; took {elapsed:?}"
);
diff --git a/tests/memory_sources_e2e.rs b/tests/memory_sources_e2e.rs
index e40a4a4202..f487d4435d 100644
--- a/tests/memory_sources_e2e.rs
+++ b/tests/memory_sources_e2e.rs
@@ -1037,10 +1037,20 @@ async fn memory_sources_missing_relative_folder_reports_the_resolved_path() {
serialized.contains("no-such-folder"),
"the error must still name the configured path; got {items_resp}"
);
+ // The concrete resolved root, not just the phrase "resolved to". A reader
+ // that still joined on the process CWD, or that emitted something generic
+ // like "resolved to an unavailable location", would satisfy a phrase-only
+ // check while keeping the exact diagnostic gap this test exists to close.
+ let expected_resolved = workspace.join("no-such-folder");
+ let expected_resolved = expected_resolved.to_string_lossy();
assert!(
serialized.contains("resolved to"),
"a relative path's error must name where the reader looked; got {items_resp}"
);
+ assert!(
+ serialized.contains(expected_resolved.as_ref()),
+ "the resolved root must be the workspace one ({expected_resolved}); got {items_resp}"
+ );
rpc_join.abort();
}