const { chromium } = require('playwright'); const fs = require('fs'); (async () => { const APP = process.env.APP; const URL = 'http://127.0.0.1:8077/'; const browser = await chromium.launch({ headless: true, args: ['--no-sandbox', '--enable-unsafe-swiftshader', '--use-gl=angle', '--use-angle=swiftshader', '--ignore-gpu-blocklist'], }); const page = await browser.newPage({ viewport: { width: 1100, height: 800 } }); const errors = [], pageerrors = [], notfound = []; page.on('console', (m) => { if (m.type() === 'error') errors.push(m.text()); }); page.on('pageerror', (e) => pageerrors.push(String(e))); page.on('response', (r) => { if (r.status() === 404) notfound.push(r.url().replace(/^https?:\/\/[^/]+/, '')); }); await page.goto(URL, { waitUntil: 'networkidle' }); // --- DEMO scene + walk test --- await page.click('#btn-demo'); await page.waitForFunction('window.__genreconReady === true', { timeout: 20000 }); await page.waitForTimeout(1400); // settle on floor const params = await page.evaluate('window.__params'); const demoTris = await page.evaluate('window.__genreconTris'); const cam0 = await page.evaluate('window.__genreconCam'); await page.evaluate(() => document.dispatchEvent(new KeyboardEvent('keydown', { code: 'KeyW' }))); await page.waitForTimeout(1000); const dbg = await page.evaluate('window.__dbg'); await page.evaluate(() => document.dispatchEvent(new KeyboardEvent('keyup', { code: 'KeyW' }))); const cam1 = await page.evaluate('window.__genreconCam'); const walkDist = Math.hypot(cam1[0] - cam0[0], cam1[2] - cam0[2]); await page.screenshot({ path: APP + '/test-demo.png' }); // --- full upload→reconstruct(mock)→viewer flow --- const fake = APP + '/_fakevid.mp4'; fs.writeFileSync(fake, Buffer.alloc(4096, 1)); await page.goto(URL, { waitUntil: 'networkidle' }); await page.setInputFiles('#file-input', fake); await page.waitForSelector('#view-progress.active', { timeout: 5000 }); await page.waitForSelector('#view-viewer.active', { timeout: 40000 }); await page.waitForFunction('window.__genreconReady === true', { timeout: 20000 }); await page.waitForTimeout(800); const uploadTris = await page.evaluate('window.__genreconTris'); await page.screenshot({ path: APP + '/test-upload.png' }); console.log(JSON.stringify({ errors, pageerrors, notfound: [...new Set(notfound)], params, demoTris, cam0, cam1, walkDist, dbg, uploadTris, }, null, 2)); await browser.close(); })().catch((e) => { console.error('TEST_FAIL', e); process.exit(1); });