48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
import sys
|
|
import os
|
|
import time
|
|
from simulation.sim_base import BaseSimulation, run_sim
|
|
|
|
class ExecutionSimulation(BaseSimulation):
|
|
def run(self):
|
|
print("\n--- Running Execution & Modals Simulation ---")
|
|
|
|
# 1. Trigger script generation
|
|
msg = "Create a hello.ps1 script that prints 'Simulation Test' and execute it."
|
|
print(f"[Sim] Sending message to trigger script: {msg}")
|
|
self.sim.run_discussion_turn(msg)
|
|
|
|
# 2. Wait for confirmation modal
|
|
print("[Sim] Waiting for confirmation modal...")
|
|
modal_shown = False
|
|
for i in range(30):
|
|
if self.client.get_value("show_confirm_modal"):
|
|
modal_shown = True
|
|
print(f"[Sim] Modal shown at second {i}")
|
|
break
|
|
time.sleep(1)
|
|
|
|
assert modal_shown, "Expected confirmation modal to be shown"
|
|
|
|
# 3. Approve script
|
|
print("[Sim] Approving script execution...")
|
|
self.client.click("btn_approve_script")
|
|
time.sleep(2)
|
|
|
|
# 4. Verify output in history or status
|
|
session = self.client.get_session()
|
|
entries = session.get('session', {}).get('entries', [])
|
|
|
|
# Tool outputs are usually in history
|
|
success = any("Simulation Test" in e.get('content', '') for e in entries if e.get('role') in ['Tool', 'Function'])
|
|
if success:
|
|
print("[Sim] Output found in session history.")
|
|
else:
|
|
print("[Sim] Output NOT found in history yet, checking status...")
|
|
# Maybe check ai_status
|
|
status = self.client.get_value("ai_status")
|
|
print(f"[Sim] Final Status: {status}")
|
|
|
|
if __name__ == "__main__":
|
|
run_sim(ExecutionSimulation)
|