Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

Make the automatic mode timing tests independent of machine speed

Emre Sokulluf2e932c8fc10
diff --git a/test/auto-mode.mjs b/test/auto-mode.mjs
index d0fa68da8..c9e6631e7 100644
--- a/test/auto-mode.mjs
+++ b/test/auto-mode.mjs
@@ -89,10 +89,9 @@ for (const build of BUILDS) {
});
test(`${build}: the grace period never waits for a slow decision`, async () => {
- const started = Date.now();
+ // A route that never answers still settles, read-only.
const routed = await autoMode.settleAutoModeRoute(new Promise(() => {}), 20);
assert.deepEqual(routed, { mode: 'ask', choice: null, source: 'route_timeout' });
- assert.ok(Date.now() - started < 1000);
assert.deepEqual(await autoMode.settleAutoModeRoute(Promise.resolve({ mode: 'act', choice: 'act', source: 'decision_model' }), 20),
{ mode: 'act', choice: 'act', source: 'decision_model' });
assert.equal((await autoMode.settleAutoModeRoute(Promise.resolve({ mode: 'auto' }), 20)).mode, 'ask');
@@ -395,10 +394,9 @@ for (const build of BUILDS) {
});
test(`${build}: a slow decision model leaves the turn read-only after the grace period`, async () => {
+ // The decision never answers; the turn goes on without it.
const f = fixture(Agent, { decide: () => new Promise(() => {}), replies: [done('Read-only answer.')] });
- const started = Date.now();
assert.equal(await f.run('Turn on dark mode.'), 'Read-only answer.');
- assert.ok(Date.now() - started < 3000);
assert.deepEqual(runModes(f.updates), [{ mode: 'ask', source: 'route_timeout' }]);
assert.ok(f.calls[0].tools.includes('request_action_mode'), 'the main model can still hand the turn off');
});