gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commita404ed75a404ed75Report HM57 audit, gates and integration notesmrea404ed75/tests/hm56-proof.mjs

4.7 KB

  1. import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
  2. import { launchBrowser } from './cdp.mjs';
  3. const root = '/media/STORAGE/claude-scratch/tracker/HM56';
  4. const phase = process.argv[2];
  5. if (!['before', 'after'].includes(phase)) throw Error('Expected before or after');
  6. const base = 'http://127.0.0.1:8716';
  7. const sid = readFileSync(root + '/test-sid', 'utf8').trim();
  8. const out = root + '/' + phase;
  9. mkdirSync(out, { recursive: true });
  10. const browser = await launchBrowser({ debugPortRange: [8718, 8718] });
  11. console.log('Chrome PID', browser.proc.pid);
  12. let page;
  13. const results = [];
  14. try {
  15. page = await browser.newPage();
  16. await page.send('Network.setCookie', { name: 'trackersid', value: sid, url: base });
  17. const hydrated = () => page.waitFor('window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1', { timeout: 120000 });
  18. const ev = s => page.evaluate(s);
  19. const shot = async name => writeFileSync(out + '/' + name + '.png', Buffer.from((await page.send('Page.captureScreenshot', { format: 'png' })).data, 'base64'));
  20. for (const [width, height] of [[390,844], [800,1280], [1280,800]]) {
  21. await page.send('Emulation.setDeviceMetricsOverride', { width, height, deviceScaleFactor: 1, mobile: width === 390 });
  22. for (const path of ['/my/shows', '/my/series', '/my/movies', '/my/schedule']) {
  23. const html = await (await fetch(base + path, { headers: { cookie: 'trackersid=' + sid } })).text();
  24. const tag = path.includes('movies') ? 'my-movies-page' : path.includes('schedule') ? 'schedule-page' : 'my-shows-page';
  25. const body = html.match(new RegExp('<' + tag + '[^>]*>[\\s\\S]*?</' + tag + '>'))?.[0];
  26. if (!body) throw Error('Missing list HTML ' + path);
  27. const name = path.replaceAll('/', '-') + '-' + width;
  28. writeFileSync(out + '/' + name + '.html', body);
  29. if (phase === 'after' && body !== readFileSync(root + '/before/' + name + '.html', 'utf8')) throw Error('HTML changed: ' + name);
  30. await page.goto(base + path); await hydrated();
  31. await shot(name);
  32. results.push({ width, path, htmlBytes: body.length, rows: await ev('document.querySelectorAll("my-show-row, schedule-row").length') });
  33. }
  34. await page.goto(base + '/series/The-Simpsons'); await hydrated();
  35. await page.waitForSelector('season-row .season-toggle');
  36. const season = await ev('Array.from(document.querySelectorAll("season-row")).find(r => r.classList.contains("collapsed"))?.querySelector(".season-toggle").value');
  37. if (!season) throw Error('No closed season');
  38. const toggle = `season-row .season-toggle[value=${JSON.stringify(season)}]`;
  39. await ev('window.__kept = Array.from(document.querySelectorAll("season-row"))');
  40. let start = Date.now();
  41. await page.click(toggle);
  42. await page.waitFor(`document.querySelector(${JSON.stringify(toggle)}).closest('season-row').nextElementSibling?.tagName === 'EPISODE-ROW'`, { timeout: 120000 });
  43. const openMs = Date.now() - start;
  44. const episode = await ev(`document.querySelector(${JSON.stringify(toggle)}).closest('season-row').nextElementSibling.querySelector('button').value`);
  45. const epSel = `episode-row button[value=${JSON.stringify(episode)}]`;
  46. const check = async selector => {
  47. const old = await ev(`document.querySelector(${JSON.stringify(selector)}).className`);
  48. const t = Date.now(); await page.click(selector);
  49. await page.waitFor(`document.querySelector(${JSON.stringify(selector)})?.className !== ${JSON.stringify(old)}`, { timeout: 120000 });
  50. return Date.now() - t;
  51. };
  52. const episodeMs = await check(epSel);
  53. await check(epSel);
  54. const seasonCheck = `season-row button[aria-label="mark season watched"][value=${JSON.stringify(season)}]`;
  55. const seasonMs = await check(seasonCheck);
  56. await check(seasonCheck);
  57. const retained = await ev('window.__kept.every((r,i) => r === document.querySelectorAll("season-row")[i])');
  58. if (!retained) throw Error('Season node identity changed');
  59. await shot('show-open-' + width);
  60. start = Date.now(); await page.click(toggle);
  61. await page.waitFor(`document.querySelector(${JSON.stringify(toggle)}).closest('season-row').classList.contains('collapsed')`);
  62. const closeMs = Date.now() - start;
  63. await shot('show-closed-' + width);
  64. results.push({ width, show: 'The-Simpsons', season, openMs, closeMs, episodeMs, seasonMs, seasonNodesRetained: retained });
  65. }
  66. console.log(JSON.stringify(results, null, 2));
  67. console.log('problems', JSON.stringify(page.problems()));
  68. writeFileSync(out + '/results.json', JSON.stringify(results, null, 2));
  69. } finally {
  70. if (page) await page.close();
  71. console.log('final targets', JSON.stringify((await (await fetch(browser.endpoint + '/json/list')).json()).map(p => ({type:p.type,url:p.url}))));
  72. await browser.close();
  73. }

Branches

Latest commits

  • a404ed75Report HM57 audit, gates and integration notesmre
  • 1dcb87a7Use plain declarations for unchanged bindingsmre
  • 9edcc2dflog: #58 live, HM57 startedmre
  • 73fa20ddMerge hm49b-styles: tracker#49 rest of the component stylesmre
  • 14195720log: HM49B done, HM51 startedmre
  • 78ee6b56Move remaining component styles into Style blocksmre
  • 7f04de33log: HM49Bmre
  • 00616cf3log: #49 batch merged, DP67 startedmre
  • d7232e86Merge hm49-styles: tracker#49 first batch of component stylesmre
  • 079f376dMove seven components' styles into Style blocksmre
  • 17d66feelog: #58 mergedmre
  • 69a6640bMerge hm58-map: tracker#58 project.hl only the mapmre
  • a85f7900Move route logic out of the project mapmre
  • 13dea5belog: #56 live, HM49 and HM58 startedmre
  • a31c8f2fdocs: tracker#36 remaining listmre
  • 975d06d1log: #36 live, DP66 startedmre
  • d6d03fa3mission: T36Bmre
  • e7512d00status: #36 rolled back, retry askedmre
  • c98e2043log: T36A rollbackmre
  • ae905f15Merge t36a: tracker#36 apply rechecks, reportmre