Explorar el Código

优化代码,添加接口

liuchengsen hace 2 meses
padre
commit
1717b940f6
Se han modificado 1 ficheros con 23 adiciones y 11 borrados
  1. 23 11
      zhijiayun-test/src/main/resources/static/invite-test.html

+ 23 - 11
zhijiayun-test/src/main/resources/static/invite-test.html

@@ -222,9 +222,9 @@ function updateStats(id, passed) {
     stats[id] = passed ? 'pass' : 'fail';
     if (passed) stats.pass++; else stats.fail++;
 
-    document.getElementById('passCount').textContent = stats.pass;
-    document.getElementById('failCount').textContent = stats.fail;
-    document.getElementById('pendingCount').textContent = stats.pending;
+    document.getElementById('passCount').textContent = Math.max(0, stats.pass);
+    document.getElementById('failCount').textContent = Math.max(0, stats.fail);
+    document.getElementById('pendingCount').textContent = Math.max(0, stats.pending);
 }
 
 // ===================== 登录相关 =====================
@@ -1020,33 +1020,45 @@ function getSectionsInModule(modulePrefix) {
 async function runBatchTests(modulePrefix) {
     const sections = getSectionsInModule(modulePrefix);
     for (const section of sections) {
-        const btn = section.querySelector('button');
+        const btn = section.querySelector('button[onclick*="runTest"]');
         if (btn) {
             btn.click();
-            await new Promise(r => setTimeout(r, 200));
+            await new Promise(r => setTimeout(r, 500));
         }
     }
 }
 
 async function runAllTests() {
     const modules = ['auth','crawler','invite','coupon','level','platform-account','business-license','platform-config','trial-quota','admin','audit-log'];
-    stats = { pass: 0, fail: 0, pending: 0 };
+    resetStats();
     for (const m of modules) {
         document.querySelector(`.module-tab[data-module="${m}"]`).click();
+        await new Promise(r => setTimeout(r, 100));
         await runBatchTests(m);
     }
 }
 
-function clearAllResults() {
-    document.querySelectorAll('.response-box').forEach(b => b.style.display = 'none');
-    document.querySelectorAll('.status-badge').forEach(b => { b.textContent = ''; b.className = 'status-badge'; });
-    stats = { pass: 0, fail: 0, pending: 0 };
-    Object.keys(stats).forEach(k => { if (k !== 'pass' && k !== 'fail' && k !== 'pending') delete stats[k]; });
+function resetStats() {
+    const keys = Object.keys(stats);
+    for (const k of keys) {
+        if (k !== 'pass' && k !== 'fail' && k !== 'pending') {
+            delete stats[k];
+        }
+    }
+    stats.pass = 0;
+    stats.fail = 0;
+    stats.pending = 0;
     document.getElementById('passCount').textContent = '0';
     document.getElementById('failCount').textContent = '0';
     document.getElementById('pendingCount').textContent = '0';
 }
 
+function clearAllResults() {
+    document.querySelectorAll('.response-box').forEach(b => b.style.display = 'none');
+    document.querySelectorAll('.status-badge').forEach(b => { b.textContent = ''; b.className = 'status-badge'; });
+    resetStats();
+}
+
 // 快捷批量运行
 function runAuthTests() { runBatchTests('auth'); }
 function runCrawlerTests() { runBatchTests('crawler'); }