diff --git a/games/age-of-dwarves/guide/e2e/diag.spec.ts b/games/age-of-dwarves/guide/e2e/diag.spec.ts index 0475c654..a421bc4c 100644 --- a/games/age-of-dwarves/guide/e2e/diag.spec.ts +++ b/games/age-of-dwarves/guide/e2e/diag.spec.ts @@ -2,42 +2,41 @@ import { test, expect } from '@playwright/test' const BASE_URL = '/climate/simulation?noGui=true&skip=welcome&totalTurns=50&buffer=0' -test('diagnose simulation - find 404s and worker failures', async ({ page }) => { - const messages: string[] = [] - const errors: string[] = [] - const notFoundResources: string[] = [] +test('diagnose - timing of events', async ({ page }) => { + const t0 = Date.now() + const log = (label: string): void => console.log(`[+${((Date.now() - t0) / 1000).toFixed(1)}s] ${label}`) page.on('console', msg => { - const text = msg.text() - if (msg.type() === 'error' || text.includes('404') || text.includes('failed') || text.includes('error')) { - messages.push(`[page:${msg.type()}] ${text}`) - } - }) - page.on('pageerror', err => errors.push(`[pageerror] ${err.message}`)) - - page.on('response', res => { - if (res.status() === 404 || res.status() >= 400) { - notFoundResources.push(`${res.status()} ${res.url()}`) - } - }) - - page.on('requestfailed', req => { - notFoundResources.push(`FAILED: ${req.url()} — ${req.failure()?.errorText}`) + if (msg.type() === 'error') log(`ERROR: ${msg.text()}`) }) + page.on('pageerror', err => log(`PAGE_ERROR: ${err.message}`)) page.on('worker', (worker) => { - messages.push(`[WORKER CREATED] ${worker.url()}`) + log(`WORKER CREATED: ${worker.url().slice(-40)}`) + }) + + page.on('response', res => { + if (res.url().includes('sim-cache')) { + log(`SIM-CACHE RESPONSE: ${res.status()} ${res.url().slice(-50)}`) + } }) await page.goto(BASE_URL) - await page.waitForTimeout(15000) + log('page loaded') - console.log('=== ERROR/RELEVANT CONSOLE MESSAGES ===') - for (const m of messages) console.log(m) - console.log('=== PAGE ERRORS ===') - for (const e of errors) console.log(e) - console.log('=== 404 / FAILED RESOURCES ===') - for (const r of notFoundResources) console.log(r) + // Poll for canvas every 5 seconds, up to 180 seconds + for (let i = 0; i < 36; i++) { + await page.waitForTimeout(5000) + const canvasVisible = await page.locator('canvas').first().isVisible().catch(() => false) + const loadingSteps = await page.locator('.sc-bzBgWJ').count().catch(() => 0) + const checkmarks = await page.locator(':text-is("✓")').count().catch(() => 0) + const active = await page.locator(':text-is("◉")').count().catch(() => 0) + log(`poll ${i + 1}: canvas=${canvasVisible}, steps=${loadingSteps}, ✓=${checkmarks}, ◉=${active}`) + if (canvasVisible) { + log('CANVAS VISIBLE — SIMULATION COMPLETE') + break + } + } expect(true).toBe(true) -}) +}, { timeout: 210_000 }) diff --git a/games/age-of-dwarves/guide/test-results/.last-run.json b/games/age-of-dwarves/guide/test-results/.last-run.json index cfac8a6b..ec8b86a3 100644 --- a/games/age-of-dwarves/guide/test-results/.last-run.json +++ b/games/age-of-dwarves/guide/test-results/.last-run.json @@ -1,6 +1,6 @@ { "status": "failed", "failedTests": [ - "620c61f0a0b21e7686ea-28292657752f1295456f" + "dc16e76570d2ea8d5f4a-0a10752f0734d5e9ffbc" ] } \ No newline at end of file