Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.

Commit 2d54e3a

Browse files
committed
optimize test
1 parent 1f85c10 commit 2d54e3a

2 files changed

Lines changed: 47 additions & 9 deletions

File tree

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,44 @@ const readJSON = (filepath, defaultValue = null) => {
2222

2323
// Extract comprehensive test data from Playwright metrics
2424
function extractTestData() {
25-
const metrics = readJSON('playwright-metrics.json') || readJSON(path.join(ART, 'playwright-metrics.json'));
26-
const history = readJSON('.test-history.json');
27-
const failureAnalysis = readJSON(path.join(ART, 'test-failure-analysis.json'));
25+
const possiblePaths = [
26+
'playwright-metrics.json',
27+
path.join(ART, 'playwright-metrics.json'),
28+
path.join(ART, 'playwright-summary-pr.json'),
29+
path.join(ART, 'playwright-summary.json')
30+
];
31+
32+
let metrics = null;
33+
for (const p of possiblePaths) {
34+
if (fs.existsSync(p)) {
35+
metrics = readJSON(p);
36+
if (metrics && (metrics.suites || metrics.total)) {
37+
console.log(`Found metrics at: ${p}`);
38+
break;
39+
}
40+
}
41+
}
2842

43+
// If no detailed metrics found, try to use summary
2944
if (!metrics || !metrics.suites) {
30-
console.error('No test metrics found');
31-
return [];
45+
const summary = readJSON(path.join(ART, 'playwright-summary-pr.json'));
46+
if (summary && summary.total) {
47+
// Create a minimal structure from summary
48+
console.log('Using summary data for visualization');
49+
return [{
50+
id: 'summary-tests',
51+
suite: 'All Tests',
52+
describe: 'Summary',
53+
name: `${summary.passed} passed, ${summary.failed} failed`,
54+
duration: summary.duration || 0,
55+
passRate: summary.pass_rate || 0,
56+
passed: summary.passed || 0,
57+
failed: summary.failed || 0,
58+
total: summary.total || 0,
59+
lastStatus: summary.failed > 0 ? 'failed' : 'passed',
60+
priority: 1
61+
}];
62+
}
3263
}
3364

3465
const testData = [];

scripts/summary-comment.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ ${testHistory.flakyTests.length > 5 ? `\n_...and ${testHistory.flakyTests.length
303303
</details>
304304
` : '';
305305

306+
/* dashboard root (absolute if workflow provided it) */
307+
const dashboardURL = process.env.WEB_REPORT_URL || 'index.html';
308+
306309
// Quick commands section (enhanced)
307310
const mdQuickCommands = quickActionsData?.commands?.length > 0 ? `
308311
## ⚡ Quick Actions
@@ -327,14 +330,18 @@ ${cmd.command}
327330
const insights = generateInsights();
328331
const recommendations = generateRecommendations();
329332

330-
/* dashboard root (absolute if workflow provided it) */
331-
const dashboardURL = process.env.WEB_REPORT_URL || 'index.html';
332-
333333
/* Status summary line */
334334
const overallStatus = playPR.failed === 0 && codeQualityIssues === 0 ?
335335
'✅ **All checks passed!**' :
336336
`⚠️ **${playPR.failed} test failure(s), ${codeQualityIssues} code quality issue(s)${hasVisualChanges ? `, ${visualChangeCount} visual change(s)` : ''}**`;
337337

338+
const joinURL = (base, path) => {
339+
if (base.endsWith('/')) {
340+
return base + path;
341+
}
342+
return base + '/' + path;
343+
};
344+
338345
/* final comment body */
339346
const body = `
340347
# 🔍 GUI Test Review Summary
@@ -343,7 +350,7 @@ ${overallStatus}
343350
344351
<div align="center">
345352
346-
[📊 **Dashboard**](${dashboardURL}) • [🏙️ **3D Test City**](${dashboardURL}/test-city-3d.html) • [🖼️ **Visual Regression**](${dashboardURL}#visual-regression) • [⚡ **Quick Actions**](${dashboardURL}#quick-actions)
353+
[📊 **Dashboard**](${dashboardURL}) • [🏙️ **3D Test City**](${joinURL(dashboardURL, 'test-city-3d.html')}) • [🖼️ **Visual Regression**](${dashboardURL}#visual-regression) • [⚡ **Quick Actions**](${dashboardURL}#quick-actions)
347354
348355
</div>
349356

0 commit comments

Comments
 (0)