gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitb8bd1157b8bd1157tracker#14: README + STATUS (search, real-data numbers, gate, merge notes)mreb8bd1157/tests/realdata-search.mjs

6.6 KB

  1. // tests/realdata-search.mjs — tracker.worldapi.org#14 REAL-DATA check of the search (NOT part of the gate): a dev server
  2. // (TRACKER_REAL_BASE, default http://127.0.0.1:8770) over a COPY of Byrodin's storage/ with the REAL TMDB (the dev .env),
  3. // a session file for the creator (az5b2) whose id is in .scratch/real-sid (STATUS.md "ticket #14" has the procedure).
  4. // Times: the page load, every keystroke → its results, "Fetch from web", an import (it WRITES — a copy only!) and the
  5. // imported show's page; screenshots 390 + 1280 into TRACKER_REAL_SHOTS (default /tmp/w052-t14/real). Run: node tests/realdata-search.mjs
  6. import { writeFileSync, readFileSync, mkdirSync } from 'node:fs';
  7. import { launchBrowser } from './cdp.mjs';
  8. process.env.HL_CHROME ||= '/opt/google/chrome/chrome';
  9. const BASE = process.env.TRACKER_REAL_BASE || 'http://127.0.0.1:8770';
  10. const OUT = process.env.TRACKER_REAL_SHOTS || '/tmp/w052-t14/real';
  11. const SID = readFileSync('.scratch/real-sid', 'utf8').trim();
  12. const [CH_FROM, CH_TO] = (process.env.TRACKER_REAL_CHROME || '8771-8772').split('-').map(Number);
  13. // a title the real data has, and one it does not (the import); override with env
  14. const HAVE = process.env.TRACKER_REAL_HAVE || 'doctor who';
  15. const WEB = process.env.TRACKER_REAL_WEB || 'severance';
  16. mkdirSync(OUT, { recursive: true });
  17. const browser = await launchBrowser({ debugPortRange: [CH_FROM, CH_TO] });
  18. const page = await browser.newPage();
  19. const ev = (e) => page.evaluate(e);
  20. await page.send('Network.enable', {});
  21. await page.send('Network.setCookie', { name: 'trackersid', value: SID, url: BASE });
  22. const hydrated = () => page.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1 && document.readyState === "complete"', { timeout: 30000, label: 'hydrated' });
  23. const shot = async (n) => writeFileSync(`${OUT}/${n}.png`, Buffer.from((await page.send('Page.captureScreenshot', { format: 'png' })).data, 'base64'));
  24. const titles = () => ev(`JSON.stringify(Array.from(document.querySelectorAll('#titles .search-title')).map(a => a.textContent))`);
  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 t = Date.now();
  29. await page.goto(BASE + '/search');
  30. await hydrated();
  31. res.push(`${w} /search load ${Date.now() - t} ms, signed in: ${await ev(`!!document.querySelector('#logout')`)}, focused: ${await ev(`document.activeElement && document.activeElement.id`)}`);
  32. // type HAVE letter by letter, timing each keystroke until the address and the list follow it
  33. let typed = '';
  34. const per = [];
  35. for (const ch of HAVE) {
  36. typed += ch;
  37. t = Date.now();
  38. await page.type('#searchinput', ch);
  39. await page.waitFor(`location.pathname === ${JSON.stringify(typed.trim() ? '/search/' + encodeURIComponent(typed.trim()) : '/search')} && document.querySelector('search-page').getAttribute('data-for') === ${JSON.stringify(typed)}`, { timeout: 10000 });
  40. per.push(Date.now() - t);
  41. }
  42. res.push(`${w} typing "${HAVE}": per keystroke ms ${per.join(',')}; first titles ${(JSON.parse(await titles())).slice(0, 4).join(' | ')}; ${await ev(`document.querySelectorAll('search-row').length`)} rows; scrollW ${await ev('document.documentElement.scrollWidth')}`);
  43. await shot(`search-typed-${w}`);
  44. // a reload of the address opens the same results (server render)
  45. t = Date.now();
  46. await page.goto(BASE + '/search/' + encodeURIComponent(HAVE));
  47. await hydrated();
  48. res.push(`${w} reload /search/${encodeURIComponent(HAVE)} ${Date.now() - t} ms, input "${await ev(`document.querySelector('#searchinput').value`)}", ${(JSON.parse(await titles())).length} titles`);
  49. }
  50. // the web + the import, once (1280)
  51. await page.goto(BASE + '/search/' + encodeURIComponent(WEB));
  52. await hydrated();
  53. res.push(`db for "${WEB}": ${await titles()}`);
  54. let t = Date.now();
  55. await page.click('#fetchweb');
  56. await page.waitFor(`document.querySelectorAll('web-row').length > 0 || !!document.querySelector('#webnote')`, { timeout: 30000, label: 'web results' });
  57. res.push(`fetch from web "${WEB}" ${Date.now() - t} ms: ${await ev(`JSON.stringify(Array.from(document.querySelectorAll('web-row')).map(r => r.querySelector('web-title').textContent + ' [' + r.querySelector('button.add').value + ']'))`)} ${await ev(`document.querySelector('#webnote') ? document.querySelector('#webnote').textContent : ''`)}`);
  58. await page.waitFor(`Array.from(document.querySelectorAll('web-row img')).every(i => i.complete)`, { timeout: 15000 }).catch(() => {});
  59. await shot('search-web-1280');
  60. await page.send('Emulation.setDeviceMetricsOverride', { width: 390, height: 844, deviceScaleFactor: 2, mobile: true });
  61. await shot('search-web-390');
  62. await page.send('Emulation.setDeviceMetricsOverride', { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false });
  63. if (process.env.TRACKER_REAL_IMPORT !== '0' && await ev(`document.querySelectorAll('web-row').length`) > 0) {
  64. const key = await ev(`document.querySelector('web-row button.add').value`);
  65. t = Date.now();
  66. await page.click(`web-row button.add[value="${key}"]`);
  67. await page.waitFor(`location.pathname.startsWith('/shows/') && !!document.querySelector('show-header h1')`, { timeout: 60000, label: 'imported show page' });
  68. res.push(`import ${key} → ${await ev('location.pathname')} in ${Date.now() - t} ms: ${await ev(`JSON.stringify({ h1: document.querySelector('show-header h1').textContent, seasons: Array.from(document.querySelectorAll('season-row')).map(r => r.querySelector('season-label').textContent + ': ' + r.querySelector('season-count').textContent).slice(0, 6), poster: document.querySelector('show-poster img') ? document.querySelector('show-poster img').getAttribute('src') : null, links: Array.from(document.querySelectorAll('a.extlink')).map(a => a.textContent) })`)}`);
  69. await page.waitFor(`!document.querySelector('show-poster img') || document.querySelector('show-poster img').complete`, { timeout: 15000 }).catch(() => {});
  70. await shot('imported-show-1280');
  71. // searched again: now in our database, and no longer in the web list
  72. await page.goto(BASE + '/search/' + encodeURIComponent(WEB));
  73. await hydrated();
  74. res.push(`after import, db for "${WEB}": ${await titles()}`);
  75. await page.click('#fetchweb');
  76. await page.waitFor(`document.querySelectorAll('web-row').length > 0 || !!document.querySelector('#webnote')`, { timeout: 30000 });
  77. res.push(`after import, web keys: ${await ev(`JSON.stringify(Array.from(document.querySelectorAll('web-row button.add')).map(b => b.value))`)} (${key} must be gone)`);
  78. }
  79. console.log(res.join('\n'));
  80. console.log('problems', JSON.stringify(page.problems()));
  81. await browser.close();

Branches

Latest commits

  • 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
  • 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
  • 05f407c5tracker: no border on any button except inverted ones (Log out, ident status and identities too); header brand weight 100mre
  • 17375427tracker#2: tools/migrate.hl + tools/verify.hl — old MongoDB data into mpackdb with new idsmre
  • 31aac936tracker#3: no border on the header and on filled buttons; inverted buttons keep theirsmre
  • 2ad9d29ctracker#1: login exactly like calendar (identity selector in the header, empty homepage)mre
  • 3691e176tracker#1: empty tracker with the ident login (state of 2026-09-27)mre