9aad012bdc
- Add mocked Click CLI tests across DOM, cookies, page, storage, perf, navigation, tabs, groups, sessions, and windows commands. - Cover integration paths for cookies, page info, performance profiles, and web storage commands. - Extend DOM integration coverage for eval, scrolling, waiting, focus, hover, typing, selection, keyboard, and checkbox interactions. - Add native host unit coverage for message framing, socket helpers, paging guards, timeouts, and profile alias resolution.
73 lines
2.8 KiB
Python
73 lines
2.8 KiB
Python
"""Integration tests for perf.* commands — require a live browser."""
|
|
import time
|
|
|
|
_VALID_PROFILES = {"auto", "normal", "gentle", "ultra"}
|
|
|
|
def test_perf_status_returns_profile_field(browser):
|
|
"""perf.status returns a dict with a performanceProfile field."""
|
|
result = browser("perf.status")
|
|
assert isinstance(result, dict)
|
|
assert "performanceProfile" in result
|
|
assert result["performanceProfile"] in _VALID_PROFILES
|
|
|
|
def test_perf_status_has_throttle(browser):
|
|
"""perf.status includes a throttle dict with batchSize and pauseMs."""
|
|
result = browser("perf.status")
|
|
throttle = result.get("throttle")
|
|
assert isinstance(throttle, dict)
|
|
assert "batchSize" in throttle
|
|
assert "pauseMs" in throttle
|
|
assert isinstance(throttle["batchSize"], int)
|
|
assert isinstance(throttle["pauseMs"], int)
|
|
assert throttle["batchSize"] > 0
|
|
assert throttle["pauseMs"] >= 0
|
|
|
|
def test_perf_status_has_audible_field(browser):
|
|
"""perf.status contains an audible boolean."""
|
|
result = browser("perf.status")
|
|
assert "audible" in result
|
|
assert isinstance(result["audible"], bool)
|
|
|
|
def test_perf_status_has_jobs_field(browser):
|
|
"""perf.status contains a jobs list (may be empty)."""
|
|
result = browser("perf.status")
|
|
assert "jobs" in result
|
|
assert isinstance(result["jobs"], list)
|
|
|
|
def test_perf_set_profile_returns_profile(browser):
|
|
"""perf.set_profile responds with the applied profile."""
|
|
# Save current
|
|
current = browser("perf.status").get("performanceProfile", "auto")
|
|
target = "normal" if current != "normal" else "gentle"
|
|
|
|
try:
|
|
result = browser("perf.set_profile", {"profile": target})
|
|
assert isinstance(result, dict)
|
|
assert result.get("performanceProfile") == target
|
|
finally:
|
|
browser("perf.set_profile", {"profile": current})
|
|
|
|
def test_perf_set_profile_updates_status(browser):
|
|
"""After set_profile the status command reflects the new profile."""
|
|
current = browser("perf.status").get("performanceProfile", "auto")
|
|
target = "gentle" if current != "gentle" else "normal"
|
|
|
|
try:
|
|
browser("perf.set_profile", {"profile": target})
|
|
status = browser("perf.status")
|
|
assert status.get("performanceProfile") == target
|
|
finally:
|
|
browser("perf.set_profile", {"profile": current})
|
|
|
|
def test_perf_profile_roundtrip_all_values(browser):
|
|
"""Every valid profile can be set and read back without error."""
|
|
original = browser("perf.status").get("performanceProfile", "auto")
|
|
try:
|
|
for profile in sorted(_VALID_PROFILES):
|
|
result = browser("perf.set_profile", {"profile": profile})
|
|
assert result.get("performanceProfile") == profile
|
|
status = browser("perf.status")
|
|
assert status.get("performanceProfile") == profile
|
|
finally:
|
|
browser("perf.set_profile", {"profile": original})
|