{
  "patterns": [
    {
      "patternId": "pattern-001",
      "name": "添加缺失的data-testid",
      "description": "为前端组件添加缺失的data-testid属性",
      "problemCategory": "missing_data_testid",
      "fixLevel": "level1",
      "matchConditions": {
        "errorMessagePattern": "waiting for selector.*data-testid",
        "affectedFilesPattern": "frontend/.*\\.(tsx|jsx)$"
      },
      "fixTemplate": {
        "filePattern": "frontend/**/*.{tsx,jsx}",
        "searchPattern": "<(button|input|div|span)([^>]*)(className=\"[^\"]*\")([^>]*)>",
        "replaceTemplate": "<$1$2 data-testid=\"{testid}\" $3$4>"
      },
      "examples": [
        {
          "before": "<button className=\"btn-primary\" onClick={handleSubmit}>",
          "after": "<button data-testid=\"submit-button\" className=\"btn-primary\" onClick={handleSubmit}>"
        }
      ],
      "riskLevel": "low",
      "verificationSteps": [
        "检查data-testid是否唯一",
        "运行回归测试",
        "验证无副作用"
      ]
    },
    {
      "patternId": "pattern-002",
      "name": "更新选择器",
      "description": "更新测试文档中的选择器以匹配前端变更",
      "problemCategory": "selector_changed",
      "fixLevel": "level1",
      "matchConditions": {
        "errorMessagePattern": "selector.*not found",
        "affectedFilesPattern": "docs/modules/.*/10-e2e-test-spec\\.md$"
      },
      "fixTemplate": {
        "filePattern": "docs/modules/**/10-e2e-test-spec.md",
        "searchPattern": "\\[data-testid=\"old-selector\"\\]",
        "replaceTemplate": "[data-testid=\"new-selector\"]"
      },
      "examples": [
        {
          "before": "[data-testid=\"old-submit-btn\"]",
          "after": "[data-testid=\"submit-button\"]"
        }
      ],
      "riskLevel": "low",
      "verificationSteps": [
        "验证新选择器在前端代码中存在",
        "运行回归测试"
      ]
    },
    {
      "patternId": "pattern-003",
      "name": "同步文案变更",
      "description": "同步前端文案变更到测试文档",
      "problemCategory": "outdated_doc_content",
      "fixLevel": "level1",
      "matchConditions": {
        "errorMessagePattern": "Expected.*but received",
        "affectedFilesPattern": "docs/modules/.*/10-e2e-test-spec\\.md$"
      },
      "fixTemplate": {
        "filePattern": "docs/modules/**/10-e2e-test-spec.md",
        "searchPattern": "验证.*显示\"旧文案\"",
        "replaceTemplate": "验证.*显示\"新文案\""
      },
      "examples": [
        {
          "before": "验证状态显示为\"审批通过\"",
          "after": "验证状态显示为\"已通过\""
        }
      ],
      "riskLevel": "low",
      "verificationSteps": [
        "确认新文案在前端代码中",
        "运行回归测试"
      ]
    },
    {
      "patternId": "pattern-004",
      "name": "更新API端点",
      "description": "更新测试文档中的API端点以匹配后端变更",
      "problemCategory": "api_change",
      "fixLevel": "level2",
      "matchConditions": {
        "errorMessagePattern": "404.*not found|api.*endpoint",
        "affectedFilesPattern": "docs/modules/.*/07-api\\.md$"
      },
      "fixTemplate": {
        "filePattern": "docs/modules/**/07-api.md",
        "searchPattern": "/api/v1/old-endpoint",
        "replaceTemplate": "/api/v2/new-endpoint"
      },
      "examples": [
        {
          "before": "GET /api/v1/users",
          "after": "GET /api/v2/users"
        }
      ],
      "riskLevel": "medium",
      "verificationSteps": [
        "确认新API端点在后端代码中",
        "检查API文档一致性",
        "运行API集成测试",
        "运行E2E回归测试"
      ]
    },
    {
      "patternId": "pattern-005",
      "name": "修复等待超时",
      "description": "增加等待时间或优化等待策略",
      "problemCategory": "performance_issue",
      "fixLevel": "level2",
      "matchConditions": {
        "errorMessagePattern": "timeout.*exceeded",
        "affectedFilesPattern": "docs/modules/.*/10-e2e-test-spec\\.md$"
      },
      "fixTemplate": {
        "filePattern": "docs/modules/**/10-e2e-test-spec.md",
        "searchPattern": "timeout: 30000",
        "replaceTemplate": "timeout: 60000"
      },
      "examples": [
        {
          "before": "等待元素加载（30秒超时）",
          "after": "等待元素加载（60秒超时）"
        }
      ],
      "riskLevel": "medium",
      "verificationSteps": [
        "分析性能瓶颈",
        "确认是否需要优化前端性能",
        "运行回归测试"
      ]
    },
    {
      "patternId": "pattern-006",
      "name": "修复权限问题",
      "description": "更新测试账号权限或使用正确的测试账号",
      "problemCategory": "business_logic_change",
      "fixLevel": "level2",
      "matchConditions": {
        "errorMessagePattern": "403.*forbidden|permission denied",
        "affectedFilesPattern": "docs/modules/.*/10-e2e-test-spec\\.md$"
      },
      "fixTemplate": {
        "filePattern": "docs/modules/**/10-e2e-test-spec.md",
        "searchPattern": "测试账号: employee",
        "replaceTemplate": "测试账号: manager"
      },
      "examples": [
        {
          "before": "使用employee账号测试",
          "after": "使用manager账号测试"
        }
      ],
      "riskLevel": "medium",
      "verificationSteps": [
        "确认权限变更是否符合业务规则",
        "更新权限文档",
        "运行权限相关测试"
      ]
    },
    {
      "patternId": "pattern-007",
      "name": "修复状态流转",
      "description": "更新状态机文档以匹配业务逻辑变更",
      "problemCategory": "business_logic_change",
      "fixLevel": "level3",
      "matchConditions": {
        "errorMessagePattern": "invalid state transition",
        "affectedFilesPattern": "docs/modules/.*/04-state-machine\\.md$"
      },
      "fixTemplate": {
        "filePattern": "docs/modules/**/04-state-machine.md",
        "searchPattern": "PENDING -> APPROVED",
        "replaceTemplate": "PENDING -> REVIEWING -> APPROVED"
      },
      "examples": [
        {
          "before": "PENDING -> APPROVED",
          "after": "PENDING -> REVIEWING -> APPROVED"
        }
      ],
      "riskLevel": "high",
      "verificationSteps": [
        "与产品确认状态流转变更",
        "更新所有相关文档",
        "更新后端状态机代码",
        "运行完整回归测试"
      ]
    },
    {
      "patternId": "pattern-008",
      "name": "修复安全问题",
      "description": "识别并标记安全相关问题",
      "problemCategory": "security_issue",
      "fixLevel": "level3",
      "matchConditions": {
        "errorMessagePattern": "security|xss|csrf|injection",
        "affectedFilesPattern": ".*"
      },
      "fixTemplate": {
        "filePattern": "N/A",
        "searchPattern": "N/A",
        "replaceTemplate": "N/A"
      },
      "examples": [
        {
          "before": "发现潜在XSS漏洞",
          "after": "需要安全团队评估和修复"
        }
      ],
      "riskLevel": "high",
      "verificationSteps": [
        "立即通知安全团队",
        "创建高优先级Issue",
        "暂停相关功能部署"
      ]
    },
    {
      "patternId": "pattern-009",
      "name": "修复架构问题",
      "description": "识别并标记架构相关问题",
      "problemCategory": "architecture_issue",
      "fixLevel": "level3",
      "matchConditions": {
        "errorMessagePattern": "architecture|design|refactor",
        "affectedFilesPattern": ".*"
      },
      "fixTemplate": {
        "filePattern": "N/A",
        "searchPattern": "N/A",
        "replaceTemplate": "N/A"
      },
      "examples": [
        {
          "before": "发现架构设计缺陷",
          "after": "需要架构师评估和重新设计"
        }
      ],
      "riskLevel": "high",
      "verificationSteps": [
        "召开架构评审会议",
        "制定重构计划",
        "评估影响范围"
      ]
    },
    {
      "patternId": "pattern-010",
      "name": "未知问题",
      "description": "无法自动分类的问题",
      "problemCategory": "unknown",
      "fixLevel": "level3",
      "matchConditions": {
        "errorMessagePattern": ".*",
        "affectedFilesPattern": ".*"
      },
      "fixTemplate": {
        "filePattern": "N/A",
        "searchPattern": "N/A",
        "replaceTemplate": "N/A"
      },
      "examples": [
        {
          "before": "未知错误",
          "after": "需要人工分析"
        }
      ],
      "riskLevel": "high",
      "verificationSteps": [
        "详细分析错误日志",
        "复现问题",
        "寻求团队帮助"
      ]
    }
  ]
}
