Files
zentao-flow/tmp/pw_ui_test2.py
T

50 lines
2.0 KiB
Python

# -*- coding: utf-8 -*-
"""聚焦验证:研发详情 AI 指标显示 + 代码审查报告 MD 在线渲染"""
import io, sys
from playwright.sync_api import sync_playwright
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
BASE = 'http://localhost:8088'
checks = []
def check(name, ok, note=''):
checks.append((name, ok)); print(('PASS ' if ok else 'FAIL ') + name + (' | '+note if note else ''))
with sync_playwright() as p:
browser = p.chromium.launch(channel='chrome', headless=True, args=['--disable-gpu'])
page = browser.new_page(viewport={'width': 1500, 'height': 950})
page.goto(BASE, wait_until='domcontentloaded')
page.wait_for_timeout(2500)
page.locator('input[placeholder="用户名"]').fill('admin')
page.locator('input[placeholder="密码"]').fill('123456')
page.locator('text="登录"').first.click()
page.wait_for_timeout(6000)
page.goto(f'{BASE}/#/product-story-info/6566', wait_until='domcontentloaded')
page.wait_for_timeout(6000)
text = page.inner_text('body')
check('AI指标-显示workloadIndex 8.5', '8.5' in text)
check('AI指标-显示AI参与率 0.6', '0.6' in text)
check('AI指标-人员显示', '郭其兵' in text or '张富斌' in text)
# 滚动到代码审查报告区块并点击「查看」(MD 在线渲染)
block = page.locator('text=代码审查报告').first
block.scroll_into_view_if_needed()
page.wait_for_timeout(2000)
page.screenshot(path='tmp/pw_review_block.png', full_page=False)
try:
btn = page.locator('text="查看"').first
btn.click(timeout=8000)
page.wait_for_timeout(3500)
dlg = page.inner_text('body')
check('MD在线渲染-内容显示', '审查事项' in dlg or 'AI 代码审查报告' in dlg)
page.screenshot(path='tmp/pw_mdpreview.png', full_page=False)
except Exception as e:
check('MD在线渲染-内容显示', False, str(e)[:100])
browser.close()
failed = [c for c in checks if not c[1]]
print(f'\n== {len(checks)-len(failed)}/{len(checks)} 通过 ==')