Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

Add Playwright scripts for browser verification and testing

nirholas6cc0370dc3df
diff --git a/.atlas-dbg.mjs b/.atlas-dbg.mjs
new file mode 100644
index 000000000..dacac97f9
--- /dev/null
+++ b/.atlas-dbg.mjs
@@ -0,0 +1,18 @@
+import { chromium } from 'playwright';
+const BASE = process.argv[2];
+const b = await chromium.launch();
+const p = await b.newPage();
+await p.goto(BASE + '/pricing', { waitUntil: 'domcontentloaded' });
+await p.waitForTimeout(2500);
+await p.keyboard.press('Control+k');
+await p.waitForSelector('.tws-atlas[data-open]');
+await p.waitForTimeout(50);
+console.log('t+50ms intents:', await p.locator('.tws-atlas-row[data-kind="intent"]').count(),
+ 'skeletons:', await p.locator('.tws-atlas-skel').count());
+await p.waitForTimeout(700);
+console.log('t+750ms intents:', await p.locator('.tws-atlas-row[data-kind="intent"]').count());
+await p.fill('.tws-atlas-input', '/status');
+await p.waitForTimeout(300);
+console.log('rows:', JSON.stringify(await p.evaluate(() =>
+ [...document.querySelectorAll('.tws-atlas-row')].slice(0,3).map(r => ({k:r.dataset.kind,h:r.dataset.href,s:r.getAttribute('aria-selected')})))));
+await b.close();
diff --git a/.reel-probe4.mjs b/.reel-probe4.mjs
new file mode 100644
index 000000000..b747d2036
--- /dev/null
+++ b/.reel-probe4.mjs
@@ -0,0 +1,40 @@
+import { chromium } from 'playwright';
+const browser = await chromium.launch({ args: ['--use-gl=swiftshader','--enable-unsafe-swiftshader','--ignore-gpu-blocklist'] });
+const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
+await page.goto('http://localhost:3000/forge', { waitUntil: 'domcontentloaded' });
+await page.waitForTimeout(3000);
+await page.evaluate(() => document.dispatchEvent(new CustomEvent('forge:open-creation', { detail: { creation: { id:'p', prompt:'probe', glb_url:'https://three.ws/avatars/default.glb', backend:'trellis_selfhost' } } })));
+await page.waitForFunction(() => document.getElementById('viewer')?.loaded === true, null, { timeout: 90000 });
+await page.waitForTimeout(1500);
+const out = await page.evaluate(async () => {
+ const v = document.getElementById('viewer');
+ const cs = [...v.shadowRoot.querySelectorAll('canvas')];
+ const target = cs.find(x => x.id === 'webgl-canvas' && x.classList.contains('show')) || cs[0];
+ const info = { picked: target.id || '(own)', cls: target.className, w: target.width, h: target.height };
+
+ async function run(mode) {
+ const stream = mode === 'fps' ? target.captureStream(30) : target.captureStream();
+ const track = stream.getVideoTracks()[0];
+ const rec = new MediaRecorder(stream, { mimeType: 'video/webm;codecs=vp8' });
+ let total = 0, chunks = 0;
+ rec.ondataavailable = e => { total += e.data.size; chunks++; };
+ const done = new Promise(r => rec.onstop = r);
+ rec.start(200);
+ const t0 = performance.now();
+ while (performance.now() - t0 < 1500) {
+ await new Promise(r => requestAnimationFrame(r));
+ const a = (performance.now() - t0) / 1500 * 360;
+ v.cameraOrbit = `${a}deg 78deg auto`;
+ v.jumpCameraToGoal?.();
+ if (mode === 'manual') track.requestFrame?.();
+ }
+ rec.stop(); await done;
+ for (const t of stream.getTracks()) t.stop();
+ return { mode, total, chunks, hasRequestFrame: typeof track.requestFrame === 'function' };
+ }
+ info.fps = await run('fps');
+ info.manual = await run('manual');
+ return info;
+});
+console.log(JSON.stringify(out, null, 2));
+await browser.close();
diff --git a/.reel-verify.mjs b/.reel-verify.mjs
new file mode 100644
index 000000000..4fc916c5c
--- /dev/null
+++ b/.reel-verify.mjs
@@ -0,0 +1,78 @@
+// Real-browser verification of Forge Reel: load /forge, put a real model in the
+// result viewer, render an actual reel, and assert the produced files are real
+// bytes with the right magic numbers.
+import { chromium } from 'playwright';
+import { mkdirSync, writeFileSync } from 'node:fs';
+
+const OUT = '/tmp/claude-1000/-workspaces-three-ws/54abdcf2-c800-40d7-8c4b-205b55327f21/scratchpad/reel-shots';
+mkdirSync(OUT, { recursive: true });
+
+const errors = [];
+const browser = await chromium.launch({ args: ['--use-gl=swiftshader','--enable-unsafe-swiftshader','--ignore-gpu-blocklist'] });
+const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
+page.on('console', m => { if (m.type() === 'error') errors.push(m.text()); });
+page.on('pageerror', e => errors.push(`pageerror: ${e.message}`));
+
+page.setDefaultTimeout(120000);
+await page.goto('http://localhost:3210/forge', { waitUntil: 'domcontentloaded', timeout: 120000 });
+await page.waitForTimeout(3000);
+await page.evaluate(() => document.dispatchEvent(new CustomEvent('forge:open-creation', {
+ detail: { creation: { id: 'verify-reel', prompt: 'a brass lantern', glb_url: 'https://three.ws/avatars/default.glb', backend: 'trellis_selfhost' } },
+})));
+await page.waitForFunction(() => document.getElementById('viewer')?.loaded === true, null, { timeout: 90000 });
+await page.waitForTimeout(1200);
+await page.screenshot({ path: `${OUT}/01-result.png` });
+
+console.log('trigger visible:', await page.isVisible('#reel-open'));
+await page.click('#reel-open');
+await page.waitForTimeout(400);
+await page.screenshot({ path: `${OUT}/02-dialog.png` });
+console.log('summary:', await page.textContent('.reel-summary'));
+
+await page.click('.reel-durations .reel-chip[data-id="4"]');
+await page.click('.reel-start');
+await page.waitForTimeout(2500);
+await page.screenshot({ path: `${OUT}/03-rendering.png` });
+console.log('phase:', await page.textContent('.reel-working-title'), '|', await page.textContent('.reel-clock'));
+
+await page.waitForSelector('.reel-done:not([hidden]) .reel-file, .reel-error-panel:not([hidden])', { timeout: 180000 });
+if (await page.isVisible('.reel-error-panel')) console.log('ERROR PANEL:', await page.textContent('.reel-error-text'));
+await page.waitForTimeout(1000);
+await page.screenshot({ path: `${OUT}/04-done.png` });
+
+const files = await page.evaluate(async () => {
+ const rows = [...document.querySelectorAll('.reel-file')];
+ const out = [];
+ for (const row of rows) {
+ const blob = await (await fetch(row.href)).blob();
+ const buf = new Uint8Array(await blob.arrayBuffer());
+ let b64 = '';
+ for (let i = 0; i < buf.length; i += 8192) b64 += String.fromCharCode(...buf.subarray(i, i + 8192));
+ out.push({ name: row.download, type: blob.type, size: blob.size, head: [...buf.slice(0, 12)], b64: btoa(b64) });
+ }
+ return out;
+});
+for (const f of files) {
+ writeFileSync(`${OUT}/${f.name}`, Buffer.from(f.b64, 'base64'));
+ console.log(`file ${f.name} type=${f.type} size=${f.size} magic=${f.head.map(b=>b.toString(16).padStart(2,'0')).join(' ')}`);
+}
+console.log('video element has src:', await page.evaluate(() => !!document.querySelector('.reel-video')?.src));
+
+await page.keyboard.press('Escape');
+await page.waitForTimeout(300);
+console.log('closed after Esc:', !(await page.isVisible('.reel-panel')));
+await page.keyboard.press('r');
+await page.waitForTimeout(300);
+console.log('reopened with R:', await page.isVisible('.reel-panel'));
+await page.keyboard.press('Escape');
+await page.waitForTimeout(300);
+
+await page.setViewportSize({ width: 320, height: 720 });
+await page.waitForTimeout(300);
+await page.click('#reel-open');
+await page.waitForTimeout(400);
+await page.screenshot({ path: `${OUT}/05-320.png` });
+console.log('320px overflow:', await page.evaluate(() => document.documentElement.scrollWidth > window.innerWidth + 1));
+
+console.log('console errors:', JSON.stringify(errors.filter(e => !/WebSocket|vite/i.test(e)), null, 2));
+await browser.close();
diff --git a/.verify-conversions.mjs b/.verify-conversions.mjs
new file mode 100644
index 000000000..3e08d1a66
--- /dev/null
+++ b/.verify-conversions.mjs
@@ -0,0 +1,187 @@
+// Browser verification for /conversions.
+// Serves pages/conversions.html and src/conversions.js straight off disk through
+// a playwright route handler, so the check is immune to a dev server that other
+// agents keep restarting. API responses are REAL payloads captured from the
+// production database (scratchpad/buyer.json, seller.json).
+import { chromium } from 'playwright';
+import { readFileSync, existsSync } from 'node:fs';
+import { resolve } from 'node:path';
+
+const ROOT = '/workspaces/three.ws';
+const DIR = '/tmp/claude-1000/-workspaces-three-ws/ec60ca0e-93bf-42fe-96fb-7df45c0b9015/scratchpad';
+const BASE = 'https://local.test';
+const buyer = readFileSync(`${DIR}/buyer.json`, 'utf8');
+const seller = readFileSync(`${DIR}/seller.json`, 'utf8');
+
+const problems = [];
+const note = (s) => console.log(s);
+
+const MIME = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.json': 'application/json' };
+
+async function newPage(browser, mode, viewport = { width: 1280, height: 900 }) {
+ const ctx = await browser.newContext({ viewport, isMobile: viewport.width < 500, hasTouch: viewport.width < 500 });
+ const page = await ctx.newPage();
+ const noise = [];
+ page.on('console', (m) => {
+ if (m.type() !== 'error' && m.type() !== 'warning') return;
+ // Chrome logs a console error for every non-2xx response. The 401 and 500
+ // modes below induce those on purpose, and the page handles them; that
+ // browser-native line is not noise from our code.
+ if (/Failed to load resource/.test(m.text())) return;
+ noise.push(`${m.type()}: ${m.text()}`);
+ });
+ page.on('pageerror', (e) => noise.push(`pageerror: ${e.message}`));
+
+ await page.route('**/*', (route) => {
+ const url = new URL(route.request().url());
+ const path = url.pathname;
+
+ if (path.startsWith('/api/marketplace/trial-status')) {
+ const role = url.searchParams.get('role') || 'buyer';
+ if (mode === 'signedout') return route.fulfill({ status: 401, contentType: 'application/json', body: '{"error":"unauthorized"}' });
+ if (mode === 'error') return route.fulfill({ status: 500, contentType: 'application/json', body: '{"error":"boom","error_description":"The database is briefly unavailable."}' });
+ if (mode === 'empty') {
+ const body = role === 'seller'
+ ? { data: { role: 'seller', queue: [], summary: { skillsWithTrials: 0, activeTrials: 0, warmLeads: 0, lastRun: 0, sold: 0, potential: { atomic: '0', decimals: 6, display: '0' } } } }
+ : { data: { role: 'buyer', trials: [], summary: { active: 0, fresh: 0, runningLow: 0, exhausted: 0 } } };
+ return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(body) });
+ }
+ return route.fulfill({ status: 200, contentType: 'application/json', body: role === 'seller' ? seller : buyer });
+ }
+
+ if (path === '/conversions') {
+ return route.fulfill({ status: 200, contentType: 'text/html', body: readFileSync(resolve(ROOT, 'pages/conversions.html'), 'utf8') });
+ }
+
+ // Real source files; anything else (nav, footer, i18n, fonts) is site
+ // chrome this check does not exercise, so it resolves to an empty 200
+ // rather than a 404 that would pollute the console-noise assertion.
+ const onDisk = resolve(ROOT, path.replace(/^\//, ''));
+ if (onDisk.startsWith(ROOT) && existsSync(onDisk) && !onDisk.endsWith('/')) {
+ const ext = onDisk.slice(onDisk.lastIndexOf('.'));
+ return route.fulfill({ status: 200, contentType: MIME[ext] || 'application/octet-stream', body: readFileSync(onDisk) });
+ }
+ return route.fulfill({ status: 200, contentType: path.endsWith('.js') ? 'text/javascript' : 'text/plain', body: '' });
+ });
+ return { ctx, page, noise };
+}
+
+const browser = await chromium.launch();
+
+// ── populated, keyboard, cache, url sync ─────────────────────────────────────
+{
+ const { ctx, page, noise } = await newPage(browser, 'real');
+ await page.goto(`${BASE}/conversions`, { waitUntil: 'domcontentloaded' });
+ await page.waitForSelector('.cv-row', { timeout: 15000 });
+
+ const rows = await page.locator('.cv-row').count();
+ const stats = await page.locator('.stat-card .stat-val').allInnerTexts();
+ const firstSkill = await page.locator('.cv-row .cv-skill').first().innerText();
+ const pill = await page.locator('.cv-row .pill').first().innerText();
+ const pips = await page.locator('.cv-row').first().locator('.meter-pip').count();
+ const meterLabel = await page.locator('.cv-row').first().locator('.meter').getAttribute('aria-label');
+ const cta = await page.locator('.cv-row .btn').first().innerText();
+ note(`buyer: ${rows} rows | stats ${JSON.stringify(stats)} | first "${firstSkill}" [${pill}] | ${pips} pips | aria "${meterLabel}" | cta "${cta}"`);
+ if (rows !== 114) problems.push(`buyer rendered ${rows} rows, expected 114`);
+ if (!meterLabel) problems.push('meter has no aria-label');
+
+ await page.locator('#tab-buyer').focus();
+ await page.keyboard.press('ArrowRight');
+ await page.waitForFunction(() => document.querySelector('#tab-seller')?.getAttribute('aria-selected') === 'true', null, { timeout: 8000 });
+ await page.waitForSelector('.cv-metrics', { timeout: 15000 });
+ const sRows = await page.locator('.cv-row').count();
+ const sStats = await page.locator('.stat-card .stat-val').allInnerTexts();
+ const metrics = await page.locator('.cv-row').first().locator('.cv-metric').allInnerTexts();
+ const url = page.url();
+ note(`seller: ${sRows} rows | stats ${JSON.stringify(sStats)} | metrics ${JSON.stringify(metrics)}`);
+ note(`url after tab switch: ${url}`);
+ if (sRows !== 3) problems.push(`seller rendered ${sRows} rows, expected 3`);
+ if (!url.includes('role=seller')) problems.push(`url did not sync role: ${url}`);
+ const focused = await page.evaluate(() => document.activeElement?.id);
+ if (focused !== 'tab-seller') problems.push(`ArrowRight did not move focus (activeElement=${focused})`);
+
+ await page.keyboard.press('ArrowLeft');
+ await page.waitForFunction(() => document.querySelectorAll('.cv-row').length === 114, null, { timeout: 8000 });
+ const backUrl = page.url();
+ if (backUrl.includes('role=seller')) problems.push(`url did not clear role on return: ${backUrl}`);
+ note('cache: ArrowLeft restored the buyer view instantly and cleared the query param');
+
+ const ring = await page.evaluate(() => {
+ const b = document.querySelector('.cv-row .btn');
+ b.focus();
+ const s = getComputedStyle(b);
+ return `${s.outlineStyle} ${s.outlineWidth}`;
+ });
+ note(`focus-visible ring on row CTA: ${ring}`);
+
+ await page.screenshot({ path: `${DIR}/shot-buyer.png` });
+ if (noise.length) problems.push(`console noise: ${noise.slice(0, 5).join(' | ')}`);
+ await ctx.close();
+}
+
+// ── empty / signed out / error ───────────────────────────────────────────────
+for (const mode of ['empty', 'signedout', 'error']) {
+ const { ctx, page, noise } = await newPage(browser, mode);
+ await page.goto(`${BASE}/conversions`, { waitUntil: 'domcontentloaded' });
+ await page.waitForSelector('.cv-state', { timeout: 15000 });
+ const heading = await page.locator('.cv-state h2').innerText();
+ const body = await page.locator('.cv-state p').innerText();
+ const cta = await page.locator('.cv-state .btn').count();
+ note(`${mode}: "${heading}" | cta=${cta} | ${body.slice(0, 72)}…`);
+ if (!heading) problems.push(`${mode}: no heading`);
+ if (!cta) problems.push(`${mode}: no call to action`);
+ if (mode === 'error') {
+ await page.locator('#cv-retry').click();
+ await page.waitForSelector('.cv-state.is-error', { timeout: 8000 });
+ note('error: retry re-issues the request and re-renders');
+ }
+ if (mode === 'empty') {
+ await page.locator('#tab-seller').click();
+ await page.waitForFunction(
+ () => document.querySelector('.cv-state h2')?.textContent?.includes('your skills'),
+ null,
+ { timeout: 8000 },
+ );
+ note(`empty(seller): "${await page.locator('.cv-state h2').innerText()}"`);
+ }
+ if (noise.length) problems.push(`${mode} console noise: ${noise.slice(0, 3).join(' | ')}`);
+ await ctx.close();
+}
+
+// ── mobile ───────────────────────────────────────────────────────────────────
+{
+ const { ctx, page, noise } = await newPage(browser, 'real', { width: 390, height: 844 });
+ await page.goto(`${BASE}/conversions`, { waitUntil: 'domcontentloaded' });
+ await page.waitForSelector('.cv-row', { timeout: 15000 });
+ const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
+ const tabH = await page.evaluate(() => document.querySelector('.role-tab').getBoundingClientRect().height);
+ note(`mobile 390px: horizontal overflow ${overflow}px | tab height ${Math.round(tabH)}px`);
+ if (overflow > 0) problems.push(`mobile overflows by ${overflow}px`);
+ if (tabH < 32) problems.push(`mobile tab is ${tabH}px tall, below a comfortable touch target`);
+ await page.screenshot({ path: `${DIR}/shot-mobile.png` });
+ if (noise.length) problems.push(`mobile console noise: ${noise.slice(0, 3).join(' | ')}`);
+ await ctx.close();
+}
+
+// ── light theme ──────────────────────────────────────────────────────────────
+{
+ const { ctx, page } = await newPage(browser, 'real');
+ await page.addInitScript(() => localStorage.setItem('twx_theme', 'light'));
+ await page.goto(`${BASE}/conversions`, { waitUntil: 'domcontentloaded' });
+ await page.waitForSelector('.cv-row', { timeout: 15000 });
+ const theme = await page.evaluate(() => document.documentElement.getAttribute('data-theme'));
+ const bg = await page.evaluate(() => getComputedStyle(document.body).backgroundColor);
+ note(`light theme: data-theme=${theme} body bg ${bg}`);
+ if (theme !== 'light') problems.push(`light theme did not apply (data-theme=${theme})`);
+ await page.screenshot({ path: `${DIR}/shot-light.png` });
+ await ctx.close();
+}
+
+await browser.close();
+
+if (problems.length) {
+ console.log(`\nFAIL (${problems.length}):`);
+ for (const p of problems) console.log(` - ${p}`);
+ process.exit(1);
+}
+console.log('\nPASS: every state rendered, keyboard works, no console noise, no mobile overflow, light theme applies');
diff --git a/scripts/tmp/list-404.mjs b/scripts/tmp/list-404.mjs
new file mode 100644
index 000000000..4d854ce5d
--- /dev/null
+++ b/scripts/tmp/list-404.mjs
@@ -0,0 +1,9 @@
+import { chromium } from 'playwright';
+const b = await chromium.launch({ args: ['--no-sandbox'] });
+const p = await b.newPage();
+const bad = [];
+p.on('response', (r) => { if (r.status() >= 400) bad.push(`${r.status()} ${r.url()}`); });
+await p.goto('http://localhost:4599/tutorials/getting-started', { waitUntil: 'domcontentloaded', timeout: 120000 });
+await p.waitForTimeout(6000);
+console.log(bad.join('\n') || 'none');
+await b.close();
diff --git a/scripts/tmp/shot.mjs b/scripts/tmp/shot.mjs
new file mode 100644
index 000000000..5f7231627
--- /dev/null
+++ b/scripts/tmp/shot.mjs
@@ -0,0 +1,25 @@
+import { chromium } from 'playwright';
+const b = await chromium.launch({ args: ['--no-sandbox'] });
+for (const [slug, theme, name] of [['getting-started','dark','dark'],['text-to-3d','light','light']]) {
+ const ctx = await b.newContext({ viewport: { width: 1240, height: 1100 }, deviceScaleFactor: 1 });
+ await ctx.addInitScript(`try{localStorage.setItem('twx_theme','${theme}')}catch(e){}`);
+ const p = await ctx.newPage();
+ await p.goto(`http://localhost:4599/tutorials/${slug}`, { waitUntil: 'domcontentloaded', timeout: 120000 });
+ await p.waitForSelector('.tfig-frame-img img', { timeout: 30000 }).catch(()=>{});
+ await p.waitForTimeout(5000);
+ await p.evaluate(() => { const f = document.querySelector('figure.tfig'); if (f) f.scrollIntoView({ block: 'center' }); });
+ await p.waitForTimeout(1500);
+ await p.screenshot({ path: `/tmp/tfig/shot-${name}.png` });
+ await ctx.close();
+}
+// Lightbox open state
+const ctx = await b.newContext({ viewport: { width: 1240, height: 900 } });
+const p = await ctx.newPage();
+await p.goto('http://localhost:4599/tutorials/text-to-3d', { waitUntil: 'domcontentloaded', timeout: 120000 });
+await p.waitForSelector('.tfig-zoom', { timeout: 30000 });
+await p.waitForTimeout(4000);
+await p.locator('.tfig-zoom').first().click();
+await p.waitForTimeout(1200);
+await p.screenshot({ path: '/tmp/tfig/shot-lightbox.png' });
+await b.close();
+console.log('shots written');
diff --git a/scripts/tmp/static-preview.mjs b/scripts/tmp/static-preview.mjs
new file mode 100644
index 000000000..9f21abc0d
--- /dev/null
+++ b/scripts/tmp/static-preview.mjs
@@ -0,0 +1,46 @@
+// Minimal static host for verifying tutorial pages without vite.
+// Other agents restart the shared dev server constantly, which makes a
+// browser check against it flaky for reasons unrelated to what is being tested.
+import { createServer } from 'node:http';
+import { readFile } from 'node:fs/promises';
+import { existsSync } from 'node:fs';
+import { resolve, extname } from 'node:path';
+
+const ROOT = resolve(import.meta.dirname, '../..');
+const PORT = Number(process.env.PORT || 4599);
+const TYPES = {
+ '.html': 'text/html',
+ '.js': 'text/javascript',
+ '.css': 'text/css',
+ '.json': 'application/json',
+ '.webp': 'image/webp',
+ '.png': 'image/png',
+ '.jpg': 'image/jpeg',
+ '.svg': 'image/svg+xml',
+ '.glb': 'model/gltf-binary',
+ '.md': 'text/markdown',
+ '.woff2': 'font/woff2',
+};
+
+createServer(async (req, res) => {
+ let path = decodeURIComponent(new URL(req.url, 'http://x').pathname);
+ if (/^\/tutorials\/[a-z0-9-]+\/?$/.test(path)) path = '/__page/tutorial.html';
+
+ const candidates = path.startsWith('/__page/')
+ ? [resolve(ROOT, 'pages', path.slice('/__page/'.length))]
+ : [resolve(ROOT, 'public', path.slice(1)), resolve(ROOT, path.slice(1))];
+
+ for (const file of candidates) {
+ if (!file.startsWith(ROOT) || !existsSync(file)) continue;
+ try {
+ const body = await readFile(file);
+ res.writeHead(200, { 'content-type': TYPES[extname(file)] || 'application/octet-stream' });
+ res.end(body);
+ return;
+ } catch {
+ /* fall through to the next candidate */
+ }
+ }
+ res.writeHead(404, { 'content-type': 'text/plain' });
+ res.end('not found');
+}).listen(PORT, () => console.log(`static preview on http://localhost:${PORT}`));
diff --git a/scripts/tmp/verify-tutorial-figures.mjs b/scripts/tmp/verify-tutorial-figures.mjs
new file mode 100644
index 000000000..63136f7c8
--- /dev/null
+++ b/scripts/tmp/verify-tutorial-figures.mjs
@@ -0,0 +1,122 @@
+// Real-browser verification of the tutorial figure system.
+import { chromium, devices } from 'playwright';
+
+const BASE = process.env.BASE || 'http://localhost:3000';
+const SLUGS = ['getting-started', 'text-to-3d', 'render-avatar-images'];
+
+const browser = await chromium.launch({ args: ['--no-sandbox'] });
+let failures = 0;
+const note = (ok, msg) => {
+ if (!ok) failures++;
+ console.log(`${ok ? ' ok ' : ' FAIL '} ${msg}`);
+};
+
+for (const slug of SLUGS) {
+ console.log(`\n=== /tutorials/${slug} (desktop 1280) ===`);
+ const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } });
+ const page = await ctx.newPage();
+ const errors = [];
+ page.on('console', (m) => {
+ if (m.type() === 'error') { const t = m.text(); if (!/\[vite\]|WebSocket|__vite_ping/.test(t)) errors.push(t); }
+ });
+ page.on('pageerror', (e) => errors.push(String(e)));
+ await page.goto(`${BASE}/tutorials/${slug}`, { waitUntil: 'domcontentloaded', timeout: 120000 });
+ await page.waitForSelector('.tfig', { timeout: 20000 }).catch(() => {});
+ await page.waitForTimeout(3500);
+
+ const stats = await page.evaluate(() => ({
+ figures: document.querySelectorAll('figure.tfig').length,
+ leftover: document.querySelectorAll('img[src^="figure:"]').length,
+ captions: [...document.querySelectorAll('.tfig-caption .tfig-text')].map((n) => n.textContent.slice(0, 40)),
+ nums: [...document.querySelectorAll('.tfig-num')].map((n) => n.textContent),
+ imgsLoaded: [...document.querySelectorAll('.tfig-img')].map((i) => i.naturalWidth > 0),
+ viewers: document.querySelectorAll('.tfig-frame-live model-viewer').length,
+ altsPresent: [...document.querySelectorAll('.tfig-img')].every((i) => (i.getAttribute('alt') || '').length > 5),
+ zoomBtns: document.querySelectorAll('.tfig-zoom').length,
+ lightbox: !!document.querySelector('.tfig-lightbox'),
+ inParagraph: document.querySelectorAll('p > figure.tfig').length,
+ }));
+ console.log(JSON.stringify(stats, null, 1));
+ note(stats.figures > 0, `${stats.figures} figure(s) mounted`);
+ note(stats.leftover === 0, 'no unresolved figure: placeholders remain');
+ note(stats.imgsLoaded.every(Boolean), `all ${stats.imgsLoaded.length} static image(s) decoded`);
+ note(stats.altsPresent, 'every static image carries real alt text');
+ note(stats.inParagraph === 0, 'no <figure> is trapped inside a <p>');
+ note(stats.nums.every((n) => /^Figure \d+$/.test(n)), `captions numbered: ${stats.nums.join(', ')}`);
+
+ // Keyboard: tab to a zoom button, Enter to open, arrows, Escape to close.
+ if (stats.zoomBtns > 0) {
+ await page.locator('.tfig-zoom').first().focus();
+ await page.keyboard.press('Enter');
+ await page.waitForTimeout(500);
+ const opened = await page.evaluate(() => {
+ const lb = document.querySelector('.tfig-lightbox');
+ return {
+ visible: lb && !lb.hidden,
+ focusInside: lb ? lb.contains(document.activeElement) : false,
+ imgSrc: document.querySelector('.tfig-lb-img')?.getAttribute('src') || '',
+ scrollLocked: getComputedStyle(document.documentElement).overflow === 'hidden',
+ role: lb?.getAttribute('role'),
+ modal: lb?.getAttribute('aria-modal'),
+ };
+ });
+ note(opened.visible, 'Enter on the zoom control opens the lightbox');
+ note(opened.focusInside, 'focus moves inside the dialog');
+ note(!!opened.imgSrc, `lightbox shows ${opened.imgSrc.split('/').pop()}`);
+ note(opened.scrollLocked, 'background scroll is locked while modal');
+ note(opened.role === 'dialog' && opened.modal === 'true', 'dialog carries role + aria-modal');
+
+ await page.keyboard.press('Escape');
+ await page.waitForTimeout(400);
+ const closed = await page.evaluate(() => ({
+ hidden: document.querySelector('.tfig-lightbox')?.hidden,
+ focusReturned: document.activeElement?.classList.contains('tfig-zoom'),
+ scrollFree: getComputedStyle(document.documentElement).overflow !== 'hidden',
+ }));
+ note(closed.hidden === true, 'Escape closes the lightbox');
+ note(closed.focusReturned, 'focus returns to the control that opened it');
+ note(closed.scrollFree, 'scroll is released on close');
+ }
+
+ // Layout stability: the reserved box must match the decoded image.
+ const cls = await page.evaluate(() => {
+ const f = document.querySelector('.tfig-frame-img');
+ if (!f) return null;
+ const img = f.querySelector('img');
+ const declared = getComputedStyle(f).aspectRatio;
+ return { declared, natural: `${img.naturalWidth} / ${img.naturalHeight}` };
+ });
+ if (cls) note(cls.declared.replace(/\s/g, '') === cls.natural.replace(/\s/g, ''), `reserved box ${cls.declared} matches natural ${cls.natural}`);
+
+ note(errors.length === 0, errors.length ? `console errors: ${errors.slice(0, 3).join(' | ')}` : 'no console errors');
+ await ctx.close();
+}
+
+// Mobile: 320px, the narrowest viewport we support.
+console.log('\n=== /tutorials/text-to-3d (320px) ===');
+const mob = await browser.newContext({ ...devices['iPhone SE'], viewport: { width: 320, height: 640 } });
+const mp = await mob.newPage();
+await mp.goto(`${BASE}/tutorials/text-to-3d`, { waitUntil: 'domcontentloaded', timeout: 120000 });
+await mp.waitForSelector('.tfig', { timeout: 20000 }).catch(() => {});
+await mp.waitForTimeout(3000);
+const mobile = await mp.evaluate(() => {
+ const doc = document.documentElement;
+ const over = [...document.querySelectorAll('.tfig, .tfig-body, .tfig-caption')].filter(
+ (el) => el.getBoundingClientRect().right > window.innerWidth + 1,
+ );
+ return {
+ hOverflow: doc.scrollWidth > doc.clientWidth,
+ scrollWidth: doc.scrollWidth,
+ clientWidth: doc.clientWidth,
+ overflowing: over.map((e) => e.className),
+ zoomAlwaysVisible: getComputedStyle(document.querySelector('.tfig-zoom') || document.body).opacity,
+ };
+});
+console.log(JSON.stringify(mobile, null, 1));
+note(!mobile.hOverflow, `no horizontal page overflow at 320px (${mobile.scrollWidth} vs ${mobile.clientWidth})`);
+note(mobile.overflowing.length === 0, 'no figure element spills past the viewport');
+await mob.close();
+
+await browser.close();
+console.log(`\n${failures === 0 ? 'ALL CHECKS PASSED' : `${failures} CHECK(S) FAILED`}`);
+process.exit(failures === 0 ? 0 : 1);