test: update and add E2E, integration, visual, and webapp tests
- Update E2E tests: announcements, auth, auth-business-flow, full-route-regression, grades, navigation, smoke-auth, teacher-web-test - Update integration tests: api-ai-chat, api-onboarding-complete, api-onboarding-status, proxy-guard, integration setup - Update visual regression tests: admin-dashboard, homepage, student-dashboard, teacher-dashboard, visual config, helpers - Update webapp tests: admin, parent, student full tests and debug scripts - Add new webapp tests: announcements_messages, settings_profile, debug scripts - Add webtest directory with test plans, screenshots, and diagnostic scripts
This commit is contained in:
56
webtest/test_routes.py
Normal file
56
webtest/test_routes.py
Normal file
@@ -0,0 +1,56 @@
|
||||
"""测试其他教师页面"""
|
||||
import re
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
BASE_URL = "http://localhost:3000"
|
||||
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(headless=True)
|
||||
context = browser.new_context()
|
||||
page = context.new_page()
|
||||
|
||||
# 登录教师账号
|
||||
print(">>> 登录教师账号...")
|
||||
page.goto(f"{BASE_URL}/login", timeout=30000)
|
||||
page.wait_for_load_state("networkidle", timeout=15000)
|
||||
|
||||
page.locator('input[name="email"]').fill("t_chinese_1@xiaoxue.edu.cn")
|
||||
page.locator('input[name="password"]').fill("123456")
|
||||
page.get_by_role("button", name=re.compile(r"Sign In with Email", re.I)).click()
|
||||
|
||||
page.wait_for_load_state("networkidle", timeout=20000)
|
||||
page.wait_for_timeout(2000)
|
||||
print(f"登录后 URL: {page.url}")
|
||||
|
||||
# 测试多个教师页面
|
||||
routes = [
|
||||
"/teacher/dashboard",
|
||||
"/teacher/lesson-plans",
|
||||
"/teacher/lesson-plans/new",
|
||||
"/teacher/homework",
|
||||
"/teacher/exams",
|
||||
"/teacher/textbooks",
|
||||
]
|
||||
|
||||
for route in routes:
|
||||
print(f"\n>>> 测试 {route}...")
|
||||
try:
|
||||
response = page.goto(f"{BASE_URL}{route}", timeout=30000)
|
||||
status = response.status if response else "None"
|
||||
final_url = page.url
|
||||
print(f" HTTP {status} -> {final_url}")
|
||||
|
||||
if status >= 400:
|
||||
# 获取错误信息
|
||||
try:
|
||||
body = response.text()
|
||||
# 找到错误信息
|
||||
error_match = re.search(r'data-next-error-message="([^"]+)"', body)
|
||||
if error_match:
|
||||
print(f" 错误: {error_match.group(1)[:300]}")
|
||||
except:
|
||||
pass
|
||||
except Exception as e:
|
||||
print(f" ❌ 异常: {e}")
|
||||
|
||||
browser.close()
|
||||
Reference in New Issue
Block a user