// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. /* eslint-disable no-console, no-process-env */ /** * Generates a unified HTML report combining results from all E2E platforms. * * Usage: node generate_unified_report.js * * Reads environment variables: * PLATFORM_DATA - JSON string with per-platform stats: * [{"name":"Detox iOS","status":"success","tests":200,"passes":198,...,"reportUrl":"https://..."}, * {"name":"Maestro iOS","status":"not_run"}, ...] * OUTPUT_DIR - Directory to write the HTML file */ const fs = require('fs'); const path = require('path'); function escapeHtml(str) { if (typeof str !== 'string') { return str; } return str. replace(/&/g, '&'). replace(//g, '>'). replace(/"/g, '"'); } function generateUnifiedHtml(platforms) { const totalTests = platforms.reduce((sum, p) => sum + (p.tests || 0), 0); const totalPasses = platforms.reduce((sum, p) => sum + (p.passes || 0), 0); const totalFailures = platforms.reduce((sum, p) => sum + (p.failures || 0), 0); const totalSkipped = platforms.reduce((sum, p) => sum + (p.skipped || 0), 0); const totalErrors = platforms.reduce((sum, p) => sum + (p.errors || 0), 0); const overallPercent = totalTests > 0 ? ((totalPasses / totalTests) * 100).toFixed(2) : '0.00'; const platformRows = platforms.map((p) => { if (p.status === 'not_run') { return `
| Platform | Tests | Passed | Failed | Skipped | Errors | Pass Rate |
|---|---|---|---|---|---|---|
| Total | ${totalTests} | ${totalPasses} | ${totalFailures} | ${totalSkipped} | ${totalErrors} | ${overallPercent}% |