gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit2c95ac462c95ac46|||PR AP62: re-vendor Hybriel set day62 (source 70341ad2, bin a54f5f08)Tracker2c95ac46/tests/realdata-068.mjs

4.5 KB

  1. // tests/realdata-068.mjs — tracker#20/#21 (mission 068), NOT the gate: on a COPY of live storage/ (STATUS.md has the procedure),
  2. // after the kind backfill. (1) SPOT CHECKS by name: what our search says each title is (Series / Show / Movie) and where it links.
  3. // (2) Signed in (cookie from .scratch/w068/real-sid) at 390 + 1280: every page kind's full load time (to hydrated), its typed
  4. // heading, no sideways scroll, a screenshot → $REAL_OUT. Env: REAL_PORT (8760), REAL_CHROME (8767), REAL_NAMES (comma list).
  5. import { writeFileSync, readFileSync, mkdirSync } from 'node:fs';
  6. import { launchBrowser } from './cdp.mjs';
  7. process.env.HL_CHROME ||= '/opt/google/chrome/chrome';
  8. const BASE = `http://127.0.0.1:${process.env.REAL_PORT || 8760}`, OUT = process.env.REAL_OUT || '/tmp/w068/real';
  9. const SID = readFileSync(process.env.REAL_SID_FILE || '.scratch/w068/real-sid', 'utf8').trim();
  10. mkdirSync(OUT, { recursive: true });
  11. // (1) spot checks: the search's row for the exact title (with its year), by the server's own render
  12. const names = (process.env.REAL_NAMES || 'Reacher,Saturday Night Live,The Tonight Show Starring Jimmy Fallon,Last Week Tonight with John Oliver,Foundation,Doctor Who,Jersey Shore,Chernobyl,Planet Earth,Hot Ones,The Late Show with Stephen Colbert,Severance').split(',');
  13. const spot = [];
  14. for (const n of names) {
  15. const h = await (await fetch(BASE + '/search/' + encodeURIComponent(n))).text();
  16. const rows = [...h.matchAll(/<search-row>[\s\S]*?class="search-title" href="([^"]*)">([^<]*)<\/a>[\s\S]*?<search-type class="([^"]*)">([^<]*)<\/search-type>/g)].map(m => ({ href: m[1], title: m[2], type: m[4] }));
  17. const hit = rows.filter(r => r.title.replace(/ \(\d{4}\)$/, '') === n);
  18. spot.push(n + ': ' + (hit.length ? hit.map(r => `${r.type} ${r.title} → ${r.href}`).join(' | ') : 'not in our data'));
  19. }
  20. console.log('SPOT CHECKS\n' + spot.join('\n'));
  21. // (2) pages, signed in
  22. const browser = await launchBrowser({ debugPortRange: [Number(process.env.REAL_CHROME || 8767), Number(process.env.REAL_CHROME || 8767)] });
  23. const page = await browser.newPage();
  24. const ev = (e) => page.evaluate(e);
  25. const hydrated = () => page.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1 && document.readyState === "complete"', { timeout: 60000, label: 'hydrated' });
  26. const shot = async (n) => writeFileSync(`${OUT}/${n}.png`, Buffer.from((await page.send('Page.captureScreenshot', { format: 'png' })).data, 'base64'));
  27. const load = async (path) => { const t = Date.now(); await page.goto(BASE + path, { timeout: 60000 }); await hydrated(); return Date.now() - t; };
  28. await page.send('Network.setCookie', { name: 'trackersid', value: SID, url: BASE });
  29. // a movie the creator follows, and the first cast member of Reacher, from the pages themselves
  30. await load('/my/movies');
  31. const movie = await ev(`(document.querySelector('a.myshow-title') || {}).getAttribute ? document.querySelector('a.myshow-title').getAttribute('href') : '/movies'`);
  32. await load('/series/Reacher');
  33. const person = await ev(`(document.querySelector('a.artist-link') || {}).getAttribute ? document.querySelector('a.artist-link').getAttribute('href') : '/'`);
  34. const PAGES = [['home', '/'], ['series-list', '/series'], ['shows-list', '/shows'], ['movies-list', '/movies'], ['series', '/series/Reacher'], ['show', '/shows/Saturday-Night-Live'],
  35. ['movie', movie], ['genre', '/genres/Drama'], ['person', person], ['my-series', '/my/series'], ['my-shows', '/my/shows'], ['search', '/search/reacher']];
  36. const out = [];
  37. for (const [w, h, mobile] of [[390, 844, true], [1280, 900, false]]) {
  38. await page.send('Emulation.setDeviceMetricsOverride', { width: w, height: h, deviceScaleFactor: mobile ? 2 : 1, mobile });
  39. for (const [name, path] of PAGES) {
  40. const ms = await load(path);
  41. await page.waitFor(`Array.from(document.querySelectorAll('img')).filter(i => { const r = i.getBoundingClientRect(); return r.top < innerHeight && r.bottom > 0 }).every(i => i.complete)`, { timeout: 10000, label: 'images' }).catch(() => {});
  42. const info = await ev(`JSON.stringify({ h1: (document.querySelector('h1') || {}).innerText ? document.querySelector('h1').innerText.replace(/\\s+/g, ' ') : '', word: document.querySelector('h1 type-word') ? getComputedStyle(document.querySelector('h1 type-word')).color : '', sideways: document.documentElement.scrollWidth > ${w}, rows: document.querySelectorAll('my-show-row, a.tile, search-row, a.film-row').length })`);
  43. await shot(`${name}-${w}`);
  44. out.push(`${w} ${path} ${ms} ms ${info}`);
  45. }
  46. }
  47. console.log('PAGES\n' + out.join('\n'));
  48. console.log('problems', JSON.stringify(page.problems ? page.problems() : []));
  49. await browser.close();

Branches

Latest commits

  • 2c95ac46|||PR AP62: re-vendor Hybriel set day62 (source 70341ad2, bin a54f5f08)Tracker
  • b9c7c3c8Merge branch 'records-dp74' into mainTracker
  • 85cfb4ae|||PR records: AP61 day61, DP74 liveTracker
  • b1496147Merge branch 'ap61' into mainTracker
  • 2047955bMerge branch 'u12-gateports' into mainTracker
  • c8da40f3|||PR AP61: re-vendor Hybriel set day61 (source a05af47c, bin a11042e5)Tracker
  • 4e018678|||PR deploy.sh: gates use Tracker's ports 8716-8719 and LC_ALL=C; README: 2 backups keptTracker
  • 0b86324aMerge branch 'records-dp73' into mainTracker
  • 9ce5f59b|||PR records: DP73 live 613ae0e; deploy.sh keeps 2 backupsTracker
  • 613ae0ecMerge branch 'bs3' into mainTracker
  • 1383264b|||PR BS3: keep shared synchronous sorting fastTracker
  • 63e5ba1a|||PR BS3: guard boot imports and share resumable sort buffersTracker
  • 310613f1Merge branch 'records-dp72' into mainTracker
  • 6f7b61ba|||PR records: deploy-swap fix live, Kunibert findingsTracker
  • c41587d2Merge branch 'bs2' into mainTracker
  • 0dd538a6|||PR BS2: finish the boot index in slices so a booting instance keeps answeringTracker
  • 019d5cedMerge branch 'records-1110' into mainTracker
  • f88ae8b9|||PR records: day56 toggle live, reviewTracker
  • b6b3bb4dMerge branch 'ap56e' into mainTracker
  • 29a26da9|||PR AP56e: guard hidden show helpers during session syncTracker