test_debug_preservation_simple.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Debug信息保留简单测试</title>
  7. <style>
  8. body {
  9. font-family: Arial, sans-serif;
  10. margin: 20px;
  11. background-color: #f5f5f5;
  12. }
  13. .container {
  14. max-width: 800px;
  15. margin: 0 auto;
  16. background-color: white;
  17. padding: 20px;
  18. border-radius: 8px;
  19. box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  20. }
  21. h1 {
  22. color: #333;
  23. text-align: center;
  24. }
  25. .test-button {
  26. background-color: #007bff;
  27. color: white;
  28. border: none;
  29. padding: 15px 30px;
  30. border-radius: 5px;
  31. cursor: pointer;
  32. font-size: 16px;
  33. margin: 10px;
  34. width: 100%;
  35. }
  36. .test-button:hover {
  37. background-color: #0056b3;
  38. }
  39. .result {
  40. margin-top: 20px;
  41. padding: 15px;
  42. border-radius: 5px;
  43. white-space: pre-wrap;
  44. font-family: 'Courier New', monospace;
  45. font-size: 12px;
  46. max-height: 500px;
  47. overflow-y: auto;
  48. }
  49. .success {
  50. background-color: #d4edda;
  51. border: 1px solid #c3e6cb;
  52. color: #155724;
  53. }
  54. .error {
  55. background-color: #f8d7da;
  56. border: 1px solid #f5c6cb;
  57. color: #721c24;
  58. }
  59. .info {
  60. background-color: #d1ecf1;
  61. border: 1px solid #bee5eb;
  62. color: #0c5460;
  63. }
  64. .debug-field {
  65. background-color: #fff3cd;
  66. border: 1px solid #ffeaa7;
  67. color: #856404;
  68. padding: 5px;
  69. margin: 2px 0;
  70. border-radius: 3px;
  71. }
  72. </style>
  73. </head>
  74. <body>
  75. <div class="container">
  76. <h1>Debug信息保留功能测试</h1>
  77. <p>此页面用于测试工伤接口的debug信息是否正确保留。点击下面的按钮进行测试:</p>
  78. <button class="test-button" onclick="testDebugPreservation()">
  79. 测试Debug信息保留功能
  80. </button>
  81. <div id="result" class="result" style="display: none;"></div>
  82. </div>
  83. <script>
  84. const API_BASE_URL = 'http://localhost:8321/api/entry/workinjury';
  85. async function testDebugPreservation() {
  86. const resultDiv = document.getElementById('result');
  87. resultDiv.style.display = 'block';
  88. resultDiv.className = 'result info';
  89. resultDiv.textContent = '正在测试...';
  90. try {
  91. // 测试初始化接口
  92. const requestData = {
  93. action: "init",
  94. timestamp: new Date().toISOString(),
  95. config: {
  96. fixmedinsCode: "SQ201348",
  97. fixmedinsName: "沭阳铭和医院",
  98. interfaceVersion: "V2.1"
  99. }
  100. };
  101. const response = await fetch(API_BASE_URL, {
  102. method: 'POST',
  103. headers: {
  104. 'Content-Type': 'application/json',
  105. },
  106. body: JSON.stringify(requestData)
  107. });
  108. const result = await response.json();
  109. // 检查debug信息是否完整
  110. const requiredDebugFields = [
  111. 'debug_entry_time',
  112. 'debug_method_entered',
  113. 'debug_stage',
  114. 'debug_timestamp',
  115. 'debug_step'
  116. ];
  117. const presentFields = [];
  118. const missingFields = [];
  119. requiredDebugFields.forEach(field => {
  120. if (result[field] !== undefined && result[field] !== null) {
  121. presentFields.push(field);
  122. } else {
  123. missingFields.push(field);
  124. }
  125. });
  126. // 生成测试报告
  127. let report = `=== Debug信息保留测试报告 ===\n\n`;
  128. report += `HTTP状态: ${response.status}\n`;
  129. report += `API成功: ${result.success}\n`;
  130. report += `返回代码: ${result.code}\n`;
  131. report += `消息: ${result.message}\n\n`;
  132. report += `=== Debug信息完整性检查 ===\n`;
  133. report += `必需字段数: ${requiredDebugFields.length}\n`;
  134. report += `存在字段数: ${presentFields.length}\n`;
  135. report += `缺失字段数: ${missingFields.length}\n`;
  136. report += `完整性: ${missingFields.length === 0 ? '✅ 完整' : '❌ 不完整'}\n\n`;
  137. if (presentFields.length > 0) {
  138. report += `=== 存在的Debug字段 ===\n`;
  139. presentFields.forEach(field => {
  140. report += `✅ ${field}: ${result[field]}\n`;
  141. });
  142. report += `\n`;
  143. }
  144. if (missingFields.length > 0) {
  145. report += `=== 缺失的Debug字段 ===\n`;
  146. missingFields.forEach(field => {
  147. report += `❌ ${field}: 缺失\n`;
  148. });
  149. report += `\n`;
  150. }
  151. report += `=== 测试结论 ===\n`;
  152. if (missingFields.length === 0) {
  153. report += `🎉 测试通过!所有必需的debug信息都被正确保留。\n`;
  154. report += `✅ Debug信息保留功能工作正常。\n`;
  155. } else {
  156. report += `⚠️ 测试失败!部分debug信息丢失。\n`;
  157. report += `❌ 需要检查代码中的debug信息保留逻辑。\n`;
  158. }
  159. report += `\n=== 完整响应数据 ===\n`;
  160. report += JSON.stringify(result, null, 2);
  161. // 设置结果显示样式
  162. resultDiv.className = missingFields.length === 0 ? 'result success' : 'result error';
  163. resultDiv.textContent = report;
  164. } catch (error) {
  165. resultDiv.className = 'result error';
  166. resultDiv.textContent = `测试失败: ${error.message}\n\n请确保:\n1. 工伤接口服务正在运行\n2. 服务地址为: ${API_BASE_URL}\n3. 网络连接正常`;
  167. }
  168. }
  169. </script>
  170. </body>
  171. </html>