mirror of
https://github.com/insistence/RuoYi-Vue3-FastAPI.git
synced 2026-09-25 21:57:49 +00:00
* feat: 新增E2E测试 * fix: 修复docker compose命令书写错误 * fix: 运行测试前执行`playwright install` * fix: 增强检查以尝试修复3.11连接拒绝的问题 * fix: 增加mysql服务检查 * fix: 修复python 3.9兼容性问题 * perf: 优化禁用验证码脚本 * feat: 新增pg测试 * fix: 修复pg测试检查服务名书写错误 * perf: 优化测试 * style: 格式化代码
47 lines
1.8 KiB
Python
47 lines
1.8 KiB
Python
import pytest
|
|
from playwright.async_api import async_playwright
|
|
|
|
from common.base_page_test import BasePageTest
|
|
from common.config import Config
|
|
|
|
|
|
class ServerMonitorTest(BasePageTest):
|
|
"""服务监控测试类"""
|
|
|
|
async def test_server_monitor(self) -> None:
|
|
"""测试服务监控页面"""
|
|
await self.page.goto(Config.frontend_url + '/monitor/server')
|
|
await self.page.wait_for_load_state('networkidle')
|
|
|
|
# 验证主要板块存在
|
|
await self.page.wait_for_selector('text=CPU')
|
|
await self.page.wait_for_selector('text=内存')
|
|
await self.page.wait_for_selector('text=服务器信息')
|
|
await self.page.wait_for_selector('text=Python解释器信息')
|
|
await self.page.wait_for_selector('text=磁盘状态')
|
|
|
|
# 验证项目路径为 /app
|
|
# 尝试在表格行中查找
|
|
project_path_row = self.page.locator('tr', has_text='项目路径')
|
|
try:
|
|
await project_path_row.wait_for(timeout=5000)
|
|
text = await project_path_row.text_content()
|
|
assert '/app' in text, f"Expected project path '/app' in row, but got: {text}"
|
|
except Exception:
|
|
# 如果没找到行,尝试全局搜索
|
|
print("Warning: '项目路径' row not found, checking page content")
|
|
content = await self.page.content()
|
|
assert '/app' in content, "Project path '/app' not found in page content"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_server_monitor_page() -> None:
|
|
"""测试服务监控页面功能"""
|
|
async with async_playwright() as p:
|
|
test_instance = ServerMonitorTest()
|
|
await test_instance.setup(p)
|
|
try:
|
|
await test_instance.test_server_monitor()
|
|
finally:
|
|
await test_instance.teardown()
|