gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitc7cdef62c7cdef62Log: Apollo STOP, workers pausedmrec7cdef62/tests/realdata-m026.mjs

4.9 KB

  1. // tests/realdata-m026.mjs — mission 026 (tracker#31, duplicate titles), NOT the gate: what the creator sees on a COPY of live storage
  2. // (tests/realdata-m026.sh start …), signed in as az5b2 (cookie from $REAL_SID_FILE). Prints one JSON line per check and writes
  3. // screenshots (390 + 1280) to $REAL_SHOTS: /my/series (Reacher's last watched episode, Archive 81's row), Reacher's page (season 3
  4. // checked or not), /my/unwatched (Reacher S03 rows), Archive 81's page, the search "archive 81", a talk show with many seasons
  5. // (The View) and its full load time. Env: REAL_PORT, REAL_CHROME, REAL_SID_FILE, REAL_SHOTS, REAL_LABEL (file name prefix).
  6. import { writeFileSync, readFileSync, mkdirSync } from 'node:fs';
  7. import { join } from 'node:path';
  8. import { launchBrowser } from './cdp.mjs';
  9. process.env.HL_CHROME ||= '/opt/google/chrome/chrome';
  10. const PORT = Number(process.env.REAL_PORT || 8730), BASE = `http://127.0.0.1:${PORT}`;
  11. const SID = readFileSync(process.env.REAL_SID_FILE, 'utf8').trim(), SHOTS = process.env.REAL_SHOTS, LABEL = process.env.REAL_LABEL || 'x';
  12. if (SHOTS) mkdirSync(SHOTS, { recursive: true });
  13. const browser = await launchBrowser({ debugPortRange: [Number(process.env.REAL_CHROME || 8729), Number(process.env.REAL_CHROME || 8729)] });
  14. const page = await browser.newPage();
  15. await page.send('Network.setCookie', { name: 'trackersid', value: SID, url: BASE });
  16. const ev = (e) => page.evaluate(e);
  17. const hydrated = () => page.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1 && document.readyState === "complete"', { timeout: 120000, label: 'hydrated' });
  18. const open = async (path) => { const t = Date.now(); await page.goto(BASE + path, { timeout: 120000 }); await hydrated(); return Date.now() - t; };
  19. const shot = async (name, full) => {
  20. if (!SHOTS) return;
  21. for (const [w, h, m] of [[390, 844, true], [1280, 900, false]]) {
  22. await page.send('Emulation.setDeviceMetricsOverride', { width: w, height: h, deviceScaleFactor: 1, mobile: m });
  23. await new Promise(r => setTimeout(r, 300));
  24. const opts = { format: 'png' };
  25. if (full) { const hh = await ev('document.documentElement.scrollHeight'); opts.clip = { x: 0, y: 0, width: w, height: Math.min(hh, 6000), scale: 1 }; opts.captureBeyondViewport = true; }
  26. writeFileSync(join(SHOTS, `${LABEL}-${name}-${w}.png`), Buffer.from((await page.send('Page.captureScreenshot', opts)).data, 'base64'));
  27. }
  28. await page.send('Emulation.clearDeviceMetricsOverride', {});
  29. };
  30. const out = {};
  31. try {
  32. await open('/my/series');
  33. out.mySeries = JSON.parse(await ev(`JSON.stringify(Array.from(document.querySelectorAll('my-show-row')).filter(r => /Reacher|Archive 81|Flight Attendant|Raised by Wolves/.test(r.textContent)).map(r => [r.querySelector('a.myshow-title').textContent, r.querySelector('a.myshow-title').getAttribute('href'), (r.querySelector('my-show-episode') || {}).textContent || '']))`));
  34. out.mySeriesRows = await ev(`document.querySelectorAll('my-show-row').length`);
  35. await shot('my-series');
  36. const seasons = () => ev(`JSON.stringify(Array.from(document.querySelectorAll('season-row')).map(r => r.querySelector('season-label').textContent + ': ' + r.querySelector('season-count').textContent + ' ' + ((r.querySelector('button.checkicon') || {}).getAttribute ? r.querySelector('button.checkicon').getAttribute('class') : '')))`);
  37. await open('/series/Reacher');
  38. out.reacher = JSON.parse(await seasons());
  39. await shot('reacher', true);
  40. await open('/my/unwatched');
  41. out.unwatchedReacher = JSON.parse(await ev(`JSON.stringify(Array.from(document.querySelectorAll('unwatched-row')).filter(r => /Reacher/.test(r.textContent)).map(r => r.querySelector('unwatched-episode').textContent))`));
  42. out.unwatchedRows = await ev(`document.querySelectorAll('unwatched-row').length`);
  43. await shot('my-unwatched');
  44. out.archiveLoad = await open('/series/Archive-81');
  45. out.archive = { h1: await ev(`(document.querySelector('show-header h1 type-name') || {}).textContent`), seasons: JSON.parse(await seasons()), path: await ev('location.pathname') };
  46. await shot('archive-81', true);
  47. await open('/search/archive%2081');
  48. out.search = JSON.parse(await ev(`JSON.stringify(Array.from(document.querySelectorAll('a.search-title')).map(a => a.textContent + ' ' + a.getAttribute('href')))`));
  49. await shot('search-archive');
  50. for (const p of ['/shows/The-View', '/shows/EastEnders', '/series/EastEnders']) {
  51. const r = await fetch(BASE + p, { redirect: 'manual' });
  52. if (r.status === 200) { out.talkPath = p; break; }
  53. if (r.status === 301) { out.talkPath = r.headers.get('location').replace(BASE, ''); break; }
  54. }
  55. if (out.talkPath) {
  56. out.talkLoads = [];
  57. for (let i = 0; i < 3; i++) out.talkLoads.push(await open(out.talkPath));
  58. out.talkSeasons = await ev(`document.querySelectorAll('season-row').length`);
  59. await shot('talk');
  60. }
  61. } catch (e) { out.error = String(e.stack || e); }
  62. console.log(JSON.stringify(out, null, 1));
  63. await browser.close();
  64. process.exit(out.error ? 1 : 0);

