sync from local backup
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
from playwright.sync_api import sync_playwright
|
||||
import time
|
||||
import os
|
||||
|
||||
def dismiss_vite_error(page):
|
||||
try:
|
||||
page.evaluate("document.querySelector('vite-error-overlay')?.remove()")
|
||||
time.sleep(0.3)
|
||||
except:
|
||||
pass
|
||||
|
||||
def test_fixes():
|
||||
os.makedirs('/tmp/frontend_test', exist_ok=True)
|
||||
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(headless=True)
|
||||
context = browser.new_context(viewport={"width": 1400, "height": 900})
|
||||
page = context.new_page()
|
||||
|
||||
console_errors = []
|
||||
page.on("console", lambda msg: console_errors.append(f"[{msg.type}] {msg.text}") if msg.type == "error" else None)
|
||||
|
||||
print("=" * 60)
|
||||
print("测试修复效果")
|
||||
print("=" * 60)
|
||||
|
||||
# 1. 测试Learn页面(应无404错误)
|
||||
print("\n[测试1] Learn页面 - Courses 404修复")
|
||||
page.goto('http://localhost:5173/learn', wait_until='load', timeout=15000)
|
||||
time.sleep(3)
|
||||
dismiss_vite_error(page)
|
||||
page.screenshot(path='/tmp/frontend_test/learn_courses.png', full_page=True)
|
||||
|
||||
course_cards = page.locator('[class*="course"]')
|
||||
print(f" 找到 {course_cards.count()} 个课程卡片")
|
||||
|
||||
# 检查是否还有courses错误
|
||||
courses_errors = [e for e in console_errors if 'courses' in e.lower()]
|
||||
if courses_errors:
|
||||
print(f" ⚠ 仍有courses错误: {courses_errors}")
|
||||
else:
|
||||
print(" ✓ 无courses 404错误")
|
||||
|
||||
# 2. 测试Messages页面(应无message警告)
|
||||
print("\n[测试2] Messages页面 - Ant Design message警告修复")
|
||||
console_errors.clear()
|
||||
page.goto('http://localhost:5173/messages', wait_until='load', timeout=15000)
|
||||
time.sleep(2)
|
||||
dismiss_vite_error(page)
|
||||
page.screenshot(path='/tmp/frontend_test/messages.png', full_page=True)
|
||||
|
||||
message_warnings = [e for e in console_errors if 'message' in e.lower() and 'context' in e.lower()]
|
||||
if message_warnings:
|
||||
print(f" ⚠ 仍有message警告: {message_warnings}")
|
||||
else:
|
||||
print(" ✓ 无Ant Design message警告")
|
||||
|
||||
# 3. 测试未登录时点击消息标签弹出登录弹窗
|
||||
print("\n[测试3] 未登录时点击消息标签弹出登录弹窗")
|
||||
# 这里只是验证功能是否正常工作,实际登录状态需要根据当前环境判断
|
||||
tabs = page.locator('.ant-tabs-tab')
|
||||
print(f" 找到 {tabs.count()} 个标签")
|
||||
|
||||
browser.close()
|
||||
print("\n" + "=" * 60)
|
||||
print("测试完成!")
|
||||
print("=" * 60)
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_fixes()
|
||||
Reference in New Issue
Block a user