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
- 3bb4ccddAP52: modal close button refers to its nested rule with Style.buttonModalX (tracker#51, hybriel#333)mre
- ba16933fAP52: login callback and title route are static handlers taking the server as third argument (tracker#58, hybriel#332)mre
- 85153900AP52: re-vendor Hybriel set day52 (source 77cfca31, bin 0a8ed496)mre
- 7c051eddLog: hybriel#338 answermre
- d049b8b8Log: HM50 live, #52 donemre
- 6d05fa37Log: HM50 Part A mergedmre
- 1c7dab74HM50: the shell reads the framework's online state, netProbe removed (tracker#55)mre
- e8b91697HM50: search address follows the text via navigate(path, replace = true) (tracker#52)mre
- 6fe1896cHM50: re-vendor Hybriel set day50 (source 0ae38232, bin d3ef9d16)mre
- 2f391aa9Log: HM50 startedmre
- 4b59c03dHM50 mission: doc pathmre
- ed526d67HM50 missionmre
- 2f986ca3Log: RT50 passmre
- 1c4715a4RT50 mission: day50 repro retestmre
- 57d1c0dcLog: day50 retest requestmre
- 60b1f419Log: Anton #336 result, wake checkmre
- 919a18aalog: scratchmre
- 6b504440status tidymre
- 9332bd10log: DP70 livemre
- be11daa0DP70 brief fixmre