Files
rpa_vision_v3/tests/unit/test_finalize_auto_replay_flag.py
Dom 7df51d2c79 snapshot: WIP 5j replay reliability (B1 watchdog + dialog handlers + grounding drift)
Snapshot avant correction du blocage relance Léa (3 incidents 24h: SSH refusé,
polls morts ×2). Point de rollback stable.

Contenu:
- agent_v1/core/executor.py: 5 patchs dialog handling (saveas drift, close_tab
  hotkey fallback, confirm_save Unicode apostrophe, foreground dialog
  recontextualization, runtime_dialog in-loop) + helpers normalize_window_hint,
  requires_post_verify_window_transition
- agent_v1/core/grounding.py: garde drift template fix (fallback_x/y plumbed)
- server_v1/replay_watchdog.py (NEW): orphan watchdog B1, scan 10s timeout 30s
- server_v1/api_stream.py: dispatched_action plumbing, watchdog lifespan,
  metrics endpoint
- server_v1/replay_engine.py: _schedule_retry préserve original_action +
  dispatched_action
- stream_processor.py: gardes _infer_tab_switch_target (no false switch_tab
  on save_as dialog open) + _attach_expected_window_before
- tests/integration: test_replay_watchdog.py (8 cas), test_stream_processor.py
- tests/unit: test_executor_verify_window_guard.py (start_button, close_tab,
  runtime_dialog, post_verify, transition fallbacks)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 16:48:37 +02:00

59 lines
2.5 KiB
Python

"""Tests pour le flag RPA_AUTO_LAUNCH_REPLAY_AFTER_FINALIZE.
Brief Codex 2026-05-23 09:02 : le chemin produit cible est le workflow
compilé (post worker VLM), pas le replay direct depuis raw events.
Le flag env désactive la proposition automatique de replay direct par
défaut. Le chemin direct reste accessible (smoke/debug) via RPA_AUTO_LAUNCH_REPLAY_AFTER_FINALIZE=true.
"""
from __future__ import annotations
import sys
from pathlib import Path
ROOT = Path(__file__).parent.parent.parent
sys.path.insert(0, str(ROOT))
from agent_v0.server_v1.replay_engine import ( # noqa: E402
_auto_launch_replay_after_finalize,
)
class TestAutoLaunchReplayFlag:
def test_default_is_false(self, monkeypatch):
"""Sans variable d'env, le mode produit est actif → pas de
proposition automatique de replay direct."""
monkeypatch.delenv("RPA_AUTO_LAUNCH_REPLAY_AFTER_FINALIZE", raising=False)
assert _auto_launch_replay_after_finalize() is False
def test_true_value_activates(self, monkeypatch):
monkeypatch.setenv("RPA_AUTO_LAUNCH_REPLAY_AFTER_FINALIZE", "true")
assert _auto_launch_replay_after_finalize() is True
def test_1_value_activates(self, monkeypatch):
monkeypatch.setenv("RPA_AUTO_LAUNCH_REPLAY_AFTER_FINALIZE", "1")
assert _auto_launch_replay_after_finalize() is True
def test_yes_value_activates(self, monkeypatch):
monkeypatch.setenv("RPA_AUTO_LAUNCH_REPLAY_AFTER_FINALIZE", "yes")
assert _auto_launch_replay_after_finalize() is True
def test_false_value_deactivates(self, monkeypatch):
monkeypatch.setenv("RPA_AUTO_LAUNCH_REPLAY_AFTER_FINALIZE", "false")
assert _auto_launch_replay_after_finalize() is False
def test_empty_value_deactivates(self, monkeypatch):
monkeypatch.setenv("RPA_AUTO_LAUNCH_REPLAY_AFTER_FINALIZE", "")
assert _auto_launch_replay_after_finalize() is False
def test_arbitrary_value_deactivates(self, monkeypatch):
"""Toute valeur non-truthy retourne False (default-deny)."""
monkeypatch.setenv("RPA_AUTO_LAUNCH_REPLAY_AFTER_FINALIZE", "maybe")
assert _auto_launch_replay_after_finalize() is False
def test_case_insensitive(self, monkeypatch):
monkeypatch.setenv("RPA_AUTO_LAUNCH_REPLAY_AFTER_FINALIZE", "TRUE")
assert _auto_launch_replay_after_finalize() is True
monkeypatch.setenv("RPA_AUTO_LAUNCH_REPLAY_AFTER_FINALIZE", "Yes")
assert _auto_launch_replay_after_finalize() is True