Spaces:
Running
Running
File size: 4,265 Bytes
3f624b3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
#!/usr/bin/env python3
"""
Master Selenium Test Runner - Run All Tests Sequentially with Visible Browser
This script runs all important selenium tests one after another so you can watch them:
1. Character Loading (Thorin & Elara)
2. World Exploration (lazy generation, items, travel)
3. Hallucination Bug Test (non-existent goblin)
4. Shop System
5. Combat System
6. Party Mode
Each test runs in a visible browser with pauses between tests.
"""
import subprocess
import time
import sys
# ANSI colors
GREEN = '\033[0;32m'
YELLOW = '\033[1;33m'
RED = '\033[0;31m'
BLUE = '\033[0;34m'
NC = '\033[0m' # No Color
def print_header(text):
print(f"\n{BLUE}{'=' * 70}{NC}")
print(f"{BLUE}{text:^70}{NC}")
print(f"{BLUE}{'=' * 70}{NC}\n")
def run_test(test_name, test_file, description):
"""Run a single pytest test with visible browser."""
print_header(f"TEST: {test_name}")
print(f"{YELLOW}๐ Description: {description}{NC}")
print(f"{YELLOW}๐ File: {test_file}{NC}\n")
# Run pytest with visible browser markers
cmd = [
'python3', '-m', 'pytest',
f'e2e_tests/{test_file}',
'-v',
'-s', # Show print statements
'--tb=short', # Short traceback
'--capture=no' # Don't capture output
]
try:
result = subprocess.run(cmd, cwd='/Users/alexchilton/DataspellProjects/CAS_NLP_BIG_PROJECT')
if result.returncode == 0:
print(f"\n{GREEN}โ
{test_name} PASSED{NC}")
else:
print(f"\n{RED}โ {test_name} FAILED{NC}")
response = input(f"\n{YELLOW}Continue to next test? (y/n): {NC}")
if response.lower() != 'y':
print(f"{RED}Tests stopped by user{NC}")
sys.exit(1)
except KeyboardInterrupt:
print(f"\n{RED}Tests interrupted by user{NC}")
sys.exit(1)
# Pause between tests
print(f"\n{YELLOW}โธ๏ธ Pausing 3 seconds before next test...{NC}")
time.sleep(3)
def main():
print_header("๐ฎ D&D RAG SELENIUM TEST SUITE ๐ฎ")
print(f"{YELLOW}This will run all selenium tests sequentially with visible browsers{NC}")
print(f"{YELLOW}You can watch each test execute in Chrome{NC}\n")
# Check if app is running
import urllib.request
try:
urllib.request.urlopen('http://localhost:7860', timeout=2)
print(f"{GREEN}โ
App is running at http://localhost:7860{NC}\n")
except:
print(f"{RED}โ App is NOT running at http://localhost:7860{NC}")
print(f"{YELLOW}Please start it first: python3 app.py{NC}\n")
sys.exit(1)
input(f"{YELLOW}Press ENTER to start tests...{NC}")
# Test Suite
tests = [
("Character Loading", "test_character_loading.py",
"Load Thorin and Elara, verify their stats appear correctly"),
("World Exploration", "test_world_exploration.py",
"Test lazy location generation, item persistence, travel back/forth"),
("Hallucination Bug", "test_hallucination_bug.py",
"Attack non-existent goblin, verify GM doesn't hallucinate dragon"),
("Shop System", "test_shop_selenium.py",
"Visit shop, browse items, buy/sell, verify inventory updates"),
("Combat System", "test_combat_system.py",
"Full combat test - attack, damage, turns, death"),
("Party Mode", "test_party_dragon_selenium.py",
"Multiple characters fighting together against dragon"),
]
passed = 0
failed = 0
for test_name, test_file, description in tests:
try:
run_test(test_name, test_file, description)
passed += 1
except Exception as e:
print(f"{RED}Error running {test_name}: {e}{NC}")
failed += 1
# Final summary
print_header("๐ TEST SUMMARY")
print(f"{GREEN}โ
Passed: {passed}{NC}")
print(f"{RED}โ Failed: {failed}{NC}")
print(f"{BLUE}๐ Total: {passed + failed}{NC}\n")
if failed == 0:
print(f"{GREEN}๐ ALL TESTS PASSED! ๐{NC}\n")
else:
print(f"{YELLOW}โ ๏ธ Some tests failed - check output above{NC}\n")
if __name__ == "__main__":
main()
|