123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Debug信息保留简单测试</title>
- <style>
- body {
- font-family: Arial, sans-serif;
- margin: 20px;
- background-color: #f5f5f5;
- }
- .container {
- max-width: 800px;
- margin: 0 auto;
- background-color: white;
- padding: 20px;
- border-radius: 8px;
- box-shadow: 0 2px 10px rgba(0,0,0,0.1);
- }
- h1 {
- color: #333;
- text-align: center;
- }
- .test-button {
- background-color: #007bff;
- color: white;
- border: none;
- padding: 15px 30px;
- border-radius: 5px;
- cursor: pointer;
- font-size: 16px;
- margin: 10px;
- width: 100%;
- }
- .test-button:hover {
- background-color: #0056b3;
- }
- .result {
- margin-top: 20px;
- padding: 15px;
- border-radius: 5px;
- white-space: pre-wrap;
- font-family: 'Courier New', monospace;
- font-size: 12px;
- max-height: 500px;
- overflow-y: auto;
- }
- .success {
- background-color: #d4edda;
- border: 1px solid #c3e6cb;
- color: #155724;
- }
- .error {
- background-color: #f8d7da;
- border: 1px solid #f5c6cb;
- color: #721c24;
- }
- .info {
- background-color: #d1ecf1;
- border: 1px solid #bee5eb;
- color: #0c5460;
- }
- .debug-field {
- background-color: #fff3cd;
- border: 1px solid #ffeaa7;
- color: #856404;
- padding: 5px;
- margin: 2px 0;
- border-radius: 3px;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <h1>Debug信息保留功能测试</h1>
-
- <p>此页面用于测试工伤接口的debug信息是否正确保留。点击下面的按钮进行测试:</p>
-
- <button class="test-button" onclick="testDebugPreservation()">
- 测试Debug信息保留功能
- </button>
-
- <div id="result" class="result" style="display: none;"></div>
- </div>
- <script>
- const API_BASE_URL = 'http://localhost:8321/api/entry/workinjury';
-
- async function testDebugPreservation() {
- const resultDiv = document.getElementById('result');
- resultDiv.style.display = 'block';
- resultDiv.className = 'result info';
- resultDiv.textContent = '正在测试...';
-
- try {
- // 测试初始化接口
- const requestData = {
- action: "init",
- timestamp: new Date().toISOString(),
- config: {
- fixmedinsCode: "SQ201348",
- fixmedinsName: "沭阳铭和医院",
- interfaceVersion: "V2.1"
- }
- };
-
- const response = await fetch(API_BASE_URL, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify(requestData)
- });
-
- const result = await response.json();
-
- // 检查debug信息是否完整
- const requiredDebugFields = [
- 'debug_entry_time',
- 'debug_method_entered',
- 'debug_stage',
- 'debug_timestamp',
- 'debug_step'
- ];
-
- const presentFields = [];
- const missingFields = [];
-
- requiredDebugFields.forEach(field => {
- if (result[field] !== undefined && result[field] !== null) {
- presentFields.push(field);
- } else {
- missingFields.push(field);
- }
- });
-
- // 生成测试报告
- let report = `=== Debug信息保留测试报告 ===\n\n`;
- report += `HTTP状态: ${response.status}\n`;
- report += `API成功: ${result.success}\n`;
- report += `返回代码: ${result.code}\n`;
- report += `消息: ${result.message}\n\n`;
-
- report += `=== Debug信息完整性检查 ===\n`;
- report += `必需字段数: ${requiredDebugFields.length}\n`;
- report += `存在字段数: ${presentFields.length}\n`;
- report += `缺失字段数: ${missingFields.length}\n`;
- report += `完整性: ${missingFields.length === 0 ? '✅ 完整' : '❌ 不完整'}\n\n`;
-
- if (presentFields.length > 0) {
- report += `=== 存在的Debug字段 ===\n`;
- presentFields.forEach(field => {
- report += `✅ ${field}: ${result[field]}\n`;
- });
- report += `\n`;
- }
-
- if (missingFields.length > 0) {
- report += `=== 缺失的Debug字段 ===\n`;
- missingFields.forEach(field => {
- report += `❌ ${field}: 缺失\n`;
- });
- report += `\n`;
- }
-
- report += `=== 测试结论 ===\n`;
- if (missingFields.length === 0) {
- report += `🎉 测试通过!所有必需的debug信息都被正确保留。\n`;
- report += `✅ Debug信息保留功能工作正常。\n`;
- } else {
- report += `⚠️ 测试失败!部分debug信息丢失。\n`;
- report += `❌ 需要检查代码中的debug信息保留逻辑。\n`;
- }
-
- report += `\n=== 完整响应数据 ===\n`;
- report += JSON.stringify(result, null, 2);
-
- // 设置结果显示样式
- resultDiv.className = missingFields.length === 0 ? 'result success' : 'result error';
- resultDiv.textContent = report;
-
- } catch (error) {
- resultDiv.className = 'result error';
- resultDiv.textContent = `测试失败: ${error.message}\n\n请确保:\n1. 工伤接口服务正在运行\n2. 服务地址为: ${API_BASE_URL}\n3. 网络连接正常`;
- }
- }
- </script>
- </body>
- </html>
|