#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
模块名称：create_meeting_cases_v2.py
模块描述：补充会议管理模块可执行测试用例（第二批次）

基于对被测系统的实际探索，补充以下功能点：
1. 会议列表操作：查看详情、结束会议、延长会议、取消预约、修改预约
2. 会议模板功能：新增、编辑、删除、批量删除
3. 个人日程功能：会议卡片、创建入口、日期切换
4. 会议室列表功能：筛选、预约、预览详情
5. 预定数据功能：多条件筛选
6. 会议类型特定：视讯会议、普通会议、周期会议

作者：czj
创建日期：2026-07-20
"""

import asyncio
import httpx
import sys

BASE_URL = "http://localhost:8001"

# 被测系统真实信息
TARGET_URL = "https://192.168.5.44"
USERNAME = "admin@xty"
PASSWORD = "Ubains@13579"
CAPTCHA = "csba"

# 会议管理模块ID（已存在）
MEETING_MODULE_ID = "module_e80a5d08b48d4c67a16cb86156320f25"

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


async def create_cases():
    """创建所有补充用例"""
    async with httpx.AsyncClient(timeout=60) as client:
        created_count = 0

        # ==================== Phase 1: 会议列表操作类用例 ====================
        print("=" * 60)
        print("【Phase 1】会议列表操作类用例")
        print("=" * 60)

        phase1_cases = build_phase1_cases()
        for case in phase1_cases:
            r = await client.post(f"{BASE_URL}/api/cases", json=case)
            if r.status_code == 201:
                print(f"  ✅ {case['name']}")
                created_count += 1
            else:
                print(f"  ❌ {case['name']}: {r.status_code} {r.text[:100]}")

        # ==================== Phase 2: 会议模板功能用例 ====================
        print("\n" + "=" * 60)
        print("【Phase 2】会议模板功能用例")
        print("=" * 60)

        phase2_cases = build_phase2_cases()
        for case in phase2_cases:
            r = await client.post(f"{BASE_URL}/api/cases", json=case)
            if r.status_code == 201:
                print(f"  ✅ {case['name']}")
                created_count += 1
            else:
                print(f"  ❌ {case['name']}: {r.status_code} {r.text[:100]}")

        # ==================== Phase 3: 个人日程功能用例 ====================
        print("\n" + "=" * 60)
        print("【Phase 3】个人日程功能用例")
        print("=" * 60)

        phase3_cases = build_phase3_cases()
        for case in phase3_cases:
            r = await client.post(f"{BASE_URL}/api/cases", json=case)
            if r.status_code == 201:
                print(f"  ✅ {case['name']}")
                created_count += 1
            else:
                print(f"  ❌ {case['name']}: {r.status_code} {r.text[:100]}")

        # ==================== Phase 4: 会议室列表功能用例 ====================
        print("\n" + "=" * 60)
        print("【Phase 4】会议室列表功能用例")
        print("=" * 60)

        phase4_cases = build_phase4_cases()
        for case in phase4_cases:
            r = await client.post(f"{BASE_URL}/api/cases", json=case)
            if r.status_code == 201:
                print(f"  ✅ {case['name']}")
                created_count += 1
            else:
                print(f"  ❌ {case['name']}: {r.status_code} {r.text[:100]}")

        # ==================== Phase 5: 预定数据+会议类型用例 ====================
        print("\n" + "=" * 60)
        print("【Phase 5】预定数据+会议类型用例")
        print("=" * 60)

        phase5_cases = build_phase5_cases()
        for case in phase5_cases:
            r = await client.post(f"{BASE_URL}/api/cases", json=case)
            if r.status_code == 201:
                print(f"  ✅ {case['name']}")
                created_count += 1
            else:
                print(f"  ❌ {case['name']}: {r.status_code} {r.text[:100]}")

        # ==================== 汇总 ====================
        print("\n" + "=" * 60)
        print("【汇总】")
        print("=" * 60)
        print(f"  新增用例: {created_count} 个")

        stats = await client.get(f"{BASE_URL}/api/stats/overview")
        s = stats.json()
        print(f"  当前总用例: {s['cases']['total']} 个")


def nav_home_step(order):
    """导航到主页步骤"""
    return {
        "order": order,
        "name": "点击进入主页",
        "action": "navigate",
        "params": {"url": f"{TARGET_URL}/#/platform?platform=%2Fplatform%2F%23%2FHome"},
    }


def build_phase1_cases():
    """Phase 1: 会议列表操作类用例"""
    cases = []

    # 用例1: 会议列表-查看详情验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "会议列表-查看详情验证",
        "description": "点击操作菜单'查看详情'，验证弹窗显示会议基本信息",
        "priority": "high",
        "tags": ["会议列表", "操作菜单", "详情"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入会议列表", "action": "click",
             "params": {"selector": ".block:has-text('会议列表')"}},
            {"order": 3, "name": "等待表格加载", "action": "wait",
             "params": {"selector": ".el-table", "timeout": 10000}},
            {"order": 4, "name": "验证有会议数据", "action": "assert",
             "params": {"type": "element_count_min", "selector": ".el-table__row", "expected": "1"}},
            {"order": 5, "name": "点击操作菜单按钮", "action": "click",
             "params": {"selector": ".more"}},
            {"order": 6, "name": "等待菜单弹出", "action": "wait",
             "params": {"selector": ".el-popover:visible", "timeout": 5000}},
            {"order": 7, "name": "点击查看详情", "action": "click",
             "params": {"selectors": [
                 ".el-popover li:has-text('查看详情')",
                 ".el-popover .themeUl_li li:first-child"
             ]}},
            {"order": 8, "name": "等待详情弹窗", "action": "wait",
             "params": {"selector": ".el-dialog:visible", "timeout": 5000}},
            {"order": 9, "name": "验证弹窗标题", "action": "assert",
             "params": {"type": "contains", "selector": ".el-dialog__title", "expected": "会议基本信息"}},
            {"order": 10, "name": "验证弹窗内容包含会议名称", "action": "assert",
             "params": {"type": "contains", "selector": ".el-dialog__body", "expected": "会议名称"}},
            {"order": 11, "name": "关闭弹窗", "action": "click",
             "params": {"selector": ".el-dialog__headerbtn"}},
        ],
        "config": DEFAULT_CONFIG,
    })

    # 用例2: 会议列表-结束会议验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "会议列表-结束会议验证",
        "description": "点击操作菜单'结束会议'，验证确认弹窗并取消",
        "priority": "high",
        "tags": ["会议列表", "操作菜单", "结束会议"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入会议列表", "action": "click",
             "params": {"selector": ".block:has-text('会议列表')"}},
            {"order": 3, "name": "等待表格加载", "action": "wait",
             "params": {"selector": ".el-table", "timeout": 10000}},
            {"order": 4, "name": "点击操作菜单按钮", "action": "click",
             "params": {"selector": ".more"}},
            {"order": 5, "name": "等待菜单弹出", "action": "wait",
             "params": {"selector": ".el-popover:visible", "timeout": 5000}},
            {"order": 6, "name": "点击结束会议", "action": "click",
             "params": {"selectors": [
                 ".el-popover li:has-text('结束会议')",
                 ".el-popover .themeUl_li li:nth-child(4)"
             ]}},
            {"order": 7, "name": "等待确认弹窗", "action": "wait",
             "params": {"selector": ".el-message-box:visible", "timeout": 5000}},
            {"order": 8, "name": "验证确认提示", "action": "assert",
             "params": {"type": "contains", "selector": ".el-message-box__message", "expected": "结束"}},
            {"order": 9, "name": "点击取消", "action": "click",
             "params": {"selector": ".el-message-box button:has-text('取 消')"}},
        ],
        "config": DEFAULT_CONFIG,
    })

    # 用例3: 会议列表-延长会议验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "会议列表-延长会议验证",
        "description": "点击操作菜单'延长会议'，验证延长时间弹窗",
        "priority": "high",
        "tags": ["会议列表", "操作菜单", "延长会议"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入会议列表", "action": "click",
             "params": {"selector": ".block:has-text('会议列表')"}},
            {"order": 3, "name": "等待表格加载", "action": "wait",
             "params": {"selector": ".el-table", "timeout": 10000}},
            {"order": 4, "name": "点击操作菜单按钮", "action": "click",
             "params": {"selector": ".more"}},
            {"order": 5, "name": "等待菜单弹出", "action": "wait",
             "params": {"selector": ".el-popover:visible", "timeout": 5000}},
            {"order": 6, "name": "点击延长会议", "action": "click",
             "params": {"selectors": [
                 ".el-popover li:has-text('延长会议')",
                 ".el-popover .themeUl_li li:nth-child(5)"
             ]}},
            {"order": 7, "name": "等待延长弹窗", "action": "wait",
             "params": {"selector": ".el-dialog:visible, .el-message-box:visible", "timeout": 5000}},
            {"order": 8, "name": "验证延长提示", "action": "assert",
             "params": {"type": "contains", "selector": ".el-dialog__body, .el-message-box__message", "expected": "时间"}},
            {"order": 9, "name": "取消操作", "action": "click",
             "params": {"selectors": [
                 ".el-dialog button:has-text('取消')",
                 ".el-message-box button:has-text('取 消')"
             ]}},
        ],
        "config": DEFAULT_CONFIG,
    })

    # 用例4: 会议列表-取消预约会议验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "会议列表-取消预约会议验证",
        "description": "搜索预约状态的会议，执行取消操作",
        "priority": "high",
        "tags": ["会议列表", "操作菜单", "取消会议"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入会议列表", "action": "click",
             "params": {"selector": ".block:has-text('会议列表')"}},
            {"order": 3, "name": "等待表格加载", "action": "wait",
             "params": {"selector": ".el-table", "timeout": 10000}},
            {"order": 4, "name": "搜索预约会议", "action": "fill",
             "params": {"selector": "input[placeholder='请输入会议名称']", "value": "预约"}},
            {"order": 5, "name": "等待搜索结果", "action": "wait",
             "params": {"selector": ".el-table", "timeout": 5000}},
            {"order": 6, "name": "验证有预约会议", "action": "assert",
             "params": {"type": "element_count_min", "selector": ".el-table__row", "expected": "1"}},
            {"order": 7, "name": "点击操作菜单按钮", "action": "click",
             "params": {"selector": ".more"}},
            {"order": 8, "name": "等待菜单弹出", "action": "wait",
             "params": {"selector": ".el-popover:visible", "timeout": 5000}},
            {"order": 9, "name": "点击取消会议", "action": "click",
             "params": {"selectors": [
                 ".el-popover li:has-text('取消会议')",
                 ".el-popover .themeUl_li li:nth-child(3)"
             ]}},
            {"order": 10, "name": "等待确认弹窗", "action": "wait",
             "params": {"selector": ".el-message-box:visible", "timeout": 5000}},
            {"order": 11, "name": "点击取消按钮", "action": "click",
             "params": {"selector": ".el-message-box button:has-text('取 消')"}},
        ],
        "config": DEFAULT_CONFIG,
    })

    # 用例5: 会议列表-修改预约会议验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "会议列表-修改预约会议验证",
        "description": "搜索预约状态的会议，验证修改功能可用",
        "priority": "high",
        "tags": ["会议列表", "操作菜单", "修改会议"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入会议列表", "action": "click",
             "params": {"selector": ".block:has-text('会议列表')"}},
            {"order": 3, "name": "等待表格加载", "action": "wait",
             "params": {"selector": ".el-table", "timeout": 10000}},
            {"order": 4, "name": "搜索预约会议", "action": "fill",
             "params": {"selector": "input[placeholder='请输入会议名称']", "value": "预约"}},
            {"order": 5, "name": "等待搜索结果", "action": "wait",
             "params": {"selector": ".el-table", "timeout": 5000}},
            {"order": 6, "name": "点击操作菜单按钮", "action": "click",
             "params": {"selector": ".more"}},
            {"order": 7, "name": "等待菜单弹出", "action": "wait",
             "params": {"selector": ".el-popover:visible", "timeout": 5000}},
            {"order": 8, "name": "验证有修改会议选项", "action": "assert",
             "params": {"type": "element_exists", "selector": ".el-popover li:has-text('修改会议')"}},
            {"order": 9, "name": "点击修改会议", "action": "click",
             "params": {"selectors": [
                 ".el-popover li:has-text('修改会议')",
                 ".el-popover .themeUl_li li:nth-child(2)"
             ]}},
            {"order": 10, "name": "等待修改弹窗", "action": "wait",
             "params": {"selector": ".el-dialog:visible", "timeout": 5000}},
            {"order": 11, "name": "关闭弹窗", "action": "click",
             "params": {"selector": ".el-dialog__headerbtn"}},
        ],
        "config": DEFAULT_CONFIG,
    })

    # 用例6: 会议列表-不同状态操作验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "会议列表-不同状态操作验证",
        "description": "验证不同状态会议的操作菜单选项差异",
        "priority": "medium",
        "tags": ["会议列表", "操作菜单", "状态差异"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入会议列表", "action": "click",
             "params": {"selector": ".block:has-text('会议列表')"}},
            {"order": 3, "name": "等待表格加载", "action": "wait",
             "params": {"selector": ".el-table", "timeout": 10000}},
            {"order": 4, "name": "点击操作菜单按钮", "action": "click",
             "params": {"selector": ".more"}},
            {"order": 5, "name": "等待菜单弹出", "action": "wait",
             "params": {"selector": ".el-popover:visible", "timeout": 5000}},
            {"order": 6, "name": "验证有查看详情选项", "action": "assert",
             "params": {"type": "element_exists", "selector": ".el-popover li:has-text('查看详情')"}},
            {"order": 7, "name": "点击页面空白处关闭菜单", "action": "click",
             "params": {"selector": "body"}},
            {"order": 8, "name": "等待菜单关闭", "action": "wait",
             "params": {"selector": ".el-popover", "timeout": 2000}},
        ],
        "config": DEFAULT_CONFIG,
    })

    return cases


def build_phase2_cases():
    """Phase 2: 会议模板功能用例"""
    cases = []

    # 用例7: 会议模板-新增模板验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "会议模板-新增模板验证",
        "description": "点击新增模板，验证弹窗打开",
        "priority": "high",
        "tags": ["会议模板", "新增", "模板管理"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入会议模板", "action": "click",
             "params": {"selector": ".block:has-text('会议模板')"}},
            {"order": 3, "name": "等待表格加载", "action": "wait",
             "params": {"selector": ".el-table", "timeout": 10000}},
            {"order": 4, "name": "点击新增模板按钮", "action": "click",
             "params": {"selector": "button:has-text('新增模板')"}},
            {"order": 5, "name": "等待新增弹窗", "action": "wait",
             "params": {"selector": ".el-dialog:visible", "timeout": 5000}},
            {"order": 6, "name": "验证弹窗标题", "action": "assert",
             "params": {"type": "contains", "selector": ".el-dialog__title", "expected": "模板"}},
            {"order": 7, "name": "验证有模板名称输入框", "action": "assert",
             "params": {"type": "element_exists", "selector": ".el-dialog input"}},
            {"order": 8, "name": "关闭弹窗", "action": "click",
             "params": {"selector": ".el-dialog__headerbtn"}},
        ],
        "config": DEFAULT_CONFIG,
    })

    # 用例8: 会议模板-编辑模板验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "会议模板-编辑模板验证",
        "description": "编辑已有模板，验证编辑弹窗",
        "priority": "medium",
        "tags": ["会议模板", "编辑", "模板管理"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入会议模板", "action": "click",
             "params": {"selector": ".block:has-text('会议模板')"}},
            {"order": 3, "name": "等待表格加载", "action": "wait",
             "params": {"selector": ".el-table", "timeout": 10000}},
            {"order": 4, "name": "验证有模板数据", "action": "assert",
             "params": {"type": "element_count_min", "selector": ".el-table__row", "expected": "1"}},
            {"order": 5, "name": "点击编辑按钮", "action": "click",
             "params": {"selectors": [
                 ".el-table__row:first-child button:has-text('编辑')",
                 ".el-table__row:first-child .el-button--text"
             ]}},
            {"order": 6, "name": "等待编辑弹窗", "action": "wait",
             "params": {"selector": ".el-dialog:visible", "timeout": 5000}},
            {"order": 7, "name": "验证弹窗标题", "action": "assert",
             "params": {"type": "contains", "selector": ".el-dialog__title", "expected": "模板"}},
            {"order": 8, "name": "关闭弹窗", "action": "click",
             "params": {"selector": ".el-dialog__headerbtn"}},
        ],
        "config": DEFAULT_CONFIG,
    })

    # 用例9: 会议模板-删除模板验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "会议模板-删除模板验证",
        "description": "删除单个模板，验证删除确认弹窗",
        "priority": "medium",
        "tags": ["会议模板", "删除", "模板管理"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入会议模板", "action": "click",
             "params": {"selector": ".block:has-text('会议模板')"}},
            {"order": 3, "name": "等待表格加载", "action": "wait",
             "params": {"selector": ".el-table", "timeout": 10000}},
            {"order": 4, "name": "验证有模板数据", "action": "assert",
             "params": {"type": "element_count_min", "selector": ".el-table__row", "expected": "1"}},
            {"order": 5, "name": "点击删除按钮", "action": "click",
             "params": {"selectors": [
                 ".el-table__row:first-child button:has-text('删除')",
                 ".el-table__row:first-child .el-button--danger"
             ]}},
            {"order": 6, "name": "等待确认弹窗", "action": "wait",
             "params": {"selector": ".el-message-box:visible", "timeout": 5000}},
            {"order": 7, "name": "点击取消", "action": "click",
             "params": {"selector": ".el-message-box button:has-text('取 消')"}},
        ],
        "config": DEFAULT_CONFIG,
    })

    # 用例10: 会议模板-批量删除验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "会议模板-批量删除验证",
        "description": "验证批量删除按钮存在且可点击",
        "priority": "medium",
        "tags": ["会议模板", "批量删除", "模板管理"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入会议模板", "action": "click",
             "params": {"selector": ".block:has-text('会议模板')"}},
            {"order": 3, "name": "等待表格加载", "action": "wait",
             "params": {"selector": ".el-table", "timeout": 10000}},
            {"order": 4, "name": "验证批量删除按钮存在", "action": "assert",
             "params": {"type": "element_exists", "selector": "button:has-text('批量删除')"}},
            {"order": 5, "name": "点击批量删除按钮", "action": "click",
             "params": {"selector": "button:has-text('批量删除')"}},
            {"order": 6, "name": "等待提示弹窗", "action": "wait",
             "params": {"selector": ".el-message-box:visible, .el-message:visible", "timeout": 5000}},
            {"order": 7, "name": "点击取消或关闭", "action": "click",
             "params": {"selectors": [
                 ".el-message-box button:has-text('取 消')",
                 ".el-message-box__headerbtn"
             ]}},
        ],
        "config": DEFAULT_CONFIG,
    })

    return cases


def build_phase3_cases():
    """Phase 3: 个人日程功能用例"""
    cases = []

    # 用例11: 个人日程-会议卡片验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "个人日程-会议卡片验证",
        "description": "验证进行中会议卡片显示正确信息",
        "priority": "medium",
        "tags": ["个人日程", "会议卡片", "日程管理"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入个人日程", "action": "click",
             "params": {"selector": ".block:has-text('个人日程')"}},
            {"order": 3, "name": "等待页面加载", "action": "wait",
             "params": {"selector": "body", "timeout": 10000}},
            {"order": 4, "name": "验证有会议信息", "action": "assert",
             "params": {"type": "contains", "selector": "body", "expected": "会议"}},
            {"order": 5, "name": "验证有会议时间信息", "action": "assert",
             "params": {"type": "contains", "selector": "body", "expected": "时间"}},
        ],
        "config": DEFAULT_CONFIG,
    })

    # 用例12: 个人日程-创建会议入口
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "个人日程-创建会议入口",
        "description": "从个人日程页面点击创建进入新建会议",
        "priority": "medium",
        "tags": ["个人日程", "创建会议", "快捷入口"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入个人日程", "action": "click",
             "params": {"selector": ".block:has-text('个人日程')"}},
            {"order": 3, "name": "等待页面加载", "action": "wait",
             "params": {"selector": "body", "timeout": 10000}},
            {"order": 4, "name": "点击创建按钮", "action": "click",
             "params": {"selector": "button:has-text('创建')"}},
            {"order": 5, "name": "等待跳转", "action": "wait",
             "params": {"selector": "input[placeholder='会议名称/会议议题']", "timeout": 10000}},
            {"order": 6, "name": "验证进入新建会议页面", "action": "assert",
             "params": {"type": "element_exists", "selector": "input[placeholder='会议名称/会议议题']"}},
        ],
        "config": DEFAULT_CONFIG,
    })

    # 用例13: 个人日程-日期切换验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "个人日程-日期切换验证",
        "description": "验证日期选择器切换日期功能",
        "priority": "low",
        "tags": ["个人日程", "日期选择", "日程管理"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入个人日程", "action": "click",
             "params": {"selector": ".block:has-text('个人日程')"}},
            {"order": 3, "name": "等待页面加载", "action": "wait",
             "params": {"selector": "body", "timeout": 10000}},
            {"order": 4, "name": "验证日期选择器存在", "action": "assert",
             "params": {"type": "element_exists", "selector": ".el-date-editor"}},
        ],
        "config": DEFAULT_CONFIG,
    })

    return cases


def build_phase4_cases():
    """Phase 4: 会议室列表功能用例"""
    cases = []

    # 用例14: 会议室列表-筛选功能验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "会议室列表-筛选功能验证",
        "description": "使用容纳人数、日期、名称筛选会议室",
        "priority": "high",
        "tags": ["会议室列表", "筛选", "查询"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入会议室列表", "action": "click",
             "params": {"selector": ".block:has-text('会议室列表')"}},
            {"order": 3, "name": "等待页面加载", "action": "wait",
             "params": {"selector": "body", "timeout": 10000}},
            {"order": 4, "name": "验证有筛选输入框", "action": "assert",
             "params": {"type": "element_count_min", "selector": "input.el-input__inner", "expected": "2"}},
            {"order": 5, "name": "填写会议室名称", "action": "fill",
             "params": {"selector": "input[placeholder='会议室名称']", "value": "会议室"}},
            {"order": 6, "name": "点击确定筛选", "action": "click",
             "params": {"selector": "button:has-text('确定')"}},
            {"order": 7, "name": "等待筛选结果", "action": "wait",
             "params": {"selector": "body", "timeout": 5000}},
        ],
        "config": DEFAULT_CONFIG,
    })

    # 用例15: 会议室列表-预约会议验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "会议室列表-预约会议验证",
        "description": "从会议室列表发起会议预约",
        "priority": "high",
        "tags": ["会议室列表", "预约会议", "快捷入口"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入会议室列表", "action": "click",
             "params": {"selector": ".block:has-text('会议室列表')"}},
            {"order": 3, "name": "等待页面加载", "action": "wait",
             "params": {"selector": "body", "timeout": 10000}},
            {"order": 4, "name": "点击新建会议按钮", "action": "click",
             "params": {"selector": "button:has-text('新建会议')"}},
            {"order": 5, "name": "等待跳转到新建会议", "action": "wait",
             "params": {"selector": "input[placeholder='会议名称/会议议题']", "timeout": 10000}},
            {"order": 6, "name": "验证进入新建会议页面", "action": "assert",
             "params": {"type": "element_exists", "selector": "input[placeholder='会议名称/会议议题']"}},
        ],
        "config": DEFAULT_CONFIG,
    })

    # 用例16: 会议室列表-预览详情验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "会议室列表-预览详情验证",
        "description": "点击预览按钮查看会议室详情",
        "priority": "medium",
        "tags": ["会议室列表", "预览", "详情"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入会议室列表", "action": "click",
             "params": {"selector": ".block:has-text('会议室列表')"}},
            {"order": 3, "name": "等待页面加载", "action": "wait",
             "params": {"selector": "body", "timeout": 10000}},
            {"order": 4, "name": "验证有预览按钮", "action": "assert",
             "params": {"type": "element_exists", "selector": "button:has-text('预览')"}},
        ],
        "config": DEFAULT_CONFIG,
    })

    return cases


def build_phase5_cases():
    """Phase 5: 预定数据+会议类型用例"""
    cases = []

    # 用例17: 预定数据-多条件筛选验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "预定数据-多条件筛选验证",
        "description": "使用多个下拉选择框组合筛选",
        "priority": "high",
        "tags": ["预定数据", "筛选", "数据分析"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入预定数据", "action": "click",
             "params": {"selector": ".block:has-text('预定数据')"}},
            {"order": 3, "name": "等待页面加载", "action": "wait",
             "params": {"selector": "body", "timeout": 10000}},
            {"order": 4, "name": "验证有多个筛选下拉框", "action": "assert",
             "params": {"type": "element_count_min", "selector": ".el-select", "expected": "5"}},
        ],
        "config": DEFAULT_CONFIG,
    })

    # 用例18: 新建会议-视讯会议验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "新建会议-视讯会议验证",
        "description": "创建视讯会议类型会议",
        "priority": "medium",
        "tags": ["新建会议", "会议类型", "视讯会议"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入新建会议", "action": "click",
             "params": {"selector": ".block:has-text('新建会议')"}},
            {"order": 3, "name": "等待表单加载", "action": "wait",
             "params": {"selector": "input[placeholder='会议名称/会议议题']", "timeout": 10000}},
            {"order": 4, "name": "填写会议名称", "action": "fill",
             "params": {"selector": "input[placeholder='会议名称/会议议题']", "value": "视讯会议测试用例"}},
            {"order": 5, "name": "选择视讯会议类型", "action": "click",
             "params": {"selector": ".el-radio:has-text('视讯会议')"}},
            {"order": 6, "name": "验证视讯会议被选中", "action": "assert",
             "params": {"type": "element_exists", "selector": ".el-radio:has-text('视讯会议').is-checked, .el-radio:has-text('视讯会议') input:checked"}},
        ],
        "config": DEFAULT_CONFIG,
    })

    # 用例19: 新建会议-普通会议验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "新建会议-普通会议验证",
        "description": "创建普通会议类型会议",
        "priority": "medium",
        "tags": ["新建会议", "会议类型", "普通会议"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入新建会议", "action": "click",
             "params": {"selector": ".block:has-text('新建会议')"}},
            {"order": 3, "name": "等待表单加载", "action": "wait",
             "params": {"selector": "input[placeholder='会议名称/会议议题']", "timeout": 10000}},
            {"order": 4, "name": "填写会议名称", "action": "fill",
             "params": {"selector": "input[placeholder='会议名称/会议议题']", "value": "普通会议测试用例"}},
            {"order": 5, "name": "选择普通会议类型", "action": "click",
             "params": {"selector": ".el-radio:has-text('普通会议')"}},
            {"order": 6, "name": "验证普通会议被选中", "action": "assert",
             "params": {"type": "element_exists", "selector": ".el-radio:has-text('普通会议')"}},
        ],
        "config": DEFAULT_CONFIG,
    })

    # 用例20: 新建会议-周期会议验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "新建会议-周期会议验证",
        "description": "创建周期会议类型会议",
        "priority": "medium",
        "tags": ["新建会议", "会议类型", "周期会议"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入新建会议", "action": "click",
             "params": {"selector": ".block:has-text('新建会议')"}},
            {"order": 3, "name": "等待表单加载", "action": "wait",
             "params": {"selector": "input[placeholder='会议名称/会议议题']", "timeout": 10000}},
            {"order": 4, "name": "填写会议名称", "action": "fill",
             "params": {"selector": "input[placeholder='会议名称/会议议题']", "value": "周期会议测试用例"}},
            {"order": 5, "name": "选择周期会议类型", "action": "click",
             "params": {"selector": ".el-radio:has-text('周期会议')"}},
            {"order": 6, "name": "验证周期会议被选中", "action": "assert",
             "params": {"type": "element_exists", "selector": ".el-radio:has-text('周期会议')"}},
        ],
        "config": DEFAULT_CONFIG,
    })

    # 用例21: 新建会议-时间模式切换验证
    cases.append({
        "module_id": MEETING_MODULE_ID,
        "name": "新建会议-时间模式切换验证",
        "description": "验证立即开始和预定会议两种时间模式切换",
        "priority": "high",
        "tags": ["新建会议", "时间模式", "预约"],
        "steps": [
            nav_home_step(1),
            {"order": 2, "name": "点击进入新建会议", "action": "click",
             "params": {"selector": ".block:has-text('新建会议')"}},
            {"order": 3, "name": "等待表单加载", "action": "wait",
             "params": {"selector": "input[placeholder='会议名称/会议议题']", "timeout": 10000}},
            {"order": 4, "name": "验证立即开始按钮存在", "action": "assert",
             "params": {"type": "element_exists", "selector": ".time_btn:has-text('立即开始'), [class*=time]:has-text('立即开始')"}},
            {"order": 5, "name": "验证预定会议按钮存在", "action": "assert",
             "params": {"type": "element_exists", "selector": ".time_btn:has-text('预定会议'), [class*=time]:has-text('预定会议')"}},
            {"order": 6, "name": "点击预定会议", "action": "click",
             "params": {"selectors": [
                 ".time_btn:has-text('预定会议')",
                 "[class*=time]:has-text('预定会议')"
             ]}},
            {"order": 7, "name": "等待时间选择器出现", "action": "wait",
             "params": {"selector": "input[placeholder='选择时间']", "timeout": 5000}},
        ],
        "config": DEFAULT_CONFIG,
    })

    return cases


if __name__ == "__main__":
    asyncio.run(create_cases())
    print("\n🎉 会议管理模块补充用例创建完成！")