Branches

Latest commits

  • c7cdef62Log: Apollo STOP, workers pausedmre
  • d0c083fbLog: usage stopmre
  • c6d464e5Log: Apollo GO backlog, AP56 and BS1 startedmre
  • 1eb6f1a1Missions AP56, BS1mre
  • 4871f8adLog: AP52 live on day52, browser gate greenmre
  • d9bf2988Merge ap52: day52, tracker#58 server argument, #51 modal close rule, #56 keyed season rowsmre
  • c4a60ef2Log: RT52 retest passed, AP52 startedmre
  • 83760a55Browser gate: search results belong to the address form of the typed text (tracker#52 navigate replace)mre
  • 6e951d91AP52: show-page rows are keyed records; closing a season is one upsert and removes (tracker#56, hybriel#331)mre
  • 3bb4ccddAP52: modal close button refers to its nested rule with Style.buttonModalX (tracker#51, hybriel#333)mre
  • ba16933fAP52: login callback and title route are static handlers taking the server as third argument (tracker#58, hybriel#332)mre
  • 85153900AP52: re-vendor Hybriel set day52 (source 77cfca31, bin 0a8ed496)mre
  • 7c051eddLog: hybriel#338 answermre
  • d049b8b8Log: HM50 live, #52 donemre
  • 6d05fa37Log: HM50 Part A mergedmre
  • 1c7dab74HM50: the shell reads the framework's online state, netProbe removed (tracker#55)mre
  • e8b91697HM50: search address follows the text via navigate(path, replace = true) (tracker#52)mre
  • 6fe1896cHM50: re-vendor Hybriel set day50 (source 0ae38232, bin d3ef9d16)mre
  • 2f391aa9Log: HM50 startedmre
  • 4b59c03dHM50 mission: doc pathmre