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
1232
tests/webapp/announcements_messages_test.py
Normal file
58
tests/webapp/debug_announcements.py
Normal file
@@ -0,0 +1,58 @@
|
||||
"""调试 admin 访问 /announcements 的 500 错误"""
|
||||
from playwright.sync_api import sync_playwright
|
||||
import re
|
||||
|
||||
BASE_URL = "http://localhost:3000"
|
||||
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(headless=True)
|
||||
context = browser.new_context(viewport={"width": 1440, "height": 900}, locale="zh-CN")
|
||||
page = context.new_page()
|
||||
|
||||
# 收集控制台错误
|
||||
errors = []
|
||||
page_errors = []
|
||||
def on_console(msg):
|
||||
if msg.type == "error":
|
||||
errors.append(msg.text)
|
||||
def on_pageerror(err):
|
||||
page_errors.append(str(err))
|
||||
page.on("console", on_console)
|
||||
page.on("pageerror", on_pageerror)
|
||||
|
||||
# 登录 admin
|
||||
page.goto(f"{BASE_URL}/login", timeout=30000)
|
||||
page.wait_for_load_state("networkidle", timeout=15000)
|
||||
page.locator('input[name="email"]').fill("admin@xiaoxue.edu.cn")
|
||||
page.locator('input[name="password"]').fill("123456")
|
||||
login_btn = page.get_by_role("button", name=re.compile(r"Sign In with Email", re.I))
|
||||
login_btn.click()
|
||||
page.wait_for_timeout(3000)
|
||||
page.wait_for_load_state("networkidle", timeout=15000)
|
||||
print(f"登录后 URL: {page.url}")
|
||||
|
||||
# 访问 /announcements
|
||||
print("\n访问 /announcements...")
|
||||
response = page.goto(f"{BASE_URL}/announcements", timeout=30000)
|
||||
print(f"HTTP 状态: {response.status if response else 'None'}")
|
||||
page.wait_for_load_state("networkidle", timeout=15000)
|
||||
page.wait_for_timeout(2000)
|
||||
print(f"最终 URL: {page.url}")
|
||||
|
||||
# 获取页面内容
|
||||
body = page.locator("body").text_content()
|
||||
print(f"\n页面内容 (前 2000 字符):")
|
||||
print(body[:2000] if body else "(空)")
|
||||
|
||||
# 截图
|
||||
page.screenshot(path="tests/webapp/screenshots/announcements_messages/debug_announcements_admin.png", full_page=True)
|
||||
|
||||
print(f"\n控制台错误 ({len(errors)} 条):")
|
||||
for e in errors[:10]:
|
||||
print(f" - {e[:200]}")
|
||||
|
||||
print(f"\n页面错误 ({len(page_errors)} 条):")
|
||||
for e in page_errors[:10]:
|
||||
print(f" - {e[:300]}")
|
||||
|
||||
browser.close()
|
||||
56
tests/webapp/debug_teacher_msg.py
Normal file
@@ -0,0 +1,56 @@
|
||||
"""调试 teacher 发送消息"""
|
||||
from playwright.sync_api import sync_playwright
|
||||
import re
|
||||
|
||||
BASE_URL = "http://localhost:3000"
|
||||
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(headless=True)
|
||||
context = browser.new_context(viewport={"width": 1440, "height": 900}, locale="zh-CN")
|
||||
page = context.new_page()
|
||||
|
||||
# 登录 teacher
|
||||
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")
|
||||
login_btn = page.get_by_role("button", name=re.compile(r"Sign In with Email", re.I))
|
||||
login_btn.click()
|
||||
page.wait_for_timeout(3000)
|
||||
page.wait_for_load_state("networkidle", timeout=15000)
|
||||
print(f"登录后 URL: {page.url}")
|
||||
|
||||
# 访问撰写页面
|
||||
print("\n访问 /messages/compose...")
|
||||
page.goto(f"{BASE_URL}/messages/compose", timeout=30000)
|
||||
page.wait_for_load_state("networkidle", timeout=15000)
|
||||
page.wait_for_timeout(2000)
|
||||
|
||||
# 检查页面内容
|
||||
body = page.locator("body").text_content()
|
||||
print(f"页面内容 (前 1000 字符):")
|
||||
print(body[:1000] if body else "(空)")
|
||||
|
||||
# 检查收件人选择器
|
||||
print("\n检查收件人选择器...")
|
||||
select_trigger = page.locator('button[role="combobox"]').first
|
||||
print(f"button[role=combobox] count: {page.locator('button[role=\"combobox\"]').count()}")
|
||||
print(f"[role=combobox] count: {page.locator('[role=\"combobox\"]').count()}")
|
||||
|
||||
# 检查所有 button 元素
|
||||
buttons = page.locator("button").all()
|
||||
print(f"\n页面按钮数: {len(buttons)}")
|
||||
for i, btn in enumerate(buttons[:10]):
|
||||
try:
|
||||
text = btn.text_content()
|
||||
role = btn.get_attribute("role")
|
||||
type_ = btn.get_attribute("type")
|
||||
print(f" button[{i}]: role={role}, type={type_}, text={text[:50] if text else '(空)'}")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 截图
|
||||
page.screenshot(path="tests/webapp/screenshots/announcements_messages/debug_teacher_compose.png", full_page=True)
|
||||
print("\n截图已保存")
|
||||
|
||||
browser.close()
|
||||
BIN
tests/webapp/screenshots/admin_ai_tab.png
Normal file
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 81 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 58 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 57 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 44 KiB |
BIN
tests/webapp/screenshots/settings_general_tab.png
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
tests/webapp/screenshots/settings_loaded.png
Normal file
|
After Width: | Height: | Size: 61 KiB |
BIN
tests/webapp/screenshots/settings_notifications_tab.png
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
tests/webapp/screenshots/teacher_theme.png
Normal file
|
After Width: | Height: | Size: 46 KiB |