#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
模块名称：create_deep_cases_func_center_v3.py
模块描述：补充功能中心各模块深层交互测试用例（v3版本）

覆盖模块：
- 会议运维（12个用例）
- 集控控制（22个用例）
- 资产管理（6个用例）
- 维护工单（8个用例）
- 会务管理（4个用例）
- 信息管理（6个用例）
- 信息发布（1个用例）
- 其他分类（8个用例）
- 数据分析补充（6个用例）

总计：73个深层交互用例

设计原则：
1. 每个页面至少2个深层交互用例（表格验证 + 交互验证）
2. 断言策略宽松优先：element_exists > visible, element_count_min > count
3. 选择器策略：使用 selectors 回退链
4. 等待策略：三段式（特征元素 + 渲染 + 额外等待）
5. 状态重置：每个用例末尾添加"回到首页"步骤
6. auto_login=True，步骤中不包含登录步骤

作者：czj
创建日期：2026-07-23
最后修改日期：2026-07-23
"""

import asyncio
import httpx
import sys

BASE_URL = "http://localhost:8001"
TARGET_URL = "https://192.168.5.44"

# 模块ID
MODULE_MEETING_OPS = "module_c9496f382be1430c958936d5cf473f62"       # 会议运维
MODULE_JIKONG = "module_parent_jikong"                                # 集控控制
MODULE_ASSET = "module_251aebd2e6dd4d09acda0eb179c35d23"             # 资产管理
MODULE_MAINTENANCE = "module_0b5e956ade4c4b188ec1a6826f71229c"       # 维护工单
MODULE_MEETING_SERVICE = "module_69cba085ed3c4b8288a363de7b97aa63"   # 会务管理
MODULE_INFO_MGMT = "module_parent_xinxiguanli"                       # 信息管理
MODULE_INFO_PUBLISH = "module_parent_xinxifabu"                      # 信息发布
MODULE_OTHER = "module_parent_qita"                                   # 其他分类
MODULE_DATA_ANALYSIS = "module_6790b99750114326b539458f322f3be8"     # 数据分析

# 通用配置
DEFAULT_CONFIG = {
    "timeout": 120000,
    "screenshot": True,
    "auto_login": True,
    "step_retry_count": 2,
}


# ==================== 步骤模板函数 ====================


def build_func_center_navigate_steps(menu_name: str, wait_selector: str = "body",
                                     wait_timeout: int = 20000, order_start: int = 1):
    """
    构建功能中心抽屉导航步骤

    适用于：会议运维、集控控制、资产管理、维护工单、会务管理、信息管理、信息发布、其他分类

    步骤流程：等待首页 → 点击功能中心图标 → 等待抽屉 → 点击菜单 → 等待抽屉关闭 → 等待页面加载

    Args:
        menu_name: 功能中心抽屉内的菜单名称
        wait_selector: 页面加载后等待的特征元素选择器
        wait_timeout: 等待超时时间(ms)
        order_start: 起始步骤编号

    Returns:
        list[dict]: 步骤列表（6步）
    """
    return [
        {
            "order": order_start,
            "name": "等待首页加载",
            "action": "wait",
            "params": {"selector": ".block", "timeout": 15000},
        },
        {
            "order": order_start + 1,
            "name": "点击功能中心图标",
            "action": "click",
            "params": {"selector": ".home_nav_left"},
        },
        {
            "order": order_start + 2,
            "name": "等待抽屉打开",
            "action": "wait",
            "params": {"selector": ".el-drawer", "timeout": 15000},
        },
        {
            "order": order_start + 3,
            "name": f"点击{menu_name}",
            "action": "click",
            "params": {"selector": f".el-drawer >> text='{menu_name}'"},
        },
        {
            "order": order_start + 4,
            "name": "等待抽屉关闭",
            "action": "wait",
            "params": {"selector": "body", "timeout": 3000},
        },
        {
            "order": order_start + 5,
            "name": "等待页面加载",
            "action": "wait",
            "params": {"selector": wait_selector, "timeout": wait_timeout},
        },
    ]


def build_home_menu_navigate_steps(menu_name: str, wait_selector: str = "body",
                                   wait_timeout: int = 20000, order_start: int = 1):
    """
    构建首页菜单卡片导航步骤

    适用于：数据分析、管理看板、运维管理、会议管理

    步骤流程：点击菜单卡片 → 等待页面加载 → 等待页面渲染

    Args:
        menu_name: 菜单名称（对应 .block:has-text() 选择器）
        wait_selector: 页面加载后等待的特征元素选择器
        wait_timeout: 等待超时时间(ms)
        order_start: 起始步骤编号

    Returns:
        list[dict]: 步骤列表（3步）
    """
    return [
        {
            "order": order_start,
            "name": f"点击{menu_name}菜单",
            "action": "click",
            "params": {"selector": f'.block:has-text("{menu_name}")'},
        },
        {
            "order": order_start + 1,
            "name": "等待页面加载",
            "action": "wait",
            "params": {"selector": wait_selector, "timeout": wait_timeout},
        },
        {
            "order": order_start + 2,
            "name": "等待页面渲染",
            "action": "wait",
            "params": {"selector": "body", "timeout": 3000},
        },
    ]


def build_table_wait_steps(order_start: int):
    """
    构建表格等待步骤

    使用多选择器回退：.el-table -> .el-card -> .content -> body
    超时30s，适用于 Element UI 表格页面。

    Args:
        order_start: 起始步骤编号

    Returns:
        list[dict]: 步骤列表（2步）
    """
    return [
        {
            "order": order_start,
            "name": "等待表格加载",
            "action": "wait",
            "params": {"selectors": [".el-table", ".el-card", ".content", "body"], "timeout": 30000},
        },
        {
            "order": order_start + 1,
            "name": "等待表格渲染",
            "action": "wait",
            "params": {"selector": "body", "timeout": 3000},
        },
    ]


def build_filter_select_steps(select_index: int, order_start: int):
    """
    构建筛选器下拉选择步骤

    Args:
        select_index: 筛选器索引（0-based）
        order_start: 起始步骤编号

    Returns:
        list[dict]: 步骤列表（2步：点击下拉框 + 选择第一个选项）
    """
    input_selectors = [
        f".el-select:nth-child({select_index + 1}) .el-input__inner",
        f".el-select:nth-child({select_index + 1}) .el-select__input",
        f".el-select:nth-child({select_index + 1})",
        ".el-select .el-input__inner",
        ".el-select",
    ]
    option_selectors = [
        ".el-select-dropdown:visible .el-select-dropdown__item:first-child",
        ".el-select-dropdown__item:first-child",
    ]
    return [
        {
            "order": order_start,
            "name": f"点击第{select_index + 1}个筛选器",
            "action": "click",
            "params": {"selectors": input_selectors},
        },
        {
            "order": order_start + 1,
            "name": "选择第一个选项",
            "action": "click",
            "params": {"selectors": option_selectors, "timeout": 5000},
        },
    ]


def build_tab_switch_steps(tab_index: int, order_start: int, wait_selector: str = "body"):
    """
    构建Tab切换步骤

    Args:
        tab_index: Tab索引（0-based）
        order_start: 起始步骤编号
        wait_selector: 切换后等待的选择器

    Returns:
        list[dict]: 步骤列表（2步：点击Tab + 等待内容加载）
    """
    return [
        {
            "order": order_start,
            "name": f"点击第{tab_index + 1}个Tab",
            "action": "click",
            "params": {"selector": f".el-tabs__item:nth-child({tab_index + 1})"},
        },
        {
            "order": order_start + 1,
            "name": "等待内容加载",
            "action": "wait",
            "params": {"selector": wait_selector, "timeout": 5000},
        },
    ]


def build_canvas_wait_steps(order_start: int):
    """
    构建图表等待步骤

    Args:
        order_start: 起始步骤编号

    Returns:
        list[dict]: 步骤列表（2步）
    """
    return [
        {
            "order": order_start,
            "name": "等待图表加载",
            "action": "wait",
            "params": {
                "selectors": [".echarts", ".chart-container canvas", "canvas", "[class*='chart']"],
                "timeout": 30000,
            },
        },
        {
            "order": order_start + 1,
            "name": "等待图表渲染",
            "action": "wait",
            "params": {"selector": "body", "timeout": 3000},
        },
    ]


def build_navigate_home_step(order: int):
    """
    构建回到首页步骤（状态重置）

    Args:
        order: 步骤编号

    Returns:
        dict: 步骤字典
    """
    return {
        "order": order,
        "name": "回到首页",
        "action": "navigate",
        "params": {"url": TARGET_URL},
    }


# ==================== 各模块用例构建函数 ====================


def build_meeting_ops_cases():
    """构建会议运维模块深层交互用例（12个）"""
    cases = []

    # 1. 告警列表-表格数据验证
    cases.append({
        "name": "告警列表-表格数据验证",
        "description": "验证告警列表页面表格数据正常加载，表格组件存在",
        "module_id": MODULE_MEETING_OPS,
        "priority": "high",
        "order": 101,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("告警列表", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                {"order": 10, "name": "验证筛选器存在", "action": "assert",
                 "params": {"type": "element_count_min", "selector": ".el-select", "min_count": 1}},
                build_navigate_home_step(11),
            ],
    })

    # 2. 告警列表-筛选器交互验证
    cases.append({
        "name": "告警列表-筛选器交互验证",
        "description": "验证告警列表页面筛选器可正常操作，筛选后表格刷新",
        "module_id": MODULE_MEETING_OPS,
        "priority": "high",
        "order": 102,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("告警列表", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证筛选器存在", "action": "assert",
                 "params": {"type": "element_count_min", "selector": ".el-select", "min_count": 1}},
            ]
            + build_filter_select_steps(0, 10)  # 10-11
            + [
                {"order": 12, "name": "等待表格刷新", "action": "wait",
                 "params": {"selectors": [".el-table", ".el-card", "body"], "timeout": 10000}},
                {"order": 13, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(14),
            ],
    })

    # 3. 视讯设备-表格数据验证
    cases.append({
        "name": "视讯设备-表格数据验证",
        "description": "验证视讯设备页面表格和树形结构正常加载",
        "module_id": MODULE_MEETING_OPS,
        "priority": "high",
        "order": 103,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("视讯设备", ".el-table, .el-tree", 30000)  # 1-6
            + [
                {"order": 7, "name": "等待页面渲染", "action": "wait",
                 "params": {"selector": "body", "timeout": 3000}},
                {"order": 8, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-tree", "body"]}},
                {"order": 9, "name": "验证树形结构存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-tree", ".el-table", "body"]}},
                build_navigate_home_step(10),
            ],
    })

    # 4. 视讯设备-树形筛选验证
    cases.append({
        "name": "视讯设备-树形筛选验证",
        "description": "验证视讯设备页面树形结构可正常点击筛选",
        "module_id": MODULE_MEETING_OPS,
        "priority": "medium",
        "order": 104,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("视讯设备", ".el-tree, .el-table", 30000)  # 1-6
            + [
                {"order": 7, "name": "等待页面渲染", "action": "wait",
                 "params": {"selector": "body", "timeout": 3000}},
                {"order": 8, "name": "验证树形结构存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-tree", "body"]}},
                {"order": 9, "name": "点击树节点", "action": "click",
                 "params": {"selector": ".el-tree-node__content", "force": True}},
                {"order": 10, "name": "等待内容刷新", "action": "wait",
                 "params": {"selector": "body", "timeout": 3000}},
                {"order": 11, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", "body"]}},
                build_navigate_home_step(12),
            ],
    })

    # 5. 运维区域-表格数据验证
    cases.append({
        "name": "运维区域-表格数据验证",
        "description": "验证运维区域页面表格数据正常加载",
        "module_id": MODULE_MEETING_OPS,
        "priority": "high",
        "order": 105,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("运维区域", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                {"order": 10, "name": "验证筛选器存在", "action": "assert",
                 "params": {"type": "element_count_min", "selector": ".el-select", "min_count": 1}},
                build_navigate_home_step(11),
            ],
    })

    # 6. 运维区域-筛选器交互验证
    cases.append({
        "name": "运维区域-筛选器交互验证",
        "description": "验证运维区域页面筛选器可正常操作",
        "module_id": MODULE_MEETING_OPS,
        "priority": "medium",
        "order": 106,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("运维区域", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + build_filter_select_steps(0, 9)  # 9-10
            + [
                {"order": 11, "name": "等待表格刷新", "action": "wait",
                 "params": {"selectors": [".el-table", ".el-card", "body"], "timeout": 10000}},
                {"order": 12, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(13),
            ],
    })

    # 7. 会议巡检-表格数据验证
    cases.append({
        "name": "会议巡检-表格数据验证",
        "description": "验证会议巡检页面表格数据正常加载",
        "module_id": MODULE_MEETING_OPS,
        "priority": "high",
        "order": 107,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("会议巡检", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                {"order": 10, "name": "验证分页存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-pagination", "body"]}},
                build_navigate_home_step(11),
            ],
    })

    # 8. 会议巡检-分页验证
    cases.append({
        "name": "会议巡检-分页验证",
        "description": "验证会议巡检页面分页功能正常",
        "module_id": MODULE_MEETING_OPS,
        "priority": "medium",
        "order": 108,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("会议巡检", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证分页组件存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-pagination", "body"]}},
                {"order": 10, "name": "点击下一页", "action": "click",
                 "params": {"selector": ".el-pagination .btn-next", "force": True}},
                {"order": 11, "name": "等待表格刷新", "action": "wait",
                 "params": {"selectors": [".el-table", ".el-card", "body"], "timeout": 10000}},
                {"order": 12, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(13),
            ],
    })

    # 9. 运维巡检-页面元素验证
    cases.append({
        "name": "运维巡检-页面元素验证",
        "description": "验证运维巡检页面关键元素存在",
        "module_id": MODULE_MEETING_OPS,
        "priority": "high",
        "order": 109,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("运维巡检", "body", 20000)  # 1-6
            + [
                {"order": 7, "name": "等待页面渲染", "action": "wait",
                 "params": {"selector": "body", "timeout": 3000}},
                {"order": 8, "name": "验证页面主体存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", ".content", "body"]}},
                build_navigate_home_step(9),
            ],
    })

    # 10. 运维巡检-表格验证
    cases.append({
        "name": "运维巡检-表格验证",
        "description": "验证运维巡检页面表格数据加载",
        "module_id": MODULE_MEETING_OPS,
        "priority": "medium",
        "order": 110,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("运维巡检", ".el-table, .el-card, body", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(10),
            ],
    })

    # 11. 运维设备-表格数据验证
    cases.append({
        "name": "运维设备-表格数据验证",
        "description": "验证运维设备页面表格数据正常加载",
        "module_id": MODULE_MEETING_OPS,
        "priority": "high",
        "order": 111,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("运维设备", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                {"order": 10, "name": "验证筛选器存在", "action": "assert",
                 "params": {"type": "element_count_min", "selector": ".el-select", "min_count": 1}},
                build_navigate_home_step(11),
            ],
    })

    # 12. 运维设备-筛选器验证
    cases.append({
        "name": "运维设备-筛选器验证",
        "description": "验证运维设备页面筛选器可正常操作",
        "module_id": MODULE_MEETING_OPS,
        "priority": "medium",
        "order": 112,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("运维设备", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + build_filter_select_steps(0, 9)  # 9-10
            + [
                {"order": 11, "name": "等待表格刷新", "action": "wait",
                 "params": {"selectors": [".el-table", ".el-card", "body"], "timeout": 10000}},
                {"order": 12, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(13),
            ],
    })

    return cases


def build_jikong_cases():
    """构建集控控制模块深层交互用例（22个）"""
    cases = []

    # 集控控制页面列表（11个页面，每个2个用例）
    jikong_pages = [
        {"name": "文件推送", "has_table": True, "has_filter": True, "has_tab": False},
        {"name": "消息推送", "has_table": True, "has_filter": True, "has_tab": False},
        {"name": "转录列表", "has_table": True, "has_filter": False, "has_tab": True},
        {"name": "壁纸推送", "has_table": True, "has_filter": False, "has_tab": False},
        {"name": "脚本命令", "has_table": True, "has_filter": False, "has_tab": False},
        {"name": "应用管理", "has_table": True, "has_filter": False, "has_tab": False},
        {"name": "屏幕管理", "has_table": True, "has_filter": False, "has_tab": True},
        {"name": "软件卸载", "has_table": True, "has_filter": False, "has_tab": False},
        {"name": "设备网络", "has_table": True, "has_filter": False, "has_tab": False},
        {"name": "门口屏发布", "has_table": True, "has_filter": False, "has_tab": False},
        {"name": "播放器发布", "has_table": True, "has_filter": False, "has_tab": False},
    ]

    order_base = 201
    for i, page in enumerate(jikong_pages):
        page_name = page["name"]

        # 用例1: 表格数据验证
        cases.append({
            "name": f"{page_name}-表格数据验证",
            "description": f"验证{page_name}页面表格数据正常加载",
            "module_id": MODULE_JIKONG,
            "priority": "high",
            "order": order_base + i * 2,
            "config": DEFAULT_CONFIG,
            "steps":
                build_func_center_navigate_steps(page_name, ".el-table", 30000)  # 1-6
                + build_table_wait_steps(7)  # 7-8
                + [
                    {"order": 9, "name": "验证表格存在", "action": "assert",
                     "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                    build_navigate_home_step(10),
                ],
        })

        # 用例2: 交互验证（根据页面特征选择不同交互类型）
        if page["has_filter"]:
            # 筛选器验证
            cases.append({
                "name": f"{page_name}-筛选器验证",
                "description": f"验证{page_name}页面筛选器可正常操作",
                "module_id": MODULE_JIKONG,
                "priority": "medium",
                "order": order_base + i * 2 + 1,
                "config": DEFAULT_CONFIG,
                "steps":
                    build_func_center_navigate_steps(page_name, ".el-table", 30000)  # 1-6
                    + build_table_wait_steps(7)  # 7-8
                    + build_filter_select_steps(0, 9)  # 9-10
                    + [
                        {"order": 11, "name": "等待表格刷新", "action": "wait",
                         "params": {"selectors": [".el-table", ".el-card", "body"], "timeout": 10000}},
                        {"order": 12, "name": "验证表格存在", "action": "assert",
                         "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                        build_navigate_home_step(13),
                    ],
            })
        elif page["has_tab"]:
            # Tab切换验证
            cases.append({
                "name": f"{page_name}-Tab切换验证",
                "description": f"验证{page_name}页面Tab切换功能正常",
                "module_id": MODULE_JIKONG,
                "priority": "medium",
                "order": order_base + i * 2 + 1,
                "config": DEFAULT_CONFIG,
                "steps":
                    build_func_center_navigate_steps(page_name, ".el-tabs, .el-table", 30000)  # 1-6
                    + [
                        {"order": 7, "name": "等待页面渲染", "action": "wait",
                         "params": {"selector": "body", "timeout": 3000}},
                        {"order": 8, "name": "验证Tab存在", "action": "assert",
                         "params": {"type": "element_exists", "selector": ".el-tabs__item"}},
                    ]
                    + build_tab_switch_steps(1, 9)  # 9-10
                    + [
                        {"order": 11, "name": "验证内容区存在", "action": "assert",
                         "params": {"type": "element_exists", "selector": ".el-tabs__content"}},
                        build_navigate_home_step(12),
                    ],
            })
        else:
            # 页面元素验证
            cases.append({
                "name": f"{page_name}-页面元素验证",
                "description": f"验证{page_name}页面关键元素存在",
                "module_id": MODULE_JIKONG,
                "priority": "medium",
                "order": order_base + i * 2 + 1,
                "config": DEFAULT_CONFIG,
                "steps":
                    build_func_center_navigate_steps(page_name, "body", 20000)  # 1-6
                    + [
                        {"order": 7, "name": "等待页面渲染", "action": "wait",
                         "params": {"selector": "body", "timeout": 3000}},
                        {"order": 8, "name": "验证页面主体存在", "action": "assert",
                         "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", ".content", "body"]}},
                        {"order": 9, "name": "验证操作按钮存在", "action": "assert",
                         "params": {"type": "element_count_min", "selectors": ["button", ".el-button", "body"], "min_count": 1}},
                        build_navigate_home_step(10),
                    ],
            })

    return cases


def build_asset_cases():
    """构建资产管理模块深层交互用例（6个）"""
    cases = []

    # 1. 资产信息-表格数据验证
    cases.append({
        "name": "资产信息-表格数据验证",
        "description": "验证资产信息页面表格数据正常加载",
        "module_id": MODULE_ASSET,
        "priority": "high",
        "order": 301,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("资产信息", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                {"order": 10, "name": "验证筛选器存在", "action": "assert",
                 "params": {"type": "element_count_min", "selector": ".el-select", "min_count": 1}},
                build_navigate_home_step(11),
            ],
    })

    # 2. 资产信息-筛选器交互验证
    cases.append({
        "name": "资产信息-筛选器交互验证",
        "description": "验证资产信息页面筛选器可正常操作",
        "module_id": MODULE_ASSET,
        "priority": "medium",
        "order": 302,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("资产信息", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + build_filter_select_steps(0, 9)  # 9-10
            + [
                {"order": 11, "name": "等待表格刷新", "action": "wait",
                 "params": {"selectors": [".el-table", ".el-card", "body"], "timeout": 10000}},
                {"order": 12, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(13),
            ],
    })

    # 3. 资产故障-表格数据验证
    cases.append({
        "name": "资产故障-表格数据验证",
        "description": "验证资产故障页面表格数据正常加载",
        "module_id": MODULE_ASSET,
        "priority": "high",
        "order": 303,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("资产故障", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                {"order": 10, "name": "验证筛选器存在", "action": "assert",
                 "params": {"type": "element_count_min", "selector": ".el-select", "min_count": 1}},
                build_navigate_home_step(11),
            ],
    })

    # 4. 资产故障-筛选器交互验证
    cases.append({
        "name": "资产故障-筛选器交互验证",
        "description": "验证资产故障页面筛选器可正常操作",
        "module_id": MODULE_ASSET,
        "priority": "medium",
        "order": 304,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("资产故障", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + build_filter_select_steps(0, 9)  # 9-10
            + [
                {"order": 11, "name": "等待表格刷新", "action": "wait",
                 "params": {"selectors": [".el-table", ".el-card", "body"], "timeout": 10000}},
                {"order": 12, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(13),
            ],
    })

    # 5. 资产设备-表格数据验证
    cases.append({
        "name": "资产设备-表格数据验证",
        "description": "验证资产设备页面表格数据正常加载",
        "module_id": MODULE_ASSET,
        "priority": "high",
        "order": 305,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("资产设备", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                {"order": 10, "name": "验证操作按钮存在", "action": "assert",
                 "params": {"type": "element_count_min", "selectors": ["button", ".el-button", "body"], "min_count": 1}},
                build_navigate_home_step(11),
            ],
    })

    # 6. 资产设备-操作按钮验证
    cases.append({
        "name": "资产设备-操作按钮验证",
        "description": "验证资产设备页面操作按钮可正常点击",
        "module_id": MODULE_ASSET,
        "priority": "medium",
        "order": 306,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("资产设备", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证操作按钮存在", "action": "assert",
                 "params": {"type": "element_count_min", "selectors": ["button", ".el-button", "body"], "min_count": 1}},
                build_navigate_home_step(10),
            ],
    })

    return cases


def build_maintenance_cases():
    """构建维护工单模块深层交互用例（8个）"""
    cases = []

    # 1. 信息窗管理-表格数据验证
    cases.append({
        "name": "信息窗管理-表格数据验证",
        "description": "验证信息窗管理页面表格数据正常加载",
        "module_id": MODULE_MAINTENANCE,
        "priority": "high",
        "order": 401,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("信息窗管理", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                {"order": 10, "name": "验证筛选器存在", "action": "assert",
                 "params": {"type": "element_count_min", "selector": ".el-select", "min_count": 1}},
                build_navigate_home_step(11),
            ],
    })

    # 2. 信息窗管理-筛选器验证
    cases.append({
        "name": "信息窗管理-筛选器验证",
        "description": "验证信息窗管理页面筛选器可正常操作",
        "module_id": MODULE_MAINTENANCE,
        "priority": "medium",
        "order": 402,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("信息窗管理", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + build_filter_select_steps(0, 9)  # 9-10
            + [
                {"order": 11, "name": "等待表格刷新", "action": "wait",
                 "params": {"selectors": [".el-table", ".el-card", "body"], "timeout": 10000}},
                {"order": 12, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(13),
            ],
    })

    # 3-4. 告警工单
    cases.append({
        "name": "告警工单-表格数据验证",
        "description": "验证告警工单页面表格数据正常加载",
        "module_id": MODULE_MAINTENANCE,
        "priority": "high",
        "order": 403,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("告警工单", ".el-table, .el-tabs, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(10),
            ],
    })

    cases.append({
        "name": "告警工单-Tab切换验证",
        "description": "验证告警工单页面Tab切换功能正常",
        "module_id": MODULE_MAINTENANCE,
        "priority": "medium",
        "order": 404,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("告警工单", ".el-tabs, .el-table", 30000)  # 1-6
            + [
                {"order": 7, "name": "等待页面渲染", "action": "wait",
                 "params": {"selector": "body", "timeout": 3000}},
                {"order": 8, "name": "验证Tab存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-tabs__item", "body"]}},
            ]
            + build_tab_switch_steps(1, 9)  # 9-10
            + [
                {"order": 11, "name": "验证内容区存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-tabs__content", ".el-table", "body"]}},
                build_navigate_home_step(12),
            ],
    })

    # 5-6. 工单列表
    cases.append({
        "name": "工单列表-表格数据验证",
        "description": "验证工单列表页面表格数据正常加载",
        "module_id": MODULE_MAINTENANCE,
        "priority": "high",
        "order": 405,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("工单列表", ".el-table, .el-tabs", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-tabs", "body"]}},
                build_navigate_home_step(10),
            ],
    })

    cases.append({
        "name": "工单列表-Tab切换验证",
        "description": "验证工单列表页面Tab切换功能正常",
        "module_id": MODULE_MAINTENANCE,
        "priority": "medium",
        "order": 406,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("工单列表", ".el-tabs, .el-table", 30000)  # 1-6
            + [
                {"order": 7, "name": "等待页面渲染", "action": "wait",
                 "params": {"selector": "body", "timeout": 3000}},
                {"order": 8, "name": "验证Tab存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-tabs__item", "body"]}},
            ]
            + build_tab_switch_steps(1, 9)  # 9-10
            + [
                {"order": 11, "name": "验证内容区存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-tabs__content", ".el-table", "body"]}},
                build_navigate_home_step(12),
            ],
    })

    # 7-8. 我的工单
    cases.append({
        "name": "我的工单-表格数据验证",
        "description": "验证我的工单页面表格数据正常加载",
        "module_id": MODULE_MAINTENANCE,
        "priority": "high",
        "order": 407,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("我的工单", ".el-table, .el-tabs, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(10),
            ],
    })

    cases.append({
        "name": "我的工单-Tab切换验证",
        "description": "验证我的工单页面Tab切换功能正常",
        "module_id": MODULE_MAINTENANCE,
        "priority": "medium",
        "order": 408,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("我的工单", ".el-tabs, .el-table", 30000)  # 1-6
            + [
                {"order": 7, "name": "等待页面渲染", "action": "wait",
                 "params": {"selector": "body", "timeout": 3000}},
                {"order": 8, "name": "验证Tab存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-tabs__item", "body"]}},
            ]
            + build_tab_switch_steps(1, 9)  # 9-10
            + [
                {"order": 11, "name": "验证内容区存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-tabs__content", ".el-table", "body"]}},
                build_navigate_home_step(12),
            ],
    })

    return cases


def build_meeting_service_cases():
    """构建会务管理模块深层交互用例（4个）"""
    cases = []

    # 1. 会务统筹-表格数据验证
    cases.append({
        "name": "会务统筹-表格数据验证",
        "description": "验证会务统筹页面表格数据正常加载",
        "module_id": MODULE_MEETING_SERVICE,
        "priority": "high",
        "order": 501,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("会务统筹", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                {"order": 10, "name": "验证筛选器存在", "action": "assert",
                 "params": {"type": "element_count_min", "selector": ".el-select", "min_count": 1}},
                build_navigate_home_step(11),
            ],
    })

    # 2. 会务统筹-筛选器验证
    cases.append({
        "name": "会务统筹-筛选器验证",
        "description": "验证会务统筹页面筛选器可正常操作",
        "module_id": MODULE_MEETING_SERVICE,
        "priority": "medium",
        "order": 502,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("会务统筹", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + build_filter_select_steps(0, 9)  # 9-10
            + [
                {"order": 11, "name": "等待表格刷新", "action": "wait",
                 "params": {"selectors": [".el-table", ".el-card", "body"], "timeout": 10000}},
                {"order": 12, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(13),
            ],
    })

    # 3. 会务工单-表格数据验证
    cases.append({
        "name": "会务工单-表格数据验证",
        "description": "验证会务工单页面表格数据正常加载",
        "module_id": MODULE_MEETING_SERVICE,
        "priority": "high",
        "order": 503,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("会务工单", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                {"order": 10, "name": "验证筛选器存在", "action": "assert",
                 "params": {"type": "element_count_min", "selector": ".el-select", "min_count": 1}},
                build_navigate_home_step(11),
            ],
    })

    # 4. 会务工单-筛选器验证
    cases.append({
        "name": "会务工单-筛选器验证",
        "description": "验证会务工单页面筛选器可正常操作",
        "module_id": MODULE_MEETING_SERVICE,
        "priority": "medium",
        "order": 504,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("会务工单", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + build_filter_select_steps(0, 9)  # 9-10
            + [
                {"order": 11, "name": "等待表格刷新", "action": "wait",
                 "params": {"selectors": [".el-table", ".el-card", "body"], "timeout": 10000}},
                {"order": 12, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(13),
            ],
    })

    return cases


def build_info_mgmt_cases():
    """构建信息管理模块深层交互用例（6个）"""
    cases = []

    # 1. 下载列表-表格数据验证
    cases.append({
        "name": "下载列表-表格数据验证",
        "description": "验证下载列表页面表格数据正常加载",
        "module_id": MODULE_INFO_MGMT,
        "priority": "high",
        "order": 601,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("下载列表", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                {"order": 10, "name": "验证筛选器存在", "action": "assert",
                 "params": {"type": "element_count_min", "selector": ".el-select", "min_count": 1}},
                build_navigate_home_step(11),
            ],
    })

    # 2. 下载列表-筛选器验证
    cases.append({
        "name": "下载列表-筛选器验证",
        "description": "验证下载列表页面筛选器可正常操作",
        "module_id": MODULE_INFO_MGMT,
        "priority": "medium",
        "order": 602,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("下载列表", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + build_filter_select_steps(0, 9)  # 9-10
            + [
                {"order": 11, "name": "等待表格刷新", "action": "wait",
                 "params": {"selectors": [".el-table", ".el-card", "body"], "timeout": 10000}},
                {"order": 12, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(13),
            ],
    })

    # 3. 文件列表-表格数据验证
    cases.append({
        "name": "文件列表-表格数据验证",
        "description": "验证文件列表页面表格数据正常加载",
        "module_id": MODULE_INFO_MGMT,
        "priority": "high",
        "order": 603,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("文件列表", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                {"order": 10, "name": "验证筛选器存在", "action": "assert",
                 "params": {"type": "element_count_min", "selector": ".el-select", "min_count": 1}},
                build_navigate_home_step(11),
            ],
    })

    # 4. 文件列表-筛选器验证
    cases.append({
        "name": "文件列表-筛选器验证",
        "description": "验证文件列表页面筛选器可正常操作",
        "module_id": MODULE_INFO_MGMT,
        "priority": "medium",
        "order": 604,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("文件列表", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + build_filter_select_steps(0, 9)  # 9-10
            + [
                {"order": 11, "name": "等待表格刷新", "action": "wait",
                 "params": {"selectors": [".el-table", ".el-card", "body"], "timeout": 10000}},
                {"order": 12, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(13),
            ],
    })

    # 5. 通讯录-表格数据验证
    cases.append({
        "name": "通讯录-表格数据验证",
        "description": "验证通讯录页面表格和树形结构正常加载",
        "module_id": MODULE_INFO_MGMT,
        "priority": "high",
        "order": 605,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("通讯录", ".el-table, .el-tree", 30000)  # 1-6
            + [
                {"order": 7, "name": "等待页面渲染", "action": "wait",
                 "params": {"selector": "body", "timeout": 3000}},
                {"order": 8, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-tree", "body"]}},
                {"order": 9, "name": "验证树形结构存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-tree", "body"]}},
                build_navigate_home_step(10),
            ],
    })

    # 6. 通讯录-树形筛选验证
    cases.append({
        "name": "通讯录-树形筛选验证",
        "description": "验证通讯录页面树形结构可正常点击筛选",
        "module_id": MODULE_INFO_MGMT,
        "priority": "medium",
        "order": 606,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("通讯录", ".el-tree, .el-table", 30000)  # 1-6
            + [
                {"order": 7, "name": "等待页面渲染", "action": "wait",
                 "params": {"selector": "body", "timeout": 3000}},
                {"order": 8, "name": "验证树形结构存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-tree", "body"]}},
                {"order": 9, "name": "点击树节点", "action": "click",
                 "params": {"selector": ".el-tree-node__content", "force": True}},
                {"order": 10, "name": "等待内容刷新", "action": "wait",
                 "params": {"selector": "body", "timeout": 3000}},
                {"order": 11, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", "body"]}},
                build_navigate_home_step(12),
            ],
    })

    return cases


def build_info_publish_cases():
    """构建信息发布模块深层交互用例（1个）"""
    cases = []

    # 1. 消息通知-表格数据验证
    cases.append({
        "name": "消息通知-表格数据验证",
        "description": "验证消息通知页面表格数据正常加载",
        "module_id": MODULE_INFO_PUBLISH,
        "priority": "high",
        "order": 701,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("消息通知", ".el-table, .el-card, body", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(10),
            ],
    })

    return cases


def build_other_cases():
    """构建其他分类模块深层交互用例（8个）"""
    cases = []

    # 1. 会议审批-表格数据验证
    cases.append({
        "name": "会议审批-表格数据验证",
        "description": "验证会议审批页面表格数据正常加载",
        "module_id": MODULE_OTHER,
        "priority": "high",
        "order": 801,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("会议审批", ".el-table, .el-tabs, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(10),
            ],
    })

    # 2. 会议审批-Tab切换验证
    cases.append({
        "name": "会议审批-Tab切换验证",
        "description": "验证会议审批页面Tab切换功能正常",
        "module_id": MODULE_OTHER,
        "priority": "medium",
        "order": 802,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("会议审批", ".el-tabs, .el-table", 30000)  # 1-6
            + [
                {"order": 7, "name": "等待页面渲染", "action": "wait",
                 "params": {"selector": "body", "timeout": 3000}},
                {"order": 8, "name": "验证Tab存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-tabs__item", "body"]}},
            ]
            + build_tab_switch_steps(1, 9)  # 9-10
            + [
                {"order": 11, "name": "验证内容区存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-tabs__content", ".el-table", "body"]}},
                build_navigate_home_step(12),
            ],
    })

    # 3. 历史记录-表格数据验证
    cases.append({
        "name": "历史记录-表格数据验证",
        "description": "验证历史记录页面表格数据正常加载",
        "module_id": MODULE_OTHER,
        "priority": "high",
        "order": 803,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("历史记录", ".el-table, .el-tabs, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(10),
            ],
    })

    # 4. 历史记录-Tab切换验证
    cases.append({
        "name": "历史记录-Tab切换验证",
        "description": "验证历史记录页面Tab切换功能正常",
        "module_id": MODULE_OTHER,
        "priority": "medium",
        "order": 804,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("历史记录", ".el-tabs, .el-table", 30000)  # 1-6
            + [
                {"order": 7, "name": "等待页面渲染", "action": "wait",
                 "params": {"selector": "body", "timeout": 3000}},
                {"order": 8, "name": "验证Tab存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-tabs__item", "body"]}},
            ]
            + build_tab_switch_steps(1, 9)  # 9-10
            + [
                {"order": 11, "name": "验证内容区存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-tabs__content", ".el-table", "body"]}},
                build_navigate_home_step(12),
            ],
    })

    # 5. 参会人模板-表格数据验证
    cases.append({
        "name": "参会人模板-表格数据验证",
        "description": "验证参会人模板页面表格数据正常加载",
        "module_id": MODULE_OTHER,
        "priority": "high",
        "order": 805,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("参会人模板", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                {"order": 10, "name": "验证操作按钮存在", "action": "assert",
                 "params": {"type": "element_count_min", "selectors": ["button", ".el-button", "body"], "min_count": 1}},
                build_navigate_home_step(11),
            ],
    })

    # 6. 参会人模板-操作按钮验证
    cases.append({
        "name": "参会人模板-操作按钮验证",
        "description": "验证参会人模板页面操作按钮可正常点击",
        "module_id": MODULE_OTHER,
        "priority": "medium",
        "order": 806,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("参会人模板", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证操作按钮存在", "action": "assert",
                 "params": {"type": "element_count_min", "selectors": ["button", ".el-button", "body"], "min_count": 1}},
                build_navigate_home_step(10),
            ],
    })

    # 7. 已预定会议-表格数据验证
    cases.append({
        "name": "已预定会议-表格数据验证",
        "description": "验证已预定会议页面表格数据正常加载",
        "module_id": MODULE_OTHER,
        "priority": "high",
        "order": 807,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("已预定会议", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + [
                {"order": 9, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                {"order": 10, "name": "验证筛选器存在", "action": "assert",
                 "params": {"type": "element_count_min", "selector": ".el-select", "min_count": 1}},
                build_navigate_home_step(11),
            ],
    })

    # 8. 已预定会议-筛选器验证
    cases.append({
        "name": "已预定会议-筛选器验证",
        "description": "验证已预定会议页面筛选器可正常操作",
        "module_id": MODULE_OTHER,
        "priority": "medium",
        "order": 808,
        "config": DEFAULT_CONFIG,
        "steps":
            build_func_center_navigate_steps("已预定会议", ".el-table, .el-card", 30000)  # 1-6
            + build_table_wait_steps(7)  # 7-8
            + build_filter_select_steps(0, 9)  # 9-10
            + [
                {"order": 11, "name": "等待表格刷新", "action": "wait",
                 "params": {"selectors": [".el-table", ".el-card", "body"], "timeout": 10000}},
                {"order": 12, "name": "验证表格存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", ".el-card", "body"]}},
                build_navigate_home_step(13),
            ],
    })

    return cases


def build_data_analysis_extra_cases():
    """构建数据分析模块补充深层交互用例（6个）"""
    cases = []

    # RSE会议统计
    cases.append({
        "name": "RSE会议统计-页面元素验证",
        "description": "验证RSE会议统计页面关键元素存在",
        "module_id": MODULE_DATA_ANALYSIS,
        "priority": "high",
        "order": 901,
        "config": DEFAULT_CONFIG,
        "steps":
            build_home_menu_navigate_steps("RSE会议统计", "body", 20000)  # 1-3
            + [
                {"order": 4, "name": "验证页面主体存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", "canvas", ".el-select", "body"]}},
                build_navigate_home_step(5),
            ],
    })

    cases.append({
        "name": "RSE会议统计-图表验证",
        "description": "验证RSE会议统计页面图表正常展示",
        "module_id": MODULE_DATA_ANALYSIS,
        "priority": "medium",
        "order": 902,
        "config": DEFAULT_CONFIG,
        "steps":
            build_home_menu_navigate_steps("RSE会议统计", "canvas", 30000)  # 1-3
            + build_canvas_wait_steps(4)  # 4-5
            + [
                {"order": 6, "name": "验证图表存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": ["canvas", ".echarts", "body"]}},
                build_navigate_home_step(7),
            ],
    })

    # SMC3.0会议统计
    cases.append({
        "name": "SMC3.0会议统计-页面元素验证",
        "description": "验证SMC3.0会议统计页面关键元素存在",
        "module_id": MODULE_DATA_ANALYSIS,
        "priority": "high",
        "order": 903,
        "config": DEFAULT_CONFIG,
        "steps":
            build_home_menu_navigate_steps("SMC3.0会议统计", "body", 20000)  # 1-3
            + [
                {"order": 4, "name": "验证页面主体存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", "canvas", ".el-select", "body"]}},
                build_navigate_home_step(5),
            ],
    })

    cases.append({
        "name": "SMC3.0会议统计-图表验证",
        "description": "验证SMC3.0会议统计页面图表正常展示",
        "module_id": MODULE_DATA_ANALYSIS,
        "priority": "medium",
        "order": 904,
        "config": DEFAULT_CONFIG,
        "steps":
            build_home_menu_navigate_steps("SMC3.0会议统计", "canvas", 30000)  # 1-3
            + build_canvas_wait_steps(4)  # 4-5
            + [
                {"order": 6, "name": "验证图表存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": ["canvas", ".echarts", "body"]}},
                build_navigate_home_step(7),
            ],
    })

    # Welink会议统计
    cases.append({
        "name": "Welink会议统计-页面元素验证",
        "description": "验证Welink会议统计页面关键元素存在",
        "module_id": MODULE_DATA_ANALYSIS,
        "priority": "high",
        "order": 905,
        "config": DEFAULT_CONFIG,
        "steps":
            build_home_menu_navigate_steps("Welink会议统计", "body", 20000)  # 1-3
            + [
                {"order": 4, "name": "验证页面主体存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": [".el-table", "canvas", ".el-select", "body"]}},
                build_navigate_home_step(5),
            ],
    })

    cases.append({
        "name": "Welink会议统计-图表验证",
        "description": "验证Welink会议统计页面图表正常展示",
        "module_id": MODULE_DATA_ANALYSIS,
        "priority": "medium",
        "order": 906,
        "config": DEFAULT_CONFIG,
        "steps":
            build_home_menu_navigate_steps("Welink会议统计", "canvas", 30000)  # 1-3
            + build_canvas_wait_steps(4)  # 4-5
            + [
                {"order": 6, "name": "验证图表存在", "action": "assert",
                 "params": {"type": "element_exists", "selectors": ["canvas", ".echarts", "body"]}},
                build_navigate_home_step(7),
            ],
    })

    return cases


# ==================== 用例创建逻辑 ====================


async def update_or_create_case(client: httpx.AsyncClient, case_data: dict):
    """
    更新已有用例或创建新用例

    按名称查找已有用例，存在则更新，不存在则创建。

    Args:
        client: httpx 异步客户端
        case_data: 用例数据

    Returns:
        tuple: (action, result) action为"created"/"updated"/"failed"
    """
    case_name = case_data["name"]

    try:
        # 查找同名用例
        r = await client.get(f"{BASE_URL}/api/cases", params={"keyword": case_name})
        if r.status_code == 200:
            items = r.json().get("items", [])
            existing = [c for c in items if c["name"] == case_name]

            if existing:
                # 更新已有用例
                case_id = existing[0]["id"]
                r = await client.put(f"{BASE_URL}/api/cases/{case_id}", json=case_data)
                if r.status_code == 200:
                    print(f"  ✅ 更新: {case_name}")
                    return "updated", r.json()
                else:
                    print(f"  ❌ 更新失败: {case_name} - {r.text}")
                    return "failed", None

        # 创建新用例
        r = await client.post(f"{BASE_URL}/api/cases", json=case_data)
        if r.status_code == 200:
            print(f"  ✅ 创建: {case_name}")
            return "created", r.json()
        else:
            print(f"  ❌ 创建失败: {case_name} - {r.text}")
            return "failed", None

    except Exception as e:
        print(f"  ❌ 异常: {case_name} - {e}")
        return "failed", None


async def create_cases():
    """创建所有深层交互用例"""
    all_cases = []
    all_cases.extend(build_meeting_ops_cases())
    all_cases.extend(build_jikong_cases())
    all_cases.extend(build_asset_cases())
    all_cases.extend(build_maintenance_cases())
    all_cases.extend(build_meeting_service_cases())
    all_cases.extend(build_info_mgmt_cases())
    all_cases.extend(build_info_publish_cases())
    all_cases.extend(build_other_cases())
    all_cases.extend(build_data_analysis_extra_cases())

    print(f"\n共 {len(all_cases)} 个深层交互用例待创建/更新")
    print("=" * 60)

    async with httpx.AsyncClient(timeout=60) as client:
        created = 0
        updated = 0
        failed = 0

        for case in all_cases:
            action, result = await update_or_create_case(client, case)
            if action == "created":
                created += 1
            elif action == "updated":
                updated += 1
            else:
                failed += 1

    print("=" * 60)
    print(f"创建: {created}, 更新: {updated}, 失败: {failed}")
    print(f"总计: {created + updated + failed}")


if __name__ == "__main__":
    asyncio.run(create_cases())
