Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Adaptive Tactics - Test Runner</title> | |
| <style> | |
| body { | |
| font-family: 'Consolas', 'Monaco', monospace; | |
| background: #1a1a1a; | |
| color: #d4c9a8; | |
| padding: 20px; | |
| } | |
| h1 { | |
| color: #d4a84b; | |
| } | |
| .test-section { | |
| margin: 20px 0; | |
| padding: 15px; | |
| background: #252520; | |
| border: 1px solid #3a2e1a; | |
| border-radius: 4px; | |
| } | |
| .test-section h2 { | |
| color: #a89060; | |
| margin-top: 0; | |
| } | |
| button { | |
| background: #3a2e1a; | |
| color: #d4c9a8; | |
| border: 1px solid #6b5830; | |
| padding: 10px 20px; | |
| cursor: pointer; | |
| font-family: inherit; | |
| margin: 5px; | |
| } | |
| button:hover { | |
| background: #4a3e2a; | |
| } | |
| #output { | |
| white-space: pre-wrap; | |
| margin-top: 20px; | |
| padding: 15px; | |
| background: #0e0c0a; | |
| border: 1px solid #2a2016; | |
| max-height: 400px; | |
| overflow-y: auto; | |
| } | |
| .passed { color: #5a8a3a; } | |
| .failed { color: #8a2a2a; } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>Adaptive Tactics Test Runner</h1> | |
| <div class="test-section"> | |
| <h2>Run Tests</h2> | |
| <button onclick="runTests('rules')">Run Rules Tests</button> | |
| <button onclick="runTests('combat')">Run Combat Tests</button> | |
| <button onclick="runTests('ai')">Run AI Scoring Tests</button> | |
| <button onclick="runTests('adaptation')">Run Adaptation Tests</button> | |
| <button onclick="runAllTests()">Run All Tests</button> | |
| </div> | |
| <div id="output">Click a button to run tests...</div> | |
| <script type="module"> | |
| import { runAllTests as runRulesTests } from './test_rules.js'; | |
| import { runAllTests as runCombatTests } from './test_combat.js'; | |
| import { runAllTests as runAIScoringTests } from './test_ai_scoring.js'; | |
| import { runAllTests as runAdaptationTests } from './test_adaptation.js'; | |
| const output = document.getElementById('output'); | |
| // Capture console output | |
| const originalLog = console.log; | |
| const originalError = console.error; | |
| function captureConsole() { | |
| let logs = []; | |
| console.log = (...args) => { | |
| logs.push(args.join(' ')); | |
| originalLog.apply(console, args); | |
| }; | |
| console.error = (...args) => { | |
| logs.push('ERROR: ' + args.join(' ')); | |
| originalError.apply(console, args); | |
| }; | |
| return logs; | |
| } | |
| function restoreConsole() { | |
| console.log = originalLog; | |
| console.error = originalError; | |
| } | |
| function formatOutput(logs) { | |
| return logs.map(line => { | |
| if (line.includes('PASSED')) { | |
| return `<span class="passed">${line}</span>`; | |
| } else if (line.includes('FAILED') || line.includes('ERROR')) { | |
| return `<span class="failed">${line}</span>`; | |
| } | |
| return line; | |
| }).join('\n'); | |
| } | |
| window.runTests = async function(type) { | |
| const logs = captureConsole(); | |
| output.innerHTML = `Running ${type} tests...\n`; | |
| try { | |
| switch(type) { | |
| case 'rules': | |
| runRulesTests(); | |
| break; | |
| case 'combat': | |
| runCombatTests(); | |
| break; | |
| case 'ai': | |
| runAIScoringTests(); | |
| break; | |
| case 'adaptation': | |
| runAdaptationTests(); | |
| break; | |
| } | |
| } catch (e) { | |
| logs.push(`ERROR: ${e.message}`); | |
| } | |
| restoreConsole(); | |
| output.innerHTML = formatOutput(logs); | |
| }; | |
| window.runAllTests = async function() { | |
| const logs = captureConsole(); | |
| output.innerHTML = 'Running all tests...\n\n'; | |
| try { | |
| runRulesTests(); | |
| logs.push(''); | |
| runCombatTests(); | |
| logs.push(''); | |
| runAIScoringTests(); | |
| logs.push(''); | |
| runAdaptationTests(); | |
| logs.push('\n=== ALL TEST SUITES COMPLETED ==='); | |
| } catch (e) { | |
| logs.push(`ERROR: ${e.message}`); | |
| } | |
| restoreConsole(); | |
| output.innerHTML = formatOutput(logs); | |
| }; | |
| </script> | |
| </body> | |
| </html> | |