# -*- coding: utf-8 -*- from playwright.sync_api import sync_playwright import sys, io, re sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') def run(): with sync_playwright() as p: browser = p.chromium.launch(headless=True) page = browser.new_page(viewport={'width': 1440, 'height': 900}) errors = [] page.on('pageerror', lambda err: errors.append(str(err))) page.goto('http://localhost:5173', wait_until='networkidle', timeout=30000) page.wait_for_timeout(1000) # Login page.locator('input[type="text"]').first.fill('admin') page.locator('input[type="password"]').first.fill('admin123') page.locator('button').first.click() page.wait_for_timeout(3000) # Test all routes after fix routes = [ '/chat', '/knowledge/stats', '/knowledge/document', '/knowledge/category', '/knowledge/search', '/knowledge/faq', '/conversation', '/dashboard', '/settings/role', '/settings/model-config', '/settings/sensitive', '/settings/audit-log', '/settings/user', '/settings/api-key', '/settings/webhook', '/settings/mcp-server', '/settings/pipeline-flow', '/settings/system-config', ] all_ok = True for route in routes: errors.clear() page.evaluate(f'window.location.hash = "{route}"') page.wait_for_timeout(2500) main = page.locator('.main-content') if main.count() > 0: html = main.inner_html() clean = re.sub(r'', '', html, flags=re.DOTALL) clean = re.sub(r'\s+', ' ', clean).strip() has_content = len(clean) > 20 else: has_content = False clean = '' errs = list(set(e[:150] for e in errors)) status = 'OK' if has_content and not errs else ('ERR' if errs else 'EMPTY') print(f'[{status}] {route} | content_len={len(clean)} | errors={errs}') if not has_content or errs: all_ok = False print(f'\n=== ALL OK: {all_ok} ===') browser.close() if __name__ == '__main__': run()