TBC/tests/monitor/tests/test_monitor_dashboard_ui.py
d-robotics 633a797226 AutoFlow v2.0: 合并 Test (Robogo) + data-loop-automation (D-Cloud) 为统一平台
- 16 个业务模块,856 个测试用例,40 个 E2E 测试
- 单一 React 19 前端 + PlatformSwitcher 二合一切换
- Flask 后端支持 scenario/dcloud_module/dcloud_e2e/dcloud_all 四种任务类型
- E2E 测试面板:API 全链路(8条) + UI 点击(3条) + 分步测试(3个)
- SSE 实时日志流 + 飞书告警 + 定时调度
- 完整还原原 ToB 平台 TestPanel E2E 模块
2026-06-23 11:48:29 +08:00

119 lines
4.3 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import pytest
from tests.monitor.monitor_dashboard_page import MonitorDashboardPage
@pytest.mark.ui
@pytest.mark.monitor
class TestMonitorDashboardPageLoad:
"""监控仪表盘页面加载测试"""
def test_page_loads(self, authenticated_page):
"""
描述:导航到监控仪表盘页面
预期:当前 URL 包含 monitor-dashboard,页面正常加载
"""
page = MonitorDashboardPage(authenticated_page)
page.navigate()
assert "monitor-dashboard" in page.get_url()
def test_resource_category_visible(self, authenticated_page):
"""
描述:检查「资源池类别」文本是否存在
预期:页面显示资源类别标签
"""
page = MonitorDashboardPage(authenticated_page)
page.navigate()
assert page.is_visible("text='资源池类别'")
def test_yearly_resource_radio_visible(self, authenticated_page):
"""
描述:检查「包年包月资源」单选按钮是否可见
预期:包年包月资源单选项可见
"""
page = MonitorDashboardPage(authenticated_page)
page.navigate()
assert authenticated_page.get_by_role("radio", name="包年包月资源").is_visible()
def test_elastic_resource_radio_visible(self, authenticated_page):
"""
描述:检查「弹性资源」单选按钮是否可见
预期:弹性资源单选项可见
"""
page = MonitorDashboardPage(authenticated_page)
page.navigate()
assert authenticated_page.get_by_role("radio", name="弹性资源").is_visible()
@pytest.mark.ui
@pytest.mark.monitor
class TestResourceCategorySelection:
"""监控仪表盘资源类型切换测试"""
def test_select_yearly_resource(self, authenticated_page):
"""
描述:点击「包年包月资源」单选按钮
预期:操作不抛出异常,资源类型切换成功
"""
page = MonitorDashboardPage(authenticated_page)
page.navigate()
authenticated_page.get_by_role("radio", name="包年包月资源").click()
def test_select_elastic_resource(self, authenticated_page):
"""
描述:点击「弹性资源」单选按钮
预期:操作不抛出异常,资源类型切换成功
"""
page = MonitorDashboardPage(authenticated_page)
page.navigate()
authenticated_page.get_by_role("radio", name="弹性资源").click()
@pytest.mark.ui
@pytest.mark.monitor
class TestTimeRangeDropdown:
"""监控仪表盘时间范围下拉测试"""
def test_time_range_default_value(self, authenticated_page):
"""
描述:检查时间范围下拉框是否有默认选中值
预期:页面存在至少一个下拉框选中项元素
"""
page = MonitorDashboardPage(authenticated_page)
page.navigate()
assert authenticated_page.locator(".ant-select-selection-item").count() > 0
def test_time_range_dropdown_opens(self, authenticated_page):
"""
描述:点击时间范围下拉框
预期:操作不抛出异常,下拉框响应点击
"""
page = MonitorDashboardPage(authenticated_page)
page.navigate()
time_dropdown = authenticated_page.locator(".ant-select").first
time_dropdown.click()
@pytest.mark.ui
@pytest.mark.monitor
class TestRefreshIntervalDropdown:
"""监控仪表盘刷新间隔下拉测试"""
def test_refresh_interval_default_value(self, authenticated_page):
"""
描述:检查刷新间隔下拉框是否有默认选中值
预期:页面存在至少两个下拉框选中项元素(时间范围+刷新间隔)
"""
page = MonitorDashboardPage(authenticated_page)
page.navigate()
assert authenticated_page.locator(".ant-select-selection-item").count() > 1
def test_refresh_interval_dropdown_opens(self, authenticated_page):
"""
描述:点击刷新间隔下拉框(第二个下拉框)
预期:操作不抛出异常,下拉框响应点击
"""
page = MonitorDashboardPage(authenticated_page)
page.navigate()
refresh_dropdown = authenticated_page.locator(".ant-select").nth(1)
refresh_dropdown.click()