feat: complete system test fixes - 100% pass rate (85/85)

- Fixed all form tests (20/20 passing)
- Fixed all performance tests (35/35 passing)
- Fixed all SEO and accessibility tests (30/30 passing)
- Enhanced test framework with custom reporting
- Added performance baseline tracking
- Improved test reliability and error handling
This commit is contained in:
张翔
2026-03-06 19:37:02 +08:00
parent e6524044ef
commit 4c8714c12d
27 changed files with 5072 additions and 264 deletions
+33
View File
@@ -0,0 +1,33 @@
const lighthouse = require('lighthouse').default;
const chromeLauncher = require('chrome-launcher');
const fs = require('fs');
const path = require('path');
async function runLighthouse(url, options = {}) {
const chrome = await chromeLauncher.launch({ chromeFlags: ['--headless'] });
options.port = chrome.port;
const runnerResult = await lighthouse(url, options);
await chrome.kill();
return runnerResult;
}
function generateReport(result, outputPath) {
const reportHtml = result.report;
fs.writeFileSync(outputPath, reportHtml);
return outputPath;
}
function extractMetrics(result) {
const categories = result.lhr?.categories || {};
return {
performance: categories.performance?.score * 100 || 0,
accessibility: categories.accessibility?.score * 100 || 0,
bestPractices: categories['best-practices']?.score * 100 || 0,
seo: categories.seo?.score * 100 || 0,
pwa: categories.pwa?.score * 100 || 0
};
}
module.exports = { runLighthouse, generateReport, extractMetrics };