Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ export default function CodePreview({ preview, onClose }) {
width="80%"
destroyOnHidden
>
{/* 弹窗外层禁用指针事件,正文区会裁切溢出内容,菜单挂在两者之间的内容容器。 */}
<Tabs
activeKey={activeFile}
onChange={setActiveFile}
more={{ trigger: 'click' }}
getPopupContainer={(trigger) => trigger.closest('.ant-modal-container')}
items={files.map((path) => ({
key: path,
label: previewFileLabel(path),
Expand Down
6 changes: 5 additions & 1 deletion ruoyi-fastapi-test/common/browser_harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ def __init__(self, playwright: Playwright, browser: Browser, output: Path) -> No

async def api_context(self, token: str | None = None) -> APIRequestContext:
"""创建随用例回收的 API 客户端。"""
# UI 操作之间可能长于后端的 keep-alive 超时。直连 API 的测试请求各自关闭连接。
headers = {'Connection': 'close'}
if token:
headers['Authorization'] = f'Bearer {token}'
context = await self.playwright.request.new_context(
base_url=Config.backend_url,
extra_http_headers={'Authorization': f'Bearer {token}'} if token else {},
extra_http_headers=headers,
timeout=_API_TIMEOUT_MS,
)
self.api_contexts.append(context)
Expand Down
10 changes: 8 additions & 2 deletions ruoyi-fastapi-test/monitor/test_job_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,13 @@ async def edit_job(self, job_name: str, new_job_name: str) -> None:
async def toggle_job_status(self, job_name: str, enabled: bool) -> None:
switch = self.job_row(job_name).locator('.ant-switch' if self.is_react else '.el-switch')
await switch.click()
confirm = self.page.get_by_role('dialog').get_by_role('button', name=button_name('确定'))
action = '启用' if enabled else '暂停|停用'
dialog = (
self.page.get_by_role('dialog').filter(has_text=re.compile(rf'(?:{action})任务')).filter(has_text=job_name)
)
confirm = dialog.get_by_role('button', name=button_name('确定'))
mutation = await self.submit(confirm.click, 'PUT', '/monitor/job/changeStatus')
await expect(dialog).to_be_hidden()
await self.wait_for_sync(mutation)
await self.search_job(job_name)
if enabled:
Expand All @@ -167,7 +172,8 @@ async def run_job_once(self, job_name: str) -> str:
.get_by_text('执行一次', exact=True)
.click()
)
confirm = self.page.get_by_role('dialog').get_by_role('button', name=button_name('确定'))
dialog = self.page.get_by_role('dialog').filter(has_text='立即执行一次任务').filter(has_text=job_name)
confirm = dialog.get_by_role('button', name=button_name('确定'))
execution = await self.submit(confirm.click, 'PUT', '/monitor/job/run')
execution_id = execution['executionId']
result = await self.poll_api(
Expand Down
36 changes: 21 additions & 15 deletions ruoyi-fastapi-test/tool/test_code_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,26 @@ async def edit_table(self) -> None:
assert listed['rows'][0]['tableComment'] == self.table_comment
await expect(self.table_row()).to_contain_text(self.table_comment)

async def select_preview_file(self, dialog: Locator, name: str) -> None:
"""通过预览标签或弹窗内的溢出菜单切换到指定文件。"""
tab = dialog.get_by_role('tab', name=name, exact=True)
target = tab
menu = dialog.get_by_role('listbox')
more = dialog.locator('button[aria-haspopup="listbox"]')
if self.is_react and await more.is_visible():
await more.click()
await expect(menu).to_be_visible()
option = menu.get_by_role('option', name=name, exact=True)
if await option.count():
target = option
else:
await more.click()
await expect(menu).to_be_hidden()
await target.click()
await expect(tab).to_have_attribute('aria-selected', 'true')
if self.is_react:
await expect(menu).to_be_hidden()

async def preview_and_download(self) -> None:
"""核对预览接口、可见 Python 代码和实际下载 ZIP 的内容。"""
async with self.page.expect_response(
Expand All @@ -133,21 +153,7 @@ async def preview_and_download(self) -> None:
assert any('/zh-CN/' in name for name in locale_files), code.keys()
assert any('/en-US/' in name for name in locale_files), code.keys()
for name, source in locale_files.items():
tab = dialog.get_by_role('tab', name=name, exact=True)
more = dialog.locator('.ant-tabs-nav-more')
if self.is_react and await more.is_visible():
# 通过溢出菜单选择被裁切的标签,避免自动滚动与 Tabs 的焦点滚动相互干扰。
await more.hover()
menu = self.page.locator('.ant-tabs-dropdown:visible').get_by_role('listbox')
await expect(menu).to_be_visible()
option = menu.get_by_role('option', name=name, exact=True)
if await option.count():
await option.click()
else:
await tab.click()
else:
await tab.click()
await expect(tab).to_have_attribute('aria-selected', 'true')
await self.select_preview_file(dialog, name)
preview = dialog.locator('pre:visible').first
await expect(preview).to_have_text(source)
rendered = await preview.inner_text()
Expand Down
Loading