Initial commit: Naddie Jump — Monad Edition
This commit is contained in:
72
test-game.py
Normal file
72
test-game.py
Normal file
@@ -0,0 +1,72 @@
|
||||
from playwright.sync_api import sync_playwright
|
||||
import time
|
||||
import os
|
||||
|
||||
screenshots_dir = "/home/anril/naddie-jump/test-screenshots"
|
||||
os.makedirs(screenshots_dir, exist_ok=True)
|
||||
|
||||
console_errors = []
|
||||
console_logs = []
|
||||
|
||||
def handle_console(msg):
|
||||
console_logs.append(f"[{msg.type}] {msg.text}")
|
||||
if msg.type == "error":
|
||||
console_errors.append(msg.text)
|
||||
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(headless=True)
|
||||
context = browser.new_context(viewport={"width": 480, "height": 854})
|
||||
page = context.new_page()
|
||||
page.on("console", handle_console)
|
||||
page.on("pageerror", lambda err: console_errors.append(str(err)))
|
||||
|
||||
print("Opening game...")
|
||||
page.goto("http://localhost:5173/")
|
||||
time.sleep(2)
|
||||
|
||||
# Screenshot 1: Menu
|
||||
page.screenshot(path=f"{screenshots_dir}/01-menu.png")
|
||||
print("Screenshot: menu")
|
||||
|
||||
# Click START GAME
|
||||
print("Clicking START GAME...")
|
||||
page.click("text=START GAME")
|
||||
time.sleep(1)
|
||||
|
||||
# Screenshot 2: Game start
|
||||
page.screenshot(path=f"{screenshots_dir}/02-game-start.png")
|
||||
print("Screenshot: game start")
|
||||
|
||||
# Simulate gameplay - press left/right arrows
|
||||
print("Simulating gameplay...")
|
||||
for i in range(30):
|
||||
if i % 4 < 2:
|
||||
page.keyboard.press("ArrowRight")
|
||||
else:
|
||||
page.keyboard.press("ArrowLeft")
|
||||
time.sleep(0.15)
|
||||
|
||||
# Screenshot 3: After playing
|
||||
page.screenshot(path=f"{screenshots_dir}/03-gameplay.png")
|
||||
print("Screenshot: gameplay")
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
# Screenshot 4: Final state
|
||||
page.screenshot(path=f"{screenshots_dir}/04-final.png")
|
||||
print("Screenshot: final")
|
||||
|
||||
browser.close()
|
||||
|
||||
print("\n=== CONSOLE LOGS ===")
|
||||
for log in console_logs:
|
||||
print(log)
|
||||
|
||||
print("\n=== ERRORS ===")
|
||||
if console_errors:
|
||||
for err in console_errors:
|
||||
print(err)
|
||||
else:
|
||||
print("No errors!")
|
||||
|
||||
print(f"\nScreenshots saved to: {screenshots_dir}")
|
||||
Reference in New Issue
Block a user