- Add Next.js app structure with base configs, linting, and formatting - Implement LiveKit Meet page, types, and utility functions - Add Docker, Compose, and deployment scripts for backend and token server - Provide E2E and smoke test scaffolding with Puppeteer and Playwright helpers - Include CSS modules and global styles for UI - Add postMessage and studio integration utilities - Update package.json with dependencies and scripts for development and testing
64 lines
2.3 KiB
JavaScript
64 lines
2.3 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
function summarizeResults(results) {
|
|
const lines = [];
|
|
if (results.assertions && Array.isArray(results.assertions)) {
|
|
lines.push(`- Assertions:`);
|
|
for (const a of results.assertions) {
|
|
lines.push(` - ${a.name}: ${a.ok ? 'PASS' : 'FAIL'} - ${a.detail || ''}`);
|
|
}
|
|
}
|
|
if (results.console && Array.isArray(results.console) && results.console.length) {
|
|
const errors = results.console.filter(c => c.type === 'error' || c.type === 'warning');
|
|
if (errors.length) {
|
|
lines.push(`- Console issues:`);
|
|
for (const e of errors) {
|
|
lines.push(` - [${e.type}] ${e.text}`);
|
|
}
|
|
}
|
|
}
|
|
if (results.error) lines.push(`- Error: ${results.error}`);
|
|
return lines.join('\n');
|
|
}
|
|
|
|
function appendLog(runName, resultJsonPath, results, artifactUrl) {
|
|
try {
|
|
const logPath = path.resolve(__dirname, 'LOG.md');
|
|
const now = new Date().toISOString();
|
|
const summary = summarizeResults(results);
|
|
const screenshot = results.screenshot ? path.relative(path.dirname(logPath), results.screenshot) : '';
|
|
const status = (results.assertions && Array.isArray(results.assertions) && results.assertions.every(a => a.ok)) ? 'PASS' : (results.error ? 'ERROR' : 'UNKNOWN');
|
|
const entry = [
|
|
`## ${now} — ${runName}`,
|
|
`- Status: ${status}`,
|
|
`- Result JSON: ${resultJsonPath}`,
|
|
artifactUrl ? `- Artifact: ${artifactUrl}` : '',
|
|
screenshot ? `- Screenshot: ${screenshot}` : '',
|
|
summary ? summary : '- No assertions or console issues recorded',
|
|
'',
|
|
].filter(Boolean).join('\n');
|
|
|
|
fs.appendFileSync(logPath, entry + '\n');
|
|
return true;
|
|
} catch (err) {
|
|
try { console.warn('Failed to append log', err); } catch(e){}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// publishArtifact: runs publish_artifact.js and returns the printed path/URL or null
|
|
function publishArtifact(resultJsonPath, label) {
|
|
try {
|
|
const pub = require('child_process').execFileSync;
|
|
const script = path.resolve(__dirname, 'publish_artifact.js');
|
|
const out = pub(process.execPath, [script, resultJsonPath, label], { encoding: 'utf8' });
|
|
return out.trim();
|
|
} catch (err) {
|
|
console.warn('publishArtifact failed', err && err.message ? err.message : err);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
module.exports = { appendLog, publishArtifact };
|