tracker
All repositories: gitoria
4.7 KB
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';import { launchBrowser } from './cdp.mjs';const root = '/media/STORAGE/claude-scratch/tracker/HM56';const phase = process.argv[2];if (!['before', 'after'].includes(phase)) throw Error('Expected before or after');const base = 'http://127.0.0.1:8716';const sid = readFileSync(root + '/test-sid', 'utf8').trim();const out = root + '/' + phase;mkdirSync(out, { recursive: true });const browser = await launchBrowser({ debugPortRange: [8718, 8718] });console.log('Chrome PID', browser.proc.pid);let page;const results = [];try {page = await browser.newPage();await page.send('Network.setCookie', { name: 'trackersid', value: sid, url: base });const hydrated = () => page.waitFor('window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1', { timeout: 120000 });const ev = s => page.evaluate(s);const shot = async name => writeFileSync(out + '/' + name + '.png', Buffer.from((await page.send('Page.captureScreenshot', { format: 'png' })).data, 'base64'));for (const [width, height] of [[390,844], [800,1280], [1280,800]]) {await page.send('Emulation.setDeviceMetricsOverride', { width, height, deviceScaleFactor: 1, mobile: width === 390 });for (const path of ['/my/shows', '/my/series', '/my/movies', '/my/schedule']) {const html = await (await fetch(base + path, { headers: { cookie: 'trackersid=' + sid } })).text();const tag = path.includes('movies') ? 'my-movies-page' : path.includes('schedule') ? 'schedule-page' : 'my-shows-page';const body = html.match(new RegExp('<' + tag + '[^>]*>[\\s\\S]*?</' + tag + '>'))?.[0];if (!body) throw Error('Missing list HTML ' + path);const name = path.replaceAll('/', '-') + '-' + width;writeFileSync(out + '/' + name + '.html', body);if (phase === 'after' && body !== readFileSync(root + '/before/' + name + '.html', 'utf8')) throw Error('HTML changed: ' + name);await page.goto(base + path); await hydrated();await shot(name);results.push({ width, path, htmlBytes: body.length, rows: await ev('document.querySelectorAll("my-show-row, schedule-row").length') });}await page.goto(base + '/series/The-Simpsons'); await hydrated();await page.waitForSelector('season-row .season-toggle');const season = await ev('Array.from(document.querySelectorAll("season-row")).find(r => r.classList.contains("collapsed"))?.querySelector(".season-toggle").value');if (!season) throw Error('No closed season');const toggle = `season-row .season-toggle[value=${JSON.stringify(season)}]`;await ev('window.__kept = Array.from(document.querySelectorAll("season-row"))');let start = Date.now();await page.click(toggle);await page.waitFor(`document.querySelector(${JSON.stringify(toggle)}).closest('season-row').nextElementSibling?.tagName === 'EPISODE-ROW'`, { timeout: 120000 });const openMs = Date.now() - start;const episode = await ev(`document.querySelector(${JSON.stringify(toggle)}).closest('season-row').nextElementSibling.querySelector('button').value`);const epSel = `episode-row button[value=${JSON.stringify(episode)}]`;const check = async selector => {const old = await ev(`document.querySelector(${JSON.stringify(selector)}).className`);const t = Date.now(); await page.click(selector);await page.waitFor(`document.querySelector(${JSON.stringify(selector)})?.className !== ${JSON.stringify(old)}`, { timeout: 120000 });return Date.now() - t;};const episodeMs = await check(epSel);await check(epSel);const seasonCheck = `season-row button[aria-label="mark season watched"][value=${JSON.stringify(season)}]`;const seasonMs = await check(seasonCheck);await check(seasonCheck);const retained = await ev('window.__kept.every((r,i) => r === document.querySelectorAll("season-row")[i])');if (!retained) throw Error('Season node identity changed');await shot('show-open-' + width);start = Date.now(); await page.click(toggle);await page.waitFor(`document.querySelector(${JSON.stringify(toggle)}).closest('season-row').classList.contains('collapsed')`);const closeMs = Date.now() - start;await shot('show-closed-' + width);results.push({ width, show: 'The-Simpsons', season, openMs, closeMs, episodeMs, seasonMs, seasonNodesRetained: retained });}console.log(JSON.stringify(results, null, 2));console.log('problems', JSON.stringify(page.problems()));writeFileSync(out + '/results.json', JSON.stringify(results, null, 2));} finally {if (page) await page.close();console.log('final targets', JSON.stringify((await (await fetch(browser.endpoint + '/json/list')).json()).map(p => ({type:p.type,url:p.url}))));await browser.close();}
Branches
Latest commits
- 8d9ecdfeRV48: re-vendor Hybriel set day48 (source b6a8f429, bin 660a9524)mre
- 4a802ae7status: RV48 runningmre
- 0a5412b6RV48 brief, day48 outmre
- 56665efelog: CB69 mergedmre
- 05448a98Merge cb69-imports: appTitle in a dependency-free topicmre
- e55b379dKeep shared app title independent of the route import graphmre
- 9a99659blog: hybriel#334, batch waits for day48mre
- 85fa6c9blog: CB68 result, CB69 startedmre
- 2f07c1b7log: DP68 boot gate failed, CB68mre
- 9652782dlog: HM59 merged, DP68 startedmre
- 29867a75Merge hm59-logic: tracker#59 page logic moved to libmre
- f7bfe90bMove remaining page builders into their topicsmre
- 7c3991f9log: day46 from Antonmre
- ec54fc35Move show page logic into the shows topicmre
- c1a8d074log: correct timesmre
- 5827eba9log: HM57 merged, HM59 startedmre
- d1a91be9Merge hm57-let: tracker#57 let only for reassigned namesmre
- a404ed75Report HM57 audit, gates and integration notesmre
- 1dcb87a7Use plain declarations for unchanged bindingsmre
- b90395e3log: HM51 mergedmre