mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-08-17 18:25:42 +02:00
[eric] browser: split the opener-wait tests out at the file cap
This commit is contained in:
@@ -286,29 +286,3 @@ async def test_login_wall_url_declines_before_any_fill():
|
||||
current_url="https://x.com/i/flow/login")
|
||||
assert r is None
|
||||
assert not calls["clicks"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_opener_wait_stops_once_the_surface_settles():
|
||||
"""A budget spent waiting on a page that has stopped changing is pure cost.
|
||||
|
||||
Fixed budgets were wrong in both directions: 1.8s missed gmail and linkedin, 5.3s still missed
|
||||
a cold gmail compose window, and just raising the number taxes every run that was never going
|
||||
to work. The stop condition is now page stability, so an opener that leads nowhere gives up as
|
||||
soon as two reads match instead of sleeping out the rest."""
|
||||
# Opener clicked, then the same composer-less page twice: identical reads = nothing coming.
|
||||
r, calls = await run(TASK, PROFILE, [PROFILE, PROFILE, PROFILE, PROFILE, PROFILE, PROFILE])
|
||||
assert r is None
|
||||
# 6 sleeps were budgeted; settling must cut the reads well short of consuming them all.
|
||||
assert calls["list"] < 9, f"kept polling a settled page: {calls['list']} reads"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_opener_wait_still_catches_a_late_composer():
|
||||
"""The other direction: a surface that is still mounting must not be abandoned early, which is
|
||||
the failure that made gmail intermittent."""
|
||||
# Changing reads (so never 'settled'), composer only on the 4th look.
|
||||
late = [PROFILE, PROFILE, PROFILE, PROFILE + "\n[99]<button \"x\">",
|
||||
COMPOSER_EMPTY, COMPOSER_FILLED, COMPOSER_SENT]
|
||||
r, calls = await run(TASK, PROFILE, late)
|
||||
assert r is not None and r["sent"] is True
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
"""When to stop waiting for a compose surface that was just opened.
|
||||
|
||||
Split out of test_browser_send_script.py, which hit the 300-line cap. The rule under test is its
|
||||
own idea and deserves its own file: a fixed wait was wrong in both directions (1.8s missed gmail
|
||||
and linkedin; 5.3s still missed a cold gmail compose window; raising it further taxes every run
|
||||
that was never going to succeed), so the stop condition is page stability instead of a clock.
|
||||
"""
|
||||
import pytest
|
||||
|
||||
from backend.tests.test_browser_send_script import (
|
||||
COMPOSER_EMPTY, COMPOSER_FILLED, COMPOSER_SENT, PROFILE, TASK, run,
|
||||
)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_opener_wait_stops_once_the_surface_settles():
|
||||
"""A budget spent waiting on a page that has stopped changing is pure cost.
|
||||
|
||||
Fixed budgets were wrong in both directions: 1.8s missed gmail and linkedin, 5.3s still missed
|
||||
a cold gmail compose window, and just raising the number taxes every run that was never going
|
||||
to work. The stop condition is now page stability, so an opener that leads nowhere gives up as
|
||||
soon as two reads match instead of sleeping out the rest."""
|
||||
# Opener clicked, then the same composer-less page twice: identical reads = nothing coming.
|
||||
r, calls = await run(TASK, PROFILE, [PROFILE, PROFILE, PROFILE, PROFILE, PROFILE, PROFILE])
|
||||
assert r is None
|
||||
# 6 sleeps were budgeted; settling must cut the reads well short of consuming them all.
|
||||
assert calls["list"] < 9, f"kept polling a settled page: {calls['list']} reads"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_opener_wait_still_catches_a_late_composer():
|
||||
"""The other direction: a surface that is still mounting must not be abandoned early, which is
|
||||
the failure that made gmail intermittent."""
|
||||
# Changing reads (so never 'settled'), composer only on the 4th look.
|
||||
late = [PROFILE, PROFILE, PROFILE, PROFILE + "\n[99]<button \"x\">",
|
||||
COMPOSER_EMPTY, COMPOSER_FILLED, COMPOSER_SENT]
|
||||
r, calls = await run(TASK, PROFILE, late)
|
||||
assert r is not None and r["sent"] is True
|
||||
Reference in New Issue
Block a user