; Mosis Designer Test Runner
; AutoHotkey v2
; Runs all test scripts and generates a report

#Requires AutoHotkey v2.0
#Include "lib\utils.ahk"

; Test scripts to run
global testScripts := [
    "test_navigation.ahk"
]

; Run all tests
RunAllTests() {
    LogMessage("========================================")
    LogMessage("MOSIS DESIGNER TEST SUITE")
    LogMessage("========================================")

    totalPassed := 0
    totalFailed := 0

    ; Clean up
    KillDesigner()
    ClearLogs()

    for script in testScripts {
        LogMessage("")
        LogMessage("Running: " . script)
        LogMessage("----------------------------------------")

        scriptPath := A_ScriptDir . "\" . script

        if (!FileExist(scriptPath)) {
            LogMessage("ERROR: Script not found: " . scriptPath)
            totalFailed++
            continue
        }

        ; Run the test script
        try {
            ahkPath := "C:\Program Files\AutoHotkey\v2\AutoHotkey64.exe"
            RunWait('"' . ahkPath . '" "' . scriptPath . '"', A_ScriptDir)
        } catch as e {
            LogMessage("ERROR running script: " . e.Message)
            totalFailed++
        }

        ; Brief pause between tests
        Sleep(1000)
    }

    ; Final cleanup
    KillDesigner()

    ; Generate report
    LogMessage("")
    LogMessage("========================================")
    LogMessage("TEST SUITE COMPLETE")
    LogMessage("Check test_run.log for detailed results")
    LogMessage("========================================")
}

; Main
RunAllTests()
ExitApp()
