gitoria

tracker

All repositories: gitoria

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

3.7 KB

  1. // tests/realdata-m031.mjs — mission 031 (tracker#32 header + the WorldAPI theme), NOT the gate. Screenshots of real pages against a
  2. // server started by tests/realdata-m028.sh on a COPY of live storage/: every path of REAL_PATHS at 390 and 1280 px, signed out and
  3. // signed in as the creator (cookie from $REAL_SID_FILE), plus the header states on `/` (phone: overlay, search, user/ident dropdown;
  4. // desktop: user dropdown). Prints per shot the header's height, sideways scroll and console problems. Files: $REAL_OUT/<w>-<in|out>-<name>.png
  5. // Env: REAL_PORT, REAL_CHROME, REAL_SID_FILE, REAL_OUT, REAL_PATHS (comma list).
  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 PORT = Number(process.env.REAL_PORT || 8730), BASE = `http://127.0.0.1:${PORT}`;
  10. const SID = readFileSync(process.env.REAL_SID_FILE, 'utf8').trim(), OUT = process.env.REAL_OUT;
  11. const PATHS = (process.env.REAL_PATHS || '/,/series/Star-Trek-Picard,/movies/Star-Trek-First-Contact,/person/Patrick-Stewart,/my/series').split(',');
  12. mkdirSync(OUT, { recursive: true });
  13. const nameOf = (p) => (p === '/' ? 'home' : p.slice(1).replace(/[^A-Za-z0-9-]+/g, '_'));
  14. const browser = await launchBrowser({ debugPortRange: [Number(process.env.REAL_CHROME || 8729), Number(process.env.REAL_CHROME || 8729)] });
  15. try {
  16. for (const who of ['out', 'in']) {
  17. for (const w of [390, 1280]) {
  18. const page = await browser.newPage();
  19. await page.send('Emulation.setDeviceMetricsOverride', { width: w, height: w === 390 ? 844 : 900, deviceScaleFactor: 1, mobile: w === 390 });
  20. if (who === 'in') await page.send('Network.setCookie', { name: 'trackersid', value: SID, url: BASE });
  21. const shot = async (name) => {
  22. await new Promise(r => setTimeout(r, 400));
  23. const info = await page.evaluate(`JSON.stringify({ header: Math.round((document.querySelector('application-header') || document.body).getBoundingClientRect().height), sideways: document.documentElement.scrollWidth > innerWidth })`);
  24. writeFileSync(`${OUT}/${w}-${who}-${name}.png`, Buffer.from((await page.send('Page.captureScreenshot', { format: 'png' })).data, 'base64'));
  25. console.log(`${w} ${who} ${name.padEnd(40)} ${info} problems=${page.problems().length}`);
  26. };
  27. for (const p of PATHS) {
  28. await page.goto(BASE + p, { timeout: 120000 });
  29. await page.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1 && document.readyState === "complete"', { timeout: 120000, label: 'hydrated' });
  30. 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: 15000, label: 'images' }).catch(() => {});
  31. await shot(nameOf(p));
  32. }
  33. // the header's states on the home page (only what the page has: the old header has none of them)
  34. await page.goto(BASE + '/', { timeout: 120000 });
  35. await page.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1', { timeout: 120000 });
  36. for (const [sel, name] of [['button.menu-toggle', 'state-sidebar'], ['button.search-toggle', 'state-search'], ['button.user-toggle', 'state-usermenu'], ['button.ident-toggle', 'state-identmenu']]) {
  37. const there = await page.evaluate(`(() => { const b = document.querySelector(${JSON.stringify(sel)}); return !!b && b.getClientRects().length > 0 && getComputedStyle(b).display !== 'none' })()`);
  38. if (!there) continue;
  39. await page.click(sel);
  40. await shot(name);
  41. await page.evaluate(`document.querySelectorAll(':popover-open').forEach(e => e.hidePopover())`);
  42. }
  43. await page.close();
  44. }
  45. }
  46. } finally { 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