gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitee2b677aee2b677alog: RV39 deployingmreee2b677a/tests/realdata-check.mjs

6.9 KB

  1. // tests/realdata-check.mjs — the REAL-DATA check (NOT part of the gate; mission 047, extended in tracker.worldapi.org#13): a dev
  2. // server on :8730 over a COPY of Byrodin's storage/, a session file for the creator (az5b2) whose id is in .scratch/real-sid
  3. // (STATUS.md has the procedure). Full load of /, /movies (+ page 2), /shows, /my/movies, /my/* and the first followed show
  4. // (direct + CLIENT-SIDE from /my/shows): navigate → document complete → socket open → every poster on the page loaded.
  5. // Pagination clicks on /movies, the homepage headings, Back. Checks every check svg is drawn; screenshots 390 + 1280 into
  6. // $REAL_SHOTS (default /tmp/w050/real). Run: node tests/realdata-check.mjs
  7. // (#15: REAL_PORT / REAL_CHROME / REAL_OUT override 8730 / 8731 / the shots dir; REAL_SHOW = a show path to time instead of the first followed)
  8. import { writeFileSync, readFileSync, mkdirSync } from 'node:fs';
  9. import { launchBrowser } from '../tests/cdp.mjs';
  10. process.env.HL_CHROME ||= '/opt/google/chrome/chrome';
  11. const BASE = `http://127.0.0.1:${process.env.REAL_PORT || 8730}`, OUT = process.env.REAL_OUT || process.env.REAL_SHOTS || '/tmp/w050/real', SID = readFileSync('.scratch/real-sid', 'utf8').trim();
  12. mkdirSync(OUT, { recursive: true });
  13. const browser = await launchBrowser({ debugPortRange: [Number(process.env.REAL_CHROME || 8731), Number(process.env.REAL_CHROME || 8731)] });
  14. const page = await browser.newPage();
  15. const ev = (e) => page.evaluate(e);
  16. await page.send('Network.enable', {});
  17. await page.send('Network.setCookie', { name: 'trackersid', value: SID, url: BASE });
  18. const hydrated = () => page.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1 && document.readyState === "complete"', { timeout: 30000, label: 'hydrated' });
  19. // every poster IN THE VIEWPORT loaded (the tiles are loading="lazy": the ones further down or right load when scrolled to)
  20. const postersDone = () => page.waitFor(`Array.from(document.querySelectorAll('img.myshow-poster, img.tile-poster')).filter(i => { const r = i.getBoundingClientRect(); return r.top < innerHeight && r.bottom > 0 && r.left < innerWidth && r.right > 0 }).every(i => i.complete && i.naturalWidth > 0)`, { timeout: 30000, label: 'posters' });
  21. const shot = async (n) => writeFileSync(`${OUT}/${n}.png`, Buffer.from((await page.send('Page.captureScreenshot', { format: 'png' })).data, 'base64'));
  22. const svgState = () => ev(`JSON.stringify((() => { const s = Array.from(document.querySelectorAll('button.checkicon svg, season-caret svg'));
  23. return { checks: document.querySelectorAll('button.checkicon').length, badNs: s.filter(e => e.namespaceURI !== 'http://www.w3.org/2000/svg').length,
  24. undrawn: Array.from(document.querySelectorAll('button.checkicon svg circle')).filter(c => !(c.getBoundingClientRect().width > 0)).length }; })())`);
  25. const res = [];
  26. for (const [w, h, mobile] of [[390, 844, true], [1280, 900, false]]) {
  27. await page.send('Emulation.setDeviceMetricsOverride', { width: w, height: h, deviceScaleFactor: mobile ? 2 : 1, mobile });
  28. let showPath = null;
  29. for (const [name, path] of [['home', '/'], ['movies', '/movies'], ['movies-page-2', '/movies/page/2'], ['shows', '/shows'], ['shows-page-2', '/shows/page/2'], ['my-movies', '/my/movies'], ['my-shows', '/my/shows'], ['my-unwatched', '/my/unwatched'], ['my-schedule', '/my/schedule']]) {
  30. const t = Date.now();
  31. await page.goto(BASE + path, { timeout: 60000 });
  32. await hydrated();
  33. await postersDone();
  34. const ms = Date.now() - t;
  35. const info = await ev(`JSON.stringify({ rows: document.querySelectorAll('my-show-row, unwatched-row, schedule-row').length, tiles: document.querySelectorAll('a.tile').length, hometiles: document.querySelectorAll('a.hometile').length, current: (document.querySelector('pagination li.current') || {}).textContent || null, user: !!document.querySelector('#logout'), scrollW: document.documentElement.scrollWidth, headerH: document.querySelector('application-header').getBoundingClientRect().height })`);
  36. res.push(`${w} ${path} ${ms} ms ${info}`);
  37. await shot(`${name}-${w}`);
  38. if (name === 'my-shows') showPath = process.env.REAL_SHOW || await ev(`document.querySelector('a.myshow-title').getAttribute('href')`);
  39. }
  40. // direct load of that show
  41. let t = Date.now();
  42. await page.goto(BASE + showPath); await hydrated();
  43. res.push(`${w} ${showPath} (direct) ${Date.now() - t} ms ${await svgState()}`);
  44. // CLIENT-SIDE: /my/shows → click the first title
  45. await page.goto(BASE + '/my/shows'); await hydrated();
  46. await ev(`window.__w050 = 'same document'`);
  47. t = Date.now();
  48. await page.click(`a.myshow-title[href="${showPath}"]`);
  49. await page.waitFor(`location.pathname === ${JSON.stringify(showPath)} && !!document.querySelector('button.checkicon svg circle')`, { timeout: 20000, label: 'client nav' });
  50. res.push(`${w} client-side nav → ${showPath} ${Date.now() - t} ms marker=${await ev('window.__w050')} ${await svgState()}`);
  51. // the homepage's "Movies" heading → /movies, client-side; the pagination: "Next", then "4" (a number), then Back
  52. await page.goto(BASE + '/'); await hydrated();
  53. await ev(`window.__w050 = 'same document'`);
  54. t = Date.now();
  55. await page.click('#home-movies h2 a');
  56. await page.waitFor(`location.pathname === '/movies' && document.querySelectorAll('a.tile').length === 24`, { timeout: 20000, label: 'heading → /movies' });
  57. await postersDone();
  58. res.push(`${w} heading click → /movies ${Date.now() - t} ms marker=${await ev('window.__w050')}`);
  59. const pageClick = async (label, want) => {
  60. const first = await ev(`document.querySelector('a.tile').getAttribute('href')`);
  61. const tt = Date.now();
  62. await ev(`Array.from(document.querySelectorAll('pagination button')).find(b => b.textContent === ${JSON.stringify(label)}).click()`);
  63. await page.waitFor(`location.pathname === ${JSON.stringify(want)} && document.querySelector('a.tile').getAttribute('href') !== ${JSON.stringify(first)} && document.querySelector('pagination li.current').textContent.trim() === ${JSON.stringify(want.split('/').pop() === 'movies' ? '1' : want.split('/').pop())}`, { timeout: 20000, label: 'page ' + want });
  64. await postersDone();
  65. res.push(`${w} pagination "${label}" → ${want} ${Date.now() - tt} ms marker=${await ev('window.__w050')} title="${await ev('document.title')}"`);
  66. };
  67. await pageClick('Next', '/movies/page/2');
  68. await pageClick('4', '/movies/page/4');
  69. await ev('window.scrollTo(0, document.documentElement.scrollHeight)');
  70. await postersDone();
  71. await shot(`movies-page-4-bottom-${w}`);
  72. await pageClick('Previous', '/movies/page/3');
  73. await ev('history.back()');
  74. await page.waitFor(`location.pathname === '/movies/page/4' && document.querySelector('pagination li.current').textContent.trim() === '4'`, { timeout: 20000, label: 'back' });
  75. res.push(`${w} Back → /movies/page/4 (current 4) marker=${await ev('window.__w050')}`);
  76. }
  77. console.log(res.join('\n'));
  78. console.log('problems', JSON.stringify(page.problems ? page.problems() : []));
  79. await browser.close();

Branches

Latest commits

  • ee2b677alog: RV39 deployingmre
  • c1c4178cMerge branch 'rv39'mre
  • a016e9abReapply "Merge branch 'rv39'"mre
  • f29e2502log: RV39 gate fixmre
  • d9fce111browser gate #26: exact frame count incl. SL1 people step (hybriel#308)mre
  • ad529ac1log: m572 verdictmre
  • 1b37d404RV39 on hold: hybriel#308mre
  • f9127c68Revert "Merge branch 'rv39'"mre
  • cd39f3d3log: hybriel#308mre
  • 51341d6elog: RV39 deploy startedmre
  • c9e29e06Merge branch 'rv39'mre
  • 0f8d1fdclog: RV39 report, browser 387/2mre
  • 50249b0bRV39: reportmre
  • 10ed9581compose: HL_GC_STATS=1mre
  • 955da19bRV39: re-vendor Hybriel set day39 (source 51e921d7, bin 6b481aa7)mre
  • 64b8d1dclog: RV39 startedmre
  • 1f2df72amission RV39mre
  • 6c1936f9log+status: GC planmre
  • 2846a840log: m569 result, GC hypothesismre
  • b24cd2d5log: Anton on hl:fetch, mission 569mre