gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit139fafd8139fafd8tracker#16: short bio (4 lines, click = all), real-data check script, README + STATUSmre139fafd8/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

  • 139fafd8tracker#16: short bio (4 lines, click = all), real-data check script, README + STATUSmre
  • 93be9476tracker#16: person pages /person/<slug> with the filmography fetched from TMDB on the first visit (step by step), gatemre
  • 47a3cae6STATUS: mission 053 merge commit idsmre
  • dcc5eecaMerge branch 't14-search'mre
  • 03edc783Merge branch 't15-tvmaze'mre
  • 71b46345tracker#15: numbering check by date or title, placeholder titles in other languages, docs + real-data proofmre
  • 6bb2daf1tracker#13: homepage (tiles, intro, latest movies/shows), /shows, /movies/page/N, /my/movies; lists cached in memorymre
  • b8bd1157tracker#14: README + STATUS (search, real-data numbers, gate, merge notes)mre
  • 65c694a8tracker#14: search — header magnifier, /search/<text> (in-memory word-prefix index over titles + people), Fetch from web (TMDB search/multi, ours left out), Add = import via syncShow; gate +25 checks, real-data scriptmre
  • 34f2c15btracker#15: TVmaze merge in the sync (gaps only: new episodes/seasons, empty titles/air dates; numbering check), fake TVmaze episodes + gatemre
  • cbdc4ea7tracker#12: link icons TMDB/IMDb/TVDB/TVmaze; sync fills missing ids (TVmaze lookup); movies fetched via /movie/mre
  • b105bcd8tracker#11: Hybriel master ff51cf46 (checks no longer vanish), mobile-first styles, carets, follow button, sign-in modal, inverted check, orange castmre
  • 31b758aatracker#10: installable app (manifest, service worker, offline shell), own icon + faviconmre
  • 2fa9d997tracker#9: TMDB sync (followed shows: seasons, episodes, posters), tools/sync-tmdb.hl + daily run 04:00 UTC, fake TMDB in gatemre
  • 49e1f61edeploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
  • 54070a4etracker#8: /my/unwatched + /my/schedule (301 from old), S01E01, title (year), 1 episode, watched-set lookup (unwatched 15s -> 1s)mre
  • 3251488atracker#7: /my/shows (followed shows, newest follow first, poster, title, last watched SxxEyy); gate can take screenshots (TRACKER_GATE_SHOTS)mre
  • 44b7d9f9tracker#6: /schedule — upcoming episodes of followed shows, soonest firstmre
  • 91c9fc8ctracker#5: /unwatched — unwatched released episodes of followed shows, newest firstmre
  • a97c0295tracker#4: show page /shows/:slug (header, seasons, episodes, watch checks) + tools/relink-episode-seasons.hlmre