ai-code-battle/web/public/test-replay-viewer.html
jedarden cd30484e8c verify(blog): verify blog page generates and renders AI match commentary posts
Verification results:
1.  /data/blog/index.json exists and has 1 post (meta-week-13-season-1)
2.  Individual post pages load correctly at /blog/{slug}
3.  Blog post JSON structure matches frontend expectations (content_md field)
4.  Tags and filters implemented in UI (All, Meta Reports, Chronicles buttons)
5.  Blog page builds successfully (blog-D4QMd11d.js included in build)

Current state: Blog infrastructure is fully implemented with:
- LLM-powered narrative generation (blog.go, narrative.go)
- Story arc detection (rise, fall, rivalry, upset, evolution milestones)
- Weekly meta report generation with ELO movers, strategy analysis
- Chronicles for story arcs (rivalry, upset, rise/fall, evolution)
- Tag-based filtering and search

Note: Current blog content is placeholder/template-based. Meaningful
match commentary will be generated when:
- ACB_LLM_BASE_URL and ACB_LLM_API_KEY are configured in index-builder
- Real match data exists in PostgreSQL database
- Story arcs are detected from rating history and match results
2026-04-25 10:40:36 -04:00

94 lines
4 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Replay Viewer Test</title>
<style>
body { margin: 0; padding: 20px; font-family: sans-serif; }
#test-results { margin-top: 20px; padding: 10px; background: #f0f0f0; }
.pass { color: green; }
.fail { color: red; }
</style>
</head>
<body>
<h1>Replay Viewer Test</h1>
<div id="test-results">Loading test...</div>
<script type="module">
const results = document.getElementById('test-results');
let tests = [];
function addTest(name, passed, details) {
tests.push({ name, passed, details });
}
try {
// Test 1: Fetch demo replay
const replayResponse = await fetch('/data/demo-replay-v2.json');
addTest('Fetch demo replay', replayResponse.ok,
replayResponse.ok ? 'Status: ' + replayResponse.status : 'Failed to fetch');
if (replayResponse.ok) {
const replay = await replayResponse.json();
// Test 2: Validate replay structure
addTest('Replay has match_id', !!replay.match_id, replay.match_id || 'No match_id');
addTest('Replay has players', Array.isArray(replay.players) && replay.players.length > 0,
`${replay.players?.length || 0} players`);
addTest('Replay has turns', Array.isArray(replay.turns) && replay.turns.length > 0,
`${replay.turns?.length || 0} turns`);
addTest('Replay has map', !!replay.map, replay.map ? 'Map present' : 'No map');
// Test 3: Validate map structure
if (replay.map) {
addTest('Map has dimensions', replay.map.rows > 0 && replay.map.cols > 0,
`${replay.map.rows}x${replay.map.cols}`);
addTest('Map has walls', Array.isArray(replay.map.walls),
`${replay.map.walls?.length || 0} walls`);
}
// Test 4: Validate turn data
if (replay.turns && replay.turns.length > 0) {
const firstTurn = replay.turns[0];
addTest('First turn has bots', Array.isArray(firstTurn.bots),
`${firstTurn.bots?.length || 0} bots`);
addTest('First turn has energy', Array.isArray(firstTurn.energy),
`${firstTurn.energy?.length || 0} energy nodes`);
}
// Test 5: Validate result
if (replay.result) {
addTest('Result has winner', replay.result.winner >= 0,
`Winner: player ${replay.result.winner}`);
addTest('Result has reason', !!replay.result.reason,
`Reason: ${replay.result.reason}`);
}
}
} catch (error) {
addTest('Test execution', false, error.message);
}
// Render results
let html = '<h2>Test Results</h2><ul>';
let passed = 0;
for (const test of tests) {
const status = test.passed ? 'PASS' : 'FAIL';
const cssClass = test.passed ? 'pass' : 'fail';
if (test.passed) passed++;
html += `<li class="${cssClass}">${status}: ${test.name} - ${test.details}</li>`;
}
html += `</ul><p><strong>${passed}/${tests.length} tests passed</strong></p>`;
results.innerHTML = html;
// Also test the replay viewer module
import('./src/replay-viewer.ts').then(module => {
console.log('ReplayViewer module loaded:', module);
addTest('ReplayViewer module loads', true, 'Module loaded successfully');
results.innerHTML = html;
}).catch(err => {
console.error('Failed to load ReplayViewer:', err);
addTest('ReplayViewer module loads', false, err.message);
results.innerHTML = html;
});
</script>
</body>
</html>