mirror of
https://github.com/insistence/RuoYi-Vue3-FastAPI.git
synced 2026-10-17 15:05:34 +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: 格式化代码
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
import pytest
|
|
from playwright.async_api import async_playwright, expect
|
|
|
|
from common.base_page_test import BasePageTest
|
|
from common.config import Config
|
|
|
|
|
|
class SwaggerTest(BasePageTest):
|
|
async def check_swagger_interface(self) -> None:
|
|
"""测试系统接口页面 (Swagger UI)"""
|
|
|
|
# 1. 直接导航到系统接口页面
|
|
await self.goto_page(Config.frontend_url + '/tool/swagger')
|
|
|
|
# 2. 验证页面加载
|
|
# 等待 iframe 出现
|
|
iframe = self.page.locator('iframe')
|
|
await expect(iframe).to_be_visible()
|
|
|
|
# 获取 iframe 内容框架
|
|
frame = self.page.frame_locator('iframe')
|
|
|
|
# 验证 iframe 内部的标题包含 "RuoYi-FastAPI"
|
|
h1_locator = frame.locator('h1')
|
|
await expect(h1_locator).to_contain_text('RuoYi-FastAPI', timeout=15000)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_swagger_page() -> None:
|
|
"""测试系统接口页面功能"""
|
|
async with async_playwright() as p:
|
|
test_instance = SwaggerTest()
|
|
await test_instance.setup(p)
|
|
try:
|
|
await test_instance.check_swagger_interface()
|
|
finally:
|
|
await test_instance.teardown()
|