feat(competences): plan supervised replay tests
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
from flask import Flask
|
||||
|
||||
from core.competences.catalog import load_competence_catalog_actions, load_competences
|
||||
from core.competences.replay import build_competence_replay_actions, build_competence_replay_payload
|
||||
|
||||
|
||||
def test_load_candidate_competences_from_yaml_catalog():
|
||||
@@ -23,6 +26,8 @@ def test_competence_catalog_actions_include_runtime_gap_metadata():
|
||||
assert alt_f4["source"] == "competence_yaml"
|
||||
assert "fermer la fenêtre Bloc-notes" in alt_f4["name"]
|
||||
assert alt_f4["parameters"]["supervised"]["default"] is True
|
||||
assert alt_f4["parameters"]["start_replay"]["default"] is False
|
||||
assert alt_f4["test_action"]["type"] == "test_competence"
|
||||
assert alt_f4["t2_known_gaps"][0]["id"] == "alt_f4_confirmation_dialog_not_covered"
|
||||
|
||||
|
||||
@@ -32,3 +37,56 @@ def test_competence_catalog_actions_are_deterministic():
|
||||
|
||||
assert [action["id"] for action in first] == [action["id"] for action in second]
|
||||
|
||||
|
||||
def test_build_competence_supervised_replay_actions():
|
||||
actions = build_competence_replay_actions("key_win_r_wait_explorer_exe")
|
||||
|
||||
assert [action["type"] for action in actions] == [
|
||||
"pause_for_human",
|
||||
"key_combo",
|
||||
"verify_screen",
|
||||
"pause_for_human",
|
||||
]
|
||||
assert actions[1]["keys"] == ["win", "r"]
|
||||
assert actions[2]["expected_window_title_contains"] == ["Exécuter"]
|
||||
assert actions[2]["expected_state"]["process_active"] == "explorer.exe"
|
||||
|
||||
|
||||
def test_build_competence_raw_replay_payload_is_supervised():
|
||||
payload = build_competence_replay_payload("key_alt_f4_wait_windowsterminal_exe", machine_id="win")
|
||||
|
||||
assert payload["machine_id"] == "win"
|
||||
assert payload["params"]["execution_mode"] == "supervised"
|
||||
assert payload["params"]["competence_id"] == "key_alt_f4_wait_windowsterminal_exe"
|
||||
assert payload["actions"][1]["type"] == "key_combo"
|
||||
assert payload["actions"][1]["keys"] == ["alt", "f4"]
|
||||
|
||||
|
||||
def test_vwb_catalog_execute_plans_competence_replay():
|
||||
from visual_workflow_builder.backend.catalog_routes_v2_vlm import catalog_bp
|
||||
|
||||
app = Flask(__name__)
|
||||
app.register_blueprint(catalog_bp)
|
||||
|
||||
with app.test_client() as client:
|
||||
response = client.post(
|
||||
"/api/vwb/catalog/execute",
|
||||
json={
|
||||
"type": "lea_competence_key_ctrl_s_wait_notepad_exe",
|
||||
"step_id": "step_test",
|
||||
"parameters": {"supervised": True},
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.get_json()
|
||||
assert data["success"] is True
|
||||
result = data["result"]
|
||||
assert result["status"] == "planned"
|
||||
assert result["output_data"]["competence_id"] == "key_ctrl_s_wait_notepad_exe"
|
||||
assert [action["type"] for action in result["output_data"]["actions"]] == [
|
||||
"pause_for_human",
|
||||
"key_combo",
|
||||
"verify_screen",
|
||||
"pause_for_human",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user