f26ac15712
$10 one-time DraftPosition purchases (sponsor 25%, L2-5 5%, 10% Best Coach pot, 45% company) with keeper-signed hub-line vouchers; pure draft engine with a mocked clock; no contact data anywhere; Telegram to an outbox unless TG_LIVE=1. Unit 60/60, smoke 156/156 (Playwright 1280/390). Not deployed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
419 lines
45 KiB
JavaScript
419 lines
45 KiB
JavaScript
// 5xYourTeam local smoke test. Boots the app in prototype mode (no DOCSTORE_URL: files in a throwaway data dir under qa/out) with
|
|
// the STUB holding tank and a test clock, against local stand-ins, then checks: copy rules, pages, the promo kit, sign-in (wallet +
|
|
// network), position orders (line voucher signed by the keeper, already-bound line, hub down), purchases recorded from the chain
|
|
// (ledger split: sponsor 25%, levels 5%, pot 10%, company; passed over; Telegram card once; hub report), instant picks, a live
|
|
// draft (on the clock, manual pick, auto-picks, queue), coaching messages (no contact data anywhere), milestones -> cards, Best
|
|
// Coach + Rookie, picks returning to the pool, the release hold, the Draft Day card, old links, admin, a restart, and Playwright
|
|
// renders at 1280 and 390 with screenshots in qa/out.
|
|
// Nothing leaves this machine: hub, chain RPC and Telegram are local stand-ins. No real wallet, no money, nobody adopted.
|
|
// node qa/smoke.mjs SKIP_UI=1 node qa/smoke.mjs (HTTP only) UI_FONTS=1 (let Google Fonts load)
|
|
import { spawn, spawnSync } from 'node:child_process';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import crypto from 'node:crypto';
|
|
import http from 'node:http';
|
|
import { createRequire } from 'node:module';
|
|
import { fileURLToPath } from 'node:url';
|
|
const require = createRequire(import.meta.url);
|
|
const { ethers } = require('ethers');
|
|
|
|
const APP = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
const OUT = path.join(APP, 'qa', 'out'); fs.mkdirSync(OUT, { recursive: true });
|
|
const DATA = path.join(OUT, 'data-' + Date.now()); fs.mkdirSync(DATA, { recursive: true });
|
|
const PW = process.env.PLAYWRIGHT || 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright';
|
|
const PORT = Number(process.env.SMOKE_APP_PORT || 3561), BASE = 'http://127.0.0.1:' + PORT;
|
|
const ADMIN = 'smoke-admin-token', SSO_SECRET = crypto.randomBytes(32).toString('hex'), HUB_SECRET = 'h'.repeat(40);
|
|
const KEEPER_PK = '0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d'; // anvil's public test key #1
|
|
const KEEPER = new ethers.Wallet(KEEPER_PK).address;
|
|
const SHOP = '0x00000000000000000000000000000000005A5A5A';
|
|
const PRIZE = '0x000000000000000000000000000000000000bead';
|
|
const TANGEM = '0x7627Fc78876948AC9d95C1C9eB061E7D6d647b70';
|
|
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
|
let pass = 0, fail = 0; let srv = null;
|
|
const ok = (cond, what, extra) => { if (cond) { pass++; console.log(' ok ' + what); } else { fail++; console.log(' FAIL ' + what + (extra !== undefined ? ' -> ' + JSON.stringify(extra, (k, v) => typeof v === 'bigint' ? v.toString() : v).slice(0, 600) : '')); } };
|
|
const listen = (port, fn) => http.createServer(async (q, r) => { let b = ''; for await (const c of q) b += c; try { await fn(q, r, b); } catch (e) { r.statusCode = 500; r.end(String(e.message)); } }).listen(port, '127.0.0.1').unref();
|
|
const H = 3600000, D = 86400000;
|
|
const POOL = JSON.parse(fs.readFileSync(path.join(APP, 'qa', 'fixtures', 'pool.json'), 'utf8')).people;
|
|
const pid = name => POOL.find(p => p.username === name).id;
|
|
|
|
// ---- stand-in network hub (signed as fivex) ----
|
|
const HUB = { people: new Map(), down: false, badSig: 0, resolves: 0, got: [] };
|
|
function person(username, wallet, sponsorId, id) { id = id || 'h_' + crypto.createHash('sha1').update(username).digest('hex').slice(0, 16); HUB.people.set(id, { id, username, wallet: wallet ? wallet.toLowerCase() : null, sponsorId: sponsorId || null }); return id; }
|
|
const hubView = p => { if (!p) return null; const sp = p.sponsorId && HUB.people.get(p.sponsorId); return { id: p.id, username: p.username, wallet: p.wallet, blocked: false, sponsor: sp ? { id: sp.id, username: sp.username } : null }; };
|
|
const HUB_PORT = PORT + 1;
|
|
listen(HUB_PORT, async (q, r, b) => {
|
|
r.setHeader('Content-Type', 'application/json');
|
|
if (q.method === 'GET' && q.url === '/v1/network-sites') return r.end('[]');
|
|
if (HUB.down) { r.statusCode = 503; return r.end('{"error":"down"}'); }
|
|
const want = crypto.createHmac('sha256', HUB_SECRET).update(q.headers['x-hub-ts'] + '\n' + b).digest('hex');
|
|
if (q.headers['x-hub-sig'] !== want || q.headers['x-hub-site'] !== 'fivex') { HUB.badSig++; r.statusCode = 401; return r.end('{}'); }
|
|
const j = JSON.parse(b || '{}');
|
|
if (q.url === '/v1/resolve') {
|
|
HUB.resolves++; const all = [...HUB.people.values()]; let p = null;
|
|
if (j.id) p = HUB.people.get(j.id); else if (j.wallet) p = all.find(x => x.wallet === String(j.wallet).toLowerCase());
|
|
else if (j.ref) { const ref = String(j.ref).toLowerCase(); p = all.find(x => x.wallet === ref || x.username.toLowerCase() === ref); }
|
|
return r.end(JSON.stringify({ person: hubView(p) }));
|
|
}
|
|
HUB.got.push({ route: q.url, body: j }); r.end('{"ok":true}');
|
|
});
|
|
// ---- stand-in Polygon JSON-RPC (DraftPosition): quoteWei at POL $0.25 ($10 = 40 POL), sponsorOf, contract facts, logs ----
|
|
const IFACE = new ethers.Interface(['event Purchase(uint256 indexed orderId, address indexed buyer, uint256 qty, uint256 ref, uint256 usdCents, uint256 weiPaid, uint256 levelsPaid, uint256 prizePaid, uint256 companyPaid)',
|
|
'event Paid(uint256 indexed orderId, address indexed to, uint256 amount, uint8 level, uint8 depth)', 'event PassedOver(uint256 indexed orderId, address indexed who, uint8 depth)',
|
|
'event SponsorBound(address indexed member, address indexed sponsor)',
|
|
'function quoteWei(uint256 qty) view returns (uint256)', 'function sponsorOf(address) view returns (address)',
|
|
'function buy(uint256 qty, uint256 ref, address[] line, uint256 deadline, bytes sig) payable returns (uint256)',
|
|
'function owner() view returns (address)', 'function company() view returns (address)', 'function prizeWallet() view returns (address)', 'function keeper() view returns (address)', 'function paused() view returns (bool)',
|
|
'function totalOwed() view returns (uint256)', 'function orderCount() view returns (uint256)', 'function priceCents() view returns (uint256)']);
|
|
const CHAIN = { head: 1, logs: [], receipts: {}, bound: new Map(), replayAll: false, down: false, times: {} };
|
|
const CHAIN_PORT = PORT + 2;
|
|
listen(CHAIN_PORT, async (q, r, b) => {
|
|
const j = JSON.parse(b || '{}'); let result = null; r.setHeader('Content-Type', 'application/json');
|
|
if (CHAIN.down) return r.end(JSON.stringify({ jsonrpc: '2.0', id: j.id, error: { code: -1, message: 'down' } }));
|
|
if (j.method === 'eth_blockNumber') result = '0x' + CHAIN.head.toString(16);
|
|
if (j.method === 'eth_call') {
|
|
const tx = IFACE.parseTransaction({ data: j.params[0].data }); const enc = (fn, v) => IFACE.encodeFunctionResult(fn, v);
|
|
if (tx.name === 'quoteWei') result = enc('quoteWei', [1000n * tx.args[0] * 4n * 10n ** 16n]);
|
|
if (tx.name === 'sponsorOf') result = enc('sponsorOf', [CHAIN.bound.get(tx.args[0].toLowerCase()) || ethers.ZeroAddress]);
|
|
if (tx.name === 'owner' || tx.name === 'company') result = enc(tx.name, [TANGEM]);
|
|
if (tx.name === 'prizeWallet') result = enc('prizeWallet', [PRIZE]);
|
|
if (tx.name === 'keeper') result = enc('keeper', [KEEPER]);
|
|
if (tx.name === 'paused') result = enc('paused', [false]);
|
|
if (tx.name === 'totalOwed') result = enc('totalOwed', [0n]);
|
|
if (tx.name === 'orderCount') result = enc('orderCount', [BigInt(CHAIN.logs.length)]);
|
|
if (tx.name === 'priceCents') result = enc('priceCents', [1000n]);
|
|
}
|
|
if (j.method === 'eth_getBalance') result = '0x0';
|
|
if (j.method === 'eth_getTransactionReceipt') result = CHAIN.receipts[j.params[0]] || null;
|
|
if (j.method === 'eth_maxPriorityFeePerGas') result = '0x' + (40n * 10n ** 9n).toString(16);
|
|
if (j.method === 'eth_getBlockByNumber') { const n = j.params[0] === 'latest' ? CHAIN.head : parseInt(j.params[0], 16); result = { number: '0x' + n.toString(16), timestamp: '0x' + (CHAIN.times[n] || Math.floor(Date.now() / 1000)).toString(16), baseFeePerGas: '0x' + (30n * 10n ** 9n).toString(16) }; }
|
|
if (j.method === 'eth_getLogs') { const f = j.params[0], lo = parseInt(f.fromBlock, 16), hi = parseInt(f.toBlock, 16); result = CHAIN.logs.filter(l => CHAIN.replayAll || (parseInt(l.blockNumber, 16) >= lo && parseInt(l.blockNumber, 16) <= hi)); }
|
|
r.end(JSON.stringify({ jsonrpc: '2.0', id: j.id, result }));
|
|
});
|
|
// a position bought on the stand-in chain: Purchase log + a receipt with SponsorBound / PassedOver / Paid logs, like DraftPosition emits
|
|
let orderId = 0;
|
|
function chainBuy(o) {
|
|
const id = ++orderId; const block = ++CHAIN.head; const tx = '0x' + crypto.randomBytes(32).toString('hex');
|
|
CHAIN.times[block] = o.blockAt || Math.floor(Date.now() / 1000);
|
|
const qty = BigInt(o.qty || 1); const weiPaid = 1000n * qty * 4n * 10n ** 16n; const sp = weiPaid * 2500n / 10000n, lv = weiPaid * 500n / 10000n, pot = weiPaid / 10n;
|
|
const mk = (name, args, li) => { const e = IFACE.encodeEventLog(name, args); return { address: SHOP.toLowerCase(), topics: e.topics, data: e.data, blockNumber: '0x' + block.toString(16), transactionHash: tx, logIndex: '0x' + li.toString(16), removed: false }; };
|
|
const logs = []; let li = 0; let lvl = 0n;
|
|
for (const [m, s] of o.bound || []) { logs.push(mk('SponsorBound', [m, s], li++)); CHAIN.bound.set(m.toLowerCase(), s.toLowerCase()); }
|
|
for (const [w, d] of o.over || []) logs.push(mk('PassedOver', [id, w, d], li++));
|
|
(o.pays || []).forEach(([w, d], i) => { const a = i === 0 ? sp : lv; lvl += a; logs.push(mk('Paid', [id, w, a, i + 1, d], li++)); });
|
|
logs.push(mk('Paid', [id, PRIZE, pot, 6, 0], li++));
|
|
const company = weiPaid - lvl - pot; logs.push(mk('Paid', [id, TANGEM, company, 0, 0], li++));
|
|
const purchase = mk('Purchase', [id, o.buyer, qty, o.ref || 0, 1000n * qty, weiPaid, (o.pays || []).length, pot, company], li++);
|
|
logs.push(purchase); CHAIN.logs.push(purchase);
|
|
CHAIN.receipts[tx] = { status: '0x1', blockNumber: '0x' + block.toString(16), to: SHOP.toLowerCase(), from: o.buyer.toLowerCase(), logs };
|
|
return { tx, id, weiPaid, sp, lv, pot, company };
|
|
}
|
|
// ---- stand-in Telegram Bot API ----
|
|
const TG = []; const TG_PORT = PORT + 3;
|
|
listen(TG_PORT, async (q, r, b) => { TG.push({ method: q.url.split('/').pop(), token: q.url.split('/')[1], body: JSON.parse(b || '{}') }); r.setHeader('Content-Type', 'application/json'); r.end('{"ok":true,"result":{}}'); });
|
|
|
|
const ENV = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, ADMIN_TOKEN: ADMIN, NODE_ENV: 'development', DOCSTORE_URL: '', ALLOW_TEST_CLOCK: '1', TANK_MODE: 'stub',
|
|
NETWORK_SSO_SECRET: SSO_SECRET, IAP_URL: 'https://iap.invalid', LS_URL: 'https://ls.invalid', NETWORK_SITES_HUB: '0', DRAFT_TICK_MS: '200', DRAFT_PICK_SECONDS: '300',
|
|
CONTRACT_ADDRESS: SHOP, PRIZE_WALLET: PRIZE, CHAIN_RPC: 'http://127.0.0.1:' + CHAIN_PORT, KEEPER_KEY: KEEPER_PK, SHOP_START_BLOCK: '1', SHOP_CONFIRMATIONS: '0', SHOP_POLL_MS: '200', EXPLORER: 'https://explorer.invalid',
|
|
HUB_ENABLED: '1', HUB_URL: 'http://127.0.0.1:' + HUB_PORT, HUB_SECRET, HUB_SITE: 'fivex', HUB_TICK_MS: '300', HUB_DOWN_MS: '300', HUB_CACHE_MS: '200',
|
|
TG_LIVE: '1', TG_TOKEN: 'standin-token', TG_CHAT: '-100123', TG_PAY_TOPIC: '632242', TG_API: 'http://127.0.0.1:' + TG_PORT, OWNER_USERNAME: 'coachann' });
|
|
process.on('exit', () => { try { srv && srv.kill(); } catch (e) {} });
|
|
|
|
let nextIp = 10;
|
|
function client(opts = {}) {
|
|
const jar = {}; const ip = opts.ip || ('203.0.113.' + (nextIp++)); const ua = opts.ua || ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) SmokeBrowser/' + ip);
|
|
return { jar, ip, ua,
|
|
async req(p, o = {}) {
|
|
const headers = Object.assign({ 'User-Agent': ua, 'X-Forwarded-For': ip, Cookie: Object.entries(jar).map(([k, v]) => k + '=' + v).join('; ') }, o.headers || {});
|
|
const r = await fetch(BASE + p, { method: o.method || 'GET', headers, body: o.body, redirect: 'manual' });
|
|
for (const c of r.headers.getSetCookie ? r.headers.getSetCookie() : []) { const [kv] = c.split(';'); const i = kv.indexOf('='); jar[kv.slice(0, i)] = kv.slice(i + 1); }
|
|
return r;
|
|
},
|
|
async json(p, body, extra) { const r = await this.req(p, body === undefined ? { headers: extra } : { method: 'POST', headers: Object.assign({ 'Content-Type': 'application/json' }, extra), body: JSON.stringify(body) }); return Object.assign({ _status: r.status }, await r.json().catch(() => ({}))); } };
|
|
}
|
|
const admin = (p, body) => client().json(p, body, { 'x-admin-token': ADMIN });
|
|
async function boot(extraEnv) {
|
|
const log = fs.openSync(path.join(OUT, 'server.log'), 'a');
|
|
srv = spawn(process.execPath, ['server.js'], { cwd: APP, env: Object.assign({}, ENV, extraEnv || {}), stdio: ['ignore', log, log] });
|
|
for (let i = 0; i < 80; i++) { try { const r = await fetch(BASE + '/health'); if (r.ok) return; } catch (e) {} await sleep(150); }
|
|
throw new Error('server did not start; see qa/out/server.log');
|
|
}
|
|
async function stop() { const p = srv; srv = null; if (!p) return; const done = new Promise(r => p.once('exit', r)); p.kill('SIGINT'); await Promise.race([done, sleep(3000)]); }
|
|
async function walletMember(o = {}) {
|
|
const w = o.wallet || ethers.Wallet.createRandom(); const c = client(); const a = w.address.toLowerCase();
|
|
if (o.hub) c.hubId = person(o.hub.username, a, o.hub.sponsorId, o.hub.id);
|
|
const ch = await c.json('/api/auth/challenge', { address: w.address });
|
|
const v = await c.json('/api/auth/verify', { address: w.address, signature: await w.signMessage(ch.message) });
|
|
c.address = a; c.wallet = w; c.ok = v.ok === true && !!c.jar['fx.sid'];
|
|
return c;
|
|
}
|
|
const until = async (fn, ms) => { const end = Date.now() + (ms || 8000); let v; while (Date.now() < end) { v = await fn(); if (v) return v; await sleep(150); } return v; };
|
|
const ctToMs = (day, hour) => { const [y, m, d] = day.split('-').map(Number); for (const off of [6, 5]) { const t = Date.UTC(y, m - 1, d, hour + off); const h = Number(new Date(t).toLocaleString('en-US', { timeZone: 'America/Chicago', hour: 'numeric', hour12: false })); if (h % 24 === hour) return t; } return Date.UTC(y, m - 1, d, hour + 6); };
|
|
const EMAIL_RE = /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/;
|
|
|
|
async function main() {
|
|
if (await fetch(BASE).then(() => true, () => false)) throw new Error('port ' + PORT + ' is already in use; set SMOKE_APP_PORT');
|
|
console.log('data dir', DATA);
|
|
|
|
console.log('1. copy rules');
|
|
const pub = path.join(APP, 'public');
|
|
const files = fs.readdirSync(pub).filter(f => f.endsWith('.html')).map(f => path.join(pub, f)).concat(fs.readdirSync(path.join(pub, 'assets')).filter(f => /\.(js|css)$/.test(f) && f !== 'wallet.js').map(f => path.join(pub, 'assets', f)));
|
|
const texts = files.map(f => [path.basename(f), fs.readFileSync(f, 'utf8')]).concat(['promokit.js', 'proof.js', 'server.js', 'draft.js', 'league.js', 'tools/pages.mjs', 'tools/art.mjs'].map(f => [f, fs.readFileSync(path.join(APP, f), 'utf8')]));
|
|
ok(texts.every(([, t]) => !/[\u2014\u2013]/.test(t)), 'no em or en dashes in any page, script or copy source', texts.filter(([, t]) => /[\u2014\u2013]/.test(t)).map(x => x[0]));
|
|
const html = texts.filter(([n]) => n.endsWith('.html')).map(x => x[1]).join('\n');
|
|
ok(!/metamask/i.test(html), 'pages never name MetaMask');
|
|
ok(/SafePal or any other crypto wallet/.test(html), 'wallet copy: "SafePal or any other crypto wallet"');
|
|
ok(!/passive income|guaranteed (income|returns|profit)|earn (cash|money)|make money|get rich|up to \$?\d+ (a|per)|maximum (you|earn)/i.test(html), 'no income promises and no earnings caps in page copy');
|
|
ok(/never a subscription/i.test(html) && /A position buys a draft spot and coaching tools, not income\. Nothing is promised\./.test(html), 'position copy: one-time, never a subscription; "not income. Nothing is promised."');
|
|
ok(/TrustClickz/.test(html) && /615 Green Valley Drive, Moody, AL 35004/.test(html), 'legal pages name TrustClickz, 615 Green Valley Drive, Moody, AL 35004');
|
|
ok(/never their email or any contact details/.test(html) && /never an email, phone number or any other contact details/i.test(html), 'copy: coaches get the right to sponsor and help, never contact data');
|
|
|
|
console.log('2. boot (prototype mode, stub tank, test clock)');
|
|
// the test clock starts on Sunday 2026-11-15 noon Central: last Monday's draft (11-09) is long past and skipped, never run late
|
|
const SUN = ctToMs('2026-11-15', 12), MON = ctToMs('2026-11-16', 19);
|
|
await boot();
|
|
let r0 = await admin('/api/admin/clock', { now: SUN }); ok(r0.ok, 'admin moves the test clock (ALLOW_TEST_CLOCK=1, never in production)', r0);
|
|
await sleep(500);
|
|
const cfg = await (await fetch(BASE + '/api/config')).json();
|
|
ok(cfg.position.usd === 10 && cfg.position.picksOnBuy === 5 && cfg.split.sponsorPct === 25 && cfg.split.levelPct === 5 && cfg.split.potPct === 10 && cfg.split.companyPct === 45 && cfg.tank === 'stub', 'config: $10 position, 5 picks, split 25/5x4/10/45, stub tank', cfg);
|
|
ok(cfg.shop.live === true && cfg.draft.dow === 1 && cfg.draft.hour === 19 && cfg.draft.rounds === 5 && cfg.picks.returnDays === 3, 'shop live (stand-in); draft Monday 7 PM Central, 5 rounds; picks return after 3 days', cfg.draft);
|
|
let st = await admin('/api/admin/status');
|
|
ok(st.draft === null || (st.draft && st.draft.made === 0), 'the app came up after last Monday\'s draft window: that draft is skipped, not run late', st.draft);
|
|
|
|
console.log('3. pages');
|
|
const anon = client();
|
|
for (const p of ['/', '/team', '/cards', '/join', '/ledger', '/contract', '/promote', '/builder', '/terms', '/disclaimer', '/privacy', '/admin', '/robots.txt', '/sitemap.xml', '/art/og-share.png', '/art/icon-192.png', '/assets/fx.css', '/assets/common.js']) { const r = await anon.req(p); ok(r.status === 200, 'GET ' + p + ' 200', r.status); }
|
|
let r = await anon.req('/team'); ok(r.headers.get('x-frame-options') === 'DENY', '/team is never framed');
|
|
r = await anon.req('/nobody-at-all'); ok(r.status === 404 && /Back to the draft board/.test(await r.text()), 'an unknown coach name: 404');
|
|
r = await anon.req('/api/my'); ok(r.status === 401, '/api/my needs sign-in');
|
|
let b = await anon.json('/api/board');
|
|
ok(b.poolSize === 29 && b.pool.length === 24 && b.pool.every(p => p.gameWei === undefined && p.surfWei === undefined), 'the pool (stub tank: 29 draftable of 35); visitors see scouting facts but no earnings', { size: b.poolSize, keys: Object.keys(b.pool[0]) });
|
|
ok(!b.pool.some(p => /lockedlarry|hasasponsor|xx_spam_xx|temp_mail_9|brandnew|twiceadopted/.test(p.username)), 'never locked, sponsored, spam, throwaway, inside the grace or adopted twice', b.pool.map(p => p.username));
|
|
ok(!EMAIL_RE.test(JSON.stringify(b)), 'no email address anywhere in the board data');
|
|
|
|
console.log('4. promo kit');
|
|
{ const kr = await anon.req('/api/promo-kit?u=coachann'); const k = await kr.json();
|
|
ok(kr.status === 200 && kr.headers.get('access-control-allow-origin') === '*', 'GET /api/promo-kit 200 with CORS open');
|
|
ok(k.links[0].url === 'https://5xyourteam.com/coachann' && k.links.slice(1).every(l => l.url.endsWith('?ref=coachann')), 'kit links: the coach page + ?ref=', k.links.map(l => l.url));
|
|
ok(k.links.every(l => /^https:\/\/linkspin\.app\/r\/nw5x\?src=fivex&s1=coachann/.test(l.tracked)), 'every link has a LinkSpin-tracked twin (nw5x, source fivex)', k.links.map(l => l.tracked));
|
|
const words = JSON.stringify([k.lines, k.headlines, k.email, k.posts, k.note, k.tagline]);
|
|
ok(!/[\u2014\u2013]/.test(words) && !/passive income|guaranteed (income|returns|profit)|make money|metamask/i.test(words) && /\$10 one-time position gives you 5 picks right away/.test(words) && /SafePal or any other crypto wallet/.test(words) && /never a subscription/.test(words), 'kit copy: no dashes, no income promises, facts from config, SafePal wording, never a subscription');
|
|
ok(k.creatives.length === 21 && new Set(k.creatives.map(c => c.angle)).size === 3, 'kit: 21 creatives in 3 angles', k.creatives.length);
|
|
const bad = k.creatives.filter(c => /\d{2,4}x\d{2,4}|banner|[-_/]ads?[-_./]/i.test(c.url.replace('https://5xyourteam.com', ''))); ok(!bad.length, 'kit: creative paths are ad-blocker neutral', bad.map(c => c.url));
|
|
let dimOk = true; const dimBad = [];
|
|
for (const c of k.creatives) { const rr = await anon.req(new URL(c.url).pathname); const buf = Buffer.from(await rr.arrayBuffer()); const w = buf.readUInt32BE(16), h = buf.readUInt32BE(20); if (rr.status !== 200 || w !== c.w || h !== c.h) { dimOk = false; dimBad.push(c.key + ' ' + w + 'x' + h); } }
|
|
ok(dimOk, 'kit: every creative is a PNG at its exact size', dimBad);
|
|
for (const p of ['/art/proof/fx-proof-navy.png', '/art/proof/fx-proof-gold.png', '/art/proof/fx-proof-field.png']) { const pr = await anon.req(p); ok(pr.status === 200 && pr.headers.get('content-type') === 'image/png', 'Telegram proof card ' + p); } }
|
|
|
|
console.log('5. sign-in');
|
|
// hub line above the coaches: top <- l2 (NO position) <- l1 <- coachann ; coachbob and coachcy are under coachann
|
|
const wTop = ethers.Wallet.createRandom(), wL2 = ethers.Wallet.createRandom(), wL1 = ethers.Wallet.createRandom();
|
|
const idTop = person('topcoach', wTop.address), idL2 = person('lineup2', wL2.address, idTop), idL1 = person('lineup1', wL1.address, idL2);
|
|
const A = await walletMember({ hub: { username: 'coachann', sponsorId: idL1 } });
|
|
let me = await A.json('/api/me'); ok(A.ok && me.username === 'coachann' && me.onNetwork && !me.coach, 'a wallet the hub knows: signed in, network username, not a coach yet', me);
|
|
const Bc = await walletMember({ hub: { username: 'coachbob', sponsorId: A.hubId } });
|
|
const Cc = await walletMember({ hub: { username: 'coachcy', sponsorId: A.hubId } });
|
|
const bad = client(); const x0 = ethers.Wallet.createRandom(), x1 = ethers.Wallet.createRandom();
|
|
const ch0 = await bad.json('/api/auth/challenge', { address: x0.address }); const v0 = await bad.json('/api/auth/verify', { address: x0.address, signature: await x1.signMessage(ch0.message) });
|
|
ok(v0._status === 400 && !bad.jar['fx.sid'], 'a signature from another wallet is refused');
|
|
const L = client(); r = await L.req('/sso/start?mode=go&via=iap&to=%2Fteam'); const loc = r.headers.get('location') || '';
|
|
ok(r.status === 302 && loc.startsWith('https://iap.invalid/sso/check?st=') && loc.includes('&r=fivex'), 'network sign-in hops to InstantAdPay with r=fivex', loc);
|
|
const nsso = require(path.join(APP, 'networksso.js')); process.env.NETWORK_SSO_SECRET = SSO_SECRET;
|
|
const wPick = ethers.Wallet.createRandom(); person('gamerdad', wPick.address, null, pid('gamerdad')); // a pool person who signs in later (their hub id = the fixture id)
|
|
const tok = nsso.mint({ iss: 'iap', aud: 'fivex', email: 'gamerdad@example.org', wallet: wPick.address.toLowerCase(), name: 'gamerdad', st: new URL(loc).searchParams.get('st'), to: '/team' });
|
|
r = await L.req('/sso/in?t=' + encodeURIComponent(tok));
|
|
ok(r.status === 302 && r.headers.get('location') === '/team' && !!L.jar['fx.sid'], 'the network token signs a member in', { s: r.status, l: r.headers.get('location') });
|
|
const PICK = L;
|
|
ok(HUB.resolves > 0 && HUB.badSig === 0, 'hub lookups are signed as fivex with HUB_SECRET', HUB.badSig);
|
|
ok(!fs.readdirSync(DATA).some(f => /\.json$/.test(f) && fs.readFileSync(path.join(DATA, f), 'utf8').includes('gamerdad@example.org')), 'the sign-in email is never stored');
|
|
|
|
console.log('6. a position order (line voucher)');
|
|
let q = await A.json('/api/quote?qty=1'); ok(q.usd === 10 && q.picks === 5 && BigInt(q.wei) === 40n * 10n ** 18n, 'quote: $10 at $0.25 = 40 POL (from the contract)', q);
|
|
q = await A.json('/api/quote?qty=11'); ok(q._status === 400, '11 positions refused (1 to 10)');
|
|
let od = await A.json('/api/my/order', { qty: 1 });
|
|
const call = IFACE.parseTransaction({ data: od.data, value: od.value });
|
|
const line = call.args[2].map(a => a.toLowerCase());
|
|
ok(od._status === 200 && call.name === 'buy' && Number(call.args[0]) === 1 && BigInt(call.args[1]) > 0n, 'order = buy(qty 1, ref = a short hash of the hub id)', od);
|
|
ok(JSON.stringify(line) === JSON.stringify([wL1, wL2, wTop].map(w => w.address.toLowerCase())), 'the voucher line = the hub line\'s wallets nearest first', line);
|
|
const rec = ethers.verifyTypedData({ name: 'DraftPosition', version: '1', chainId: 137, verifyingContract: ethers.getAddress(SHOP.toLowerCase()) }, { Voucher: [{ name: 'buyer', type: 'address' }, { name: 'line', type: 'address[]' }, { name: 'deadline', type: 'uint256' }] },
|
|
{ buyer: ethers.getAddress(A.address), line: call.args[2], deadline: call.args[3] }, call.args[4]);
|
|
ok(rec === KEEPER, 'the voucher is signed by the keeper (EIP-712 DraftPosition v1)', rec);
|
|
ok(BigInt(od.value) === 40n * 10n ** 18n * 101n / 100n, 'value = quote + 1% (the contract refunds the excess in the same tx)', od.value);
|
|
CHAIN.bound.set(Bc.address, A.address);
|
|
od = await Bc.json('/api/my/order', { qty: 1 }); const c2 = IFACE.parseTransaction({ data: od.data, value: od.value });
|
|
ok(od.why === 'bound' && c2.args[2].length === 0 && c2.args[4] === '0x', 'a line already bound on chain: no voucher (the chain\'s binding wins)', od.why);
|
|
CHAIN.bound.delete(Bc.address); HUB.down = true; await sleep(350);
|
|
od = await Cc.json('/api/my/order', { qty: 1 }); ok(od._status === 503 && /sponsor line/.test(od.error), 'hub unreachable: the order waits (a line is never signed partial)', od);
|
|
HUB.down = false; await sleep(350);
|
|
|
|
console.log('7. positions recorded from the chain');
|
|
// coachann buys first (line bound, lineup1 paid 25% as sponsor; lineup2 passed over; topcoach 5%), then coachbob (2 positions) and coachcy
|
|
const tA = Math.floor(Date.now() / 1000) - 1800; // real block times (the Telegram card skips anything older than 2 hours)
|
|
const bA = chainBuy({ buyer: A.wallet.address, blockAt: tA, bound: [[A.wallet.address, wL1.address], [wL1.address, wL2.address], [wL2.address, wTop.address]], over: [[wL2.address, 2]], pays: [[wL1.address, 1], [wTop.address, 3]] });
|
|
let led = await until(async () => { const l = await anon.json('/api/ledger'); return l.items && l.items.length && l.items[0].pays.some(p => p.to) ? l : null; });
|
|
const it = led.items[0];
|
|
ok(led.items.length === 1 && it.buyerName === 'coachann' && it.usdCents === 1000, 'the ledger shows the position', it);
|
|
const pays = Object.fromEntries(it.pays.map(p => [p.label, p]));
|
|
ok(pays.sponsor.wei === bA.sp.toString() && pays.sponsor.wei === (10n ** 19n).toString() && pays['level 2'].wei === (2n * 10n ** 18n).toString() && pays['level 2'].depth === 3 && pays.pot.wei === (4n * 10n ** 18n).toString() && pays.company.wei === (24n * 10n ** 18n).toString(),
|
|
'split from the receipt: sponsor 25% = 10 POL, level 2 5% = 2 POL (place 3), pot 10% = 4 POL, company 24 POL (45% + the unfilled levels)', it.pays);
|
|
ok(it.passedOver.length === 1 && it.passedOver[0].depth === 2, 'passed over: place 2 (no position)', it.passedOver);
|
|
for (let i = 0; i < 30 && !TG.length; i++) await sleep(150);
|
|
const cap = (TG[0] && TG[0].body.caption) || '';
|
|
ok(TG.length === 1 && TG[0].method === 'sendPhoto' && TG[0].body.message_thread_id === 632242 && /\/art\/proof\/fx-proof-[a-z]+\.png$/.test(TG[0].body.photo), 'Telegram: one photo card in the payments topic', TG.map(t => t.method));
|
|
ok(/@coachann joined The Draft: a position · \$10\.00 \(40\.0000 POL\)/.test(cap) && /Sponsor 25%: 10\.0000 POL → /.test(cap) && /Level 2 5%: 2\.0000 POL → .*\(place 3 in the line\)/.test(cap) && /Best Coach pot 10%: 4\.0000 POL/.test(cap) && /5xYourTeam: 24\.0000 POL/.test(cap) && /passed over/.test(cap) && /explorer\.invalid\/tx\/0x[0-9a-f]{64}/.test(cap) && !/[\u2014\u2013]/.test(cap), 'sale card: coach, every share with POL and place, pot, company, passed over, verify link, no dashes', cap);
|
|
chainBuy({ buyer: Bc.wallet.address, qty: 2, blockAt: tA + 600, pays: [[A.wallet.address, 1]] });
|
|
chainBuy({ buyer: Cc.wallet.address, blockAt: tA + 1200, pays: [[A.wallet.address, 1]] });
|
|
await until(async () => (await anon.json('/api/ledger')).items.length === 3);
|
|
me = await A.json('/api/me'); let my = await A.json('/api/my');
|
|
ok(me.coach && my.positions === 1 && my.credits === 5, 'coachann is a coach with 5 instant picks', { coach: me.coach, credits: my.credits });
|
|
my = await Bc.json('/api/my'); ok(my.positions === 2 && my.credits === 10, '2 positions = 10 instant picks', my.credits);
|
|
for (let i = 0; i < 30 && !HUB.got.length; i++) await sleep(150);
|
|
ok(HUB.got.some(g => g.route === '/v1/contract-bind' && g.body.contract === 'fivex' && g.body.wallet === A.address && g.body.sponsorRef === wL1.address.toLowerCase()), 'hub report: contract-bind for the coach with their direct sponsor', HUB.got.slice(0, 2));
|
|
CHAIN.replayAll = true; await sleep(800); CHAIN.replayAll = false;
|
|
led = await anon.json('/api/ledger'); ok(led.items.length === 3 && TG.length === 3, 'a flaky RPC re-sending old logs: no second record, no second Telegram post');
|
|
ok(led.totals.potWei === (16n * 10n ** 18n).toString(), 'ledger total to the Best Coach pot: 10% of 4 positions = 16 POL', led.totals);
|
|
b = await A.json('/api/board'); ok(b.pot.wei === (16n * 10n ** 18n).toString() && b.me.coach && b.pool[0].gameWei !== undefined, 'the board: this week\'s pot; coaches see earnings on scouting cards', b.pot);
|
|
|
|
console.log('8. instant picks');
|
|
const p1 = b.pool[0].id;
|
|
let ip = await A.json('/api/my/instant', { person: p1 }); ok(ip.ok && ip.credits === 4, 'an instant pick from the pool (5 -> 4 credits)', ip);
|
|
ip = await Bc.json('/api/my/instant', { person: p1 }); ok(/no longer available/.test(ip.error), 'the same player cannot be taken twice', ip);
|
|
ip = await PICK.json('/api/my/instant', { person: b.pool[1].id }); ok(ip._status === 403, 'no position: no instant pick', ip);
|
|
ip = await A.json('/api/my/instant', { person: pid('lockedlarry') }); ok(/no longer available/.test(ip.error), 'someone locked on a network contract can never be picked', ip);
|
|
const gd = pid('gamerdad');
|
|
ip = await A.json('/api/my/instant', { person: gd }); ok(ip.ok, 'coachann picks @gamerdad (who will sign in as a pick)', ip);
|
|
my = await A.json('/api/my');
|
|
ok(my.picks.length === 2 && my.picks.every(p => p.status === 'open' && p.kind === 'instant' && p.daysLeft === 3) && my.help.length === 2, 'My Team: 2 open instant picks with 3 days to start, both on the who-to-help list', my.picks.map(p => [p.username, p.daysLeft]));
|
|
ok(!EMAIL_RE.test(JSON.stringify(my)), 'no email address anywhere in My Team data');
|
|
|
|
console.log('9. coaching messages (through the site only)');
|
|
const gpk = my.picks.find(p => p.person === gd);
|
|
let m = await A.json('/api/my/message', { pick: gpk.id, text: 'Welcome! I am your coach <b>here</b>.' }); ok(m.ok, 'the coach writes to their pick');
|
|
m = await Bc.json('/api/my/message', { pick: gpk.id, text: 'hi' }); ok(m._status === 403, 'another coach cannot write to someone else\'s pick', m);
|
|
me = await PICK.json('/api/my'); ok(me.myCoach && me.myCoach.coach === 'coachann' && me.myCoach.messages.length === 1 && me.myCoach.messages[0].text === 'Welcome! I am your coach here.', 'the pick sees their coach and the message (markup stripped)', me.myCoach);
|
|
m = await PICK.json('/api/my/message', { pick: gpk.id, text: 'Thanks coach, how do I link a wallet?' }); ok(m.ok, 'the pick replies through the site');
|
|
let th = await A.json('/api/my/messages?pick=' + gpk.id); ok(th.items.length === 2 && th.items[1].mine === false && th.with === 'gamerdad', 'the coach sees the thread', th);
|
|
ok(!EMAIL_RE.test(JSON.stringify(me)) && !EMAIL_RE.test(JSON.stringify(th)), 'no contact data in the pick or coach views');
|
|
|
|
console.log('10. the live draft (test clock: Monday 7 PM Central)');
|
|
await A.json('/api/my/queue', { ids: [] });
|
|
const bq = (await Cc.json('/api/board')).pool; const cyWant = bq[bq.length - 1].id; // the lowest scouting score: nobody else's auto-pick
|
|
await Cc.json('/api/my/queue', { ids: [cyWant] });
|
|
await admin('/api/admin/clock', { now: MON - 2000 }); await A.json('/api/presence', {}); await sleep(2600);
|
|
b = await A.json('/api/board');
|
|
ok(b.draft && b.draft.status === 'live' && b.draft.onClock && b.draft.onClock.me && b.draft.onClock.slot === '1.1' && b.draft.coaches === 3, 'the draft starts at 7 PM Central: coachann (earliest position, no starts last week) is on the clock at 1.1', b.draft && b.draft.onClock);
|
|
ip = await Bc.json('/api/my/instant', { person: b.pool[0].id }); ok(/draft is live/.test(ip.error), 'no instant picks while the draft is live', ip);
|
|
let dp = await PICK.json('/api/draft/pick', { person: b.pool[0].id }); ok(/not on the clock/.test(dp.error), 'someone who is not on the clock cannot pick', dp);
|
|
const mine1 = b.pool[2].id; dp = await A.json('/api/draft/pick', { person: mine1 }); ok(dp.ok, 'coachann drafts by hand', dp);
|
|
b = await until(async () => { const x = await A.json('/api/board'); return x.draft.made >= 3 ? x : null; });
|
|
ok(b.draft.made === 3 && b.draft.onClock.slot === '2.1' && b.draft.onClock.me, 'coachbob and coachcy are away: auto-picked at once; round 2 puts coachann back on the clock', b.draft);
|
|
const cyRow = (await A.json('/api/board')).draft.rows.find(x => x.coach === 'coachcy');
|
|
ok(cyRow && cyRow.person === (bq.find(p => p.id === cyWant) || {}).username, 'coachcy (away) got the first player on their queue', cyRow);
|
|
await admin('/api/admin/clock', { now: MON + 400 * 1000 }); // past the 300-second clock and the 120-second room window: coachann is away now
|
|
const done = await until(async () => { const x = await A.json('/api/board'); return x.draft.status === 'done' ? x : null; }, 10000);
|
|
ok(done && done.draft.made === 15, 'the clock ran out and coachann was away: everyone auto-picked, 3 coaches x 5 rounds = 15 picks', done && done.draft);
|
|
const tdd = await until(async () => TG.find(t => /Draft Day results/.test(t.body.caption || '')), 5000);
|
|
ok(tdd && /\/art\/draftday\/week-2026-11-16\.png$/.test(tdd.body.photo) && /1\.1<\/b> @coachann takes @/.test(tdd.body.caption) && /15 players drafted · 3 coaches/.test(tdd.body.caption), 'the Draft Day card: results image + the picks, once', tdd && tdd.body);
|
|
const dd = await anon.json('/api/draftday?week=2026-11-16'); ok(dd.rows.length === 15 && dd.players === 15, 'the Draft Day data for the card', dd.players);
|
|
my = await A.json('/api/my'); ok(my.picks.filter(p => p.status === 'open').length === 7 && my.stats.onTeam === 7, 'coachann: 2 instant + 5 drafted = 7 open picks', my.stats);
|
|
|
|
console.log('11. milestones, cards, Best Coach, Rookie of the Week');
|
|
await admin('/api/admin/stub/status', { id: gd, wallet: true }); await admin('/api/admin/tick', {});
|
|
my = await A.json('/api/my'); let g = my.picks.find(p => p.person === gd);
|
|
ok(g.tier === 'starter' && g.steps.find(s => s.key === 'wallet').done && g.steps.find(s => s.next).key === 'payouts', 'a pick links a wallet: Starter, next step payouts', g.steps);
|
|
ok(my.help[0].pickId === g.id || my.help.some(h => h.pickId === g.id && /one step from payouts/.test(h.why)), 'who to help: @gamerdad is one step from payouts', my.help.slice(0, 3));
|
|
await admin('/api/admin/stub/status', { id: gd, payouts: true }); await admin('/api/admin/tick', {});
|
|
const bpk = (await Bc.json('/api/my')).picks.filter(p => p.status === 'open');
|
|
await admin('/api/admin/stub/status', { id: bpk[0].person, purchase: true }); await admin('/api/admin/stub/status', { id: bpk[1].person, wallet: true, payouts: true }); await admin('/api/admin/tick', {});
|
|
my = await A.json('/api/my'); g = my.picks.find(p => p.person === gd);
|
|
ok(g.status === 'done' && g.tier === 'pro', '@gamerdad switched on payouts: started, stays on the team (Pro card)', g);
|
|
b = await A.json('/api/board');
|
|
ok(b.best.length === 2 && b.best[0].coach === 'coachbob' && b.best[0].started === 2 && b.best[1].coach === 'coachann', 'Best Coach standings: coachbob 2 started, coachann 1', b.best);
|
|
ok(b.rookie && b.rookie.tier === 'allstar', 'Rookie of the Week: the pick that climbed highest (All-Star)', b.rookie);
|
|
const cards = await anon.json('/api/coach?u=coachann');
|
|
ok(cards.team.some(c => c.username === 'gamerdad' && c.tierName === 'Pro' && c.milestone === 'Payouts switched on') && !/"(gameWei|surfWei|earned\w*|weiPaid)"/.test(JSON.stringify(cards)), 'public cards: milestones only, never earnings', cards.team.slice(0, 3));
|
|
r = await anon.req('/coachann'); ok(r.status === 200 && /coach\.js/.test(await r.text()), 'GET /coachann serves the coach page');
|
|
const rc = await anon.json('/api/recent'); ok(rc.items.some(x => x.kind === 'level' && x.person === 'gamerdad') && rc.items.some(x => x.kind === 'pick'), 'toasts: picks and level-ups (real events only)', rc.items.slice(0, 4));
|
|
const pot = await admin('/api/admin/pot?week=2026-11-16');
|
|
ok(pot.shares.length === 2 && pot.shares[0].username === 'coachbob' && pot.shares[0].pct === 50, 'admin: the week\'s pot shares by place (rule open for Marty)', pot);
|
|
|
|
console.log('12. picks return to the pool; the release hold');
|
|
let rl = await A.json('/api/my/release', { pick: my.picks.find(p => p.status === 'open').id }); ok(/less than 48 hours/.test(rl.error), 'a pick cannot be released in its first 48 hours', rl);
|
|
await admin('/api/admin/clock', { now: MON + 3 * D + 3600000 }); await admin('/api/admin/tick', {});
|
|
my = await A.json('/api/my');
|
|
ok(my.picks.filter(p => p.status === 'open').length === 0 && my.picks.filter(p => p.status === 'returned').length >= 5 && my.picks.find(p => p.person === gd).status === 'done', 'after 3 days the unconverted picks go back to the pool; the started one stays', my.picks.map(p => p.status));
|
|
b = await anon.json('/api/board'); ok(b.poolSize > 15, 'they are draftable again', b.poolSize);
|
|
th = await A.json('/api/my/message', { pick: my.picks.find(p => p.status === 'returned').id, text: 'still there?' }); ok(/back in the pool/.test(th.error), 'a returned pick\'s thread is closed', th);
|
|
|
|
console.log('13. old site links');
|
|
r = await anon.req('/api/admin/oldrefs', { method: 'POST', headers: { 'x-admin-token': ADMIN }, body: JSON.stringify({ oldrefs: { janie23: 'coachann', 'bad key!': 'x' } }) });
|
|
const or = await r.json(); ok(or.ok && or.total === 1 && or.skipped === 1, 'admin loads the old-username map', or);
|
|
for (const [from, to] of [['/?janie23', '/coachann'], ['/splashpg.php?pid=4&r=janie23', '/coachann'], ['/lcp.php?r=JANIE23', '/coachann'], ['/index.php?r=janie23', '/coachann'], ['/members/login.php', '/team'], ['/?nobodyold', '/'], ['/whatever.php', '/']]) {
|
|
r = await anon.req(from); ok(r.status === 301 && r.headers.get('location') === to, 'old link ' + from + ' -> ' + to, r.headers.get('location')); }
|
|
r = await anon.req('/?ref=coachann'); ok(r.status === 200, '/?ref=<name> is not an old link');
|
|
|
|
console.log('14. admin');
|
|
r = await anon.req('/api/admin/status'); ok(r.status === 401, 'admin needs the token');
|
|
st = await admin('/api/admin/status'); const sj = JSON.stringify(st);
|
|
ok(st.shop.vouchers && st.shop.keeper === KEEPER && !sj.includes(KEEPER_PK.slice(2)) && !sj.includes(HUB_SECRET) && !sj.includes('standin-token') && !sj.includes(SSO_SECRET), 'admin status: keeper address only, no key or secrets', st.shop);
|
|
ok(st.tank.mode === 'stub' && st.tank.adoptionMailsThatWouldSend >= 17, 'stub tank: every pick went through adopt (mails counted, none sent)', st.tank);
|
|
const pp = await admin('/api/admin/pot/paid', { week: '2026-11-16', rank: 1, coach: Bc.address, wei: '8000000000000000000', tx: '0x' + 'ab'.repeat(32) });
|
|
ok(pp.ok && (await anon.json('/api/ledger')).payouts.length === 1, 'a Best Coach payout recorded with its tx shows on the ledger', pp);
|
|
const tpl = await until(async () => TG.find(t => /Best Coach, week of 2026-11-16: #1 @coachbob got 8\.0000 POL/.test(t.body.text || '')), 4000);
|
|
ok(!!tpl, 'one Telegram line per Best Coach payout');
|
|
|
|
console.log('15. restart (Telegram not live: the outbox)');
|
|
await sleep(700); { const sd = JSON.parse(fs.readFileSync(path.join(DATA, 'fivex.json'), 'utf8')).drafts['2026-11-16']; ok(sd && sd.status === 'done', 'the finished draft is saved as done before the restart', sd && sd.status); }
|
|
await stop(); await boot({ TG_LIVE: '' }); await admin('/api/admin/clock', { now: MON + 3 * D + 3700000 }); await sleep(500);
|
|
my = await A.json('/api/my'); ok(my.positions === 1 && my.picks.length === 7 && my.picks.find(p => p.person === gd).tier === 'pro', 'after a restart: positions, picks and milestones are kept');
|
|
const tgBefore = TG.length;
|
|
chainBuy({ buyer: Cc.wallet.address, blockAt: Math.floor(Date.now() / 1000), pays: [[A.wallet.address, 1]] });
|
|
await until(async () => (await anon.json('/api/ledger')).items.length === 4); await sleep(800);
|
|
st = await admin('/api/admin/status');
|
|
ok(TG.length === tgBefore && st.proof.queued === 1 && /outbox/.test(st.proof.telegram) && st.proof.outbox.some(x => /coachcy joined The Draft/.test(x.body.caption || '')), 'with TG_LIVE unset nothing is sent: the sale card waits in the outbox', st.proof);
|
|
|
|
if (!process.env.SKIP_UI && fs.existsSync(PW)) {
|
|
console.log('16. Playwright renders (desktop 1280 + phone 390)');
|
|
// next Monday's draft: coachbob (2 started last week) picks first, then coachann, who is in the room: on the clock
|
|
await admin('/api/admin/clock', { now: ctToMs('2026-11-23', 19) - 2500 }); await A.json('/api/presence', {}); await sleep(3200);
|
|
b = await A.json('/api/board'); ok(b.draft && b.draft.status === 'live' && b.draft.onClock && b.draft.onClock.me && b.draft.made === 1, 'week 2: draft order earned (coachbob first); coachann is on the clock', b.draft && b.draft.onClock);
|
|
const { chromium } = require(PW); const browser = await chromium.launch();
|
|
for (const [label, vp] of [['desktop', { width: 1280, height: 900 }], ['phone', { width: 390, height: 844 }]]) {
|
|
const ctx = await browser.newContext({ viewport: vp, isMobile: label === 'phone', userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/130.0 Safari/537.36 SmokeUI-' + label });
|
|
await ctx.route(/^https:\/\//, rt => (process.env.UI_FONTS && /^https:\/\/fonts\.(googleapis|gstatic)\.com\//.test(rt.request().url())) ? rt.continue() : rt.abort());
|
|
await ctx.addCookies([{ name: 'fx.sid', value: A.jar['fx.sid'], url: BASE }]);
|
|
const errs = []; const pg = await ctx.newPage(); pg.on('pageerror', e => errs.push(e.message));
|
|
for (const [p, sel] of [['/', '#pool .scout'], ['/team', '#focus:not([hidden]) .steps div'], ['/cards', '#mineCards .tc'], ['/join', '#jQty option'], ['/coachann', '#cTeam .tc'], ['/ledger', '#rows tbody tr'], ['/contract', '#facts th'], ['/promote', '#kit .card'], ['/builder', '#bList .kit-row'], ['/terms', '.legal .card'], ['/disclaimer', '.legal .card'], ['/privacy', '.legal .card']]) {
|
|
await pg.goto(BASE + p, { waitUntil: 'domcontentloaded' }); await pg.waitForSelector(sel, { timeout: 8000 }).catch(() => {});
|
|
await sleep(300);
|
|
const found = await pg.$$eval(sel, els => els.length);
|
|
const wide = await pg.evaluate(() => document.documentElement.scrollWidth - window.innerWidth);
|
|
ok(found > 0 && wide <= 1, label + ' ' + p + ': renders (' + sel + ') with no sideways scroll', { found, wide });
|
|
await pg.screenshot({ path: path.join(OUT, label + '-' + (p === '/' ? 'board' : p.slice(1)) + '.png'), fullPage: true });
|
|
}
|
|
await pg.goto(BASE + '/', { waitUntil: 'domcontentloaded' }); await pg.waitForFunction(() => /ON THE CLOCK/.test(document.getElementById('heroKick').textContent), null, { timeout: 8000 }).catch(() => {});
|
|
ok(/YOU'RE ON THE CLOCK/.test(await pg.textContent('#heroKick')) && /Pick 2 of Round 1/.test(await pg.textContent('#heroTitle')) && (await pg.$$eval('[data-draft]', e => e.length)) > 0, label + ': board says YOU\'RE ON THE CLOCK with DRAFT buttons');
|
|
ok((await pg.textContent('footer')).includes('TrustClickz') && /Part of the network/.test(await pg.textContent('footer')) && /5xYourTeam/.test(await pg.textContent('footer .netline')), label + ': footer has the company line and the network line');
|
|
ok(errs.length === 0, label + ': no page errors', errs);
|
|
await ctx.close();
|
|
}
|
|
// a pick's view of /team (their coach and the thread)
|
|
{ const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }); await ctx.route(/^https:\/\//, rt => (process.env.UI_FONTS && /^https:\/\/fonts\.(googleapis|gstatic)\.com\//.test(rt.request().url())) ? rt.continue() : rt.abort());
|
|
await ctx.addCookies([{ name: 'fx.sid', value: PICK.jar['fx.sid'], url: BASE }]); const pg = await ctx.newPage();
|
|
await pg.goto(BASE + '/team', { waitUntil: 'domcontentloaded' }); await pg.waitForSelector('#myCoach:not([hidden]) .msg', { timeout: 8000 }).catch(() => {});
|
|
ok(/@coachann/.test(await pg.textContent('#mcName')) && (await pg.$$eval('#mcThread .msg', e => e.length)) === 2, 'a pick sees their coach and the thread on /team');
|
|
await pg.screenshot({ path: path.join(OUT, 'desktop-team-as-pick.png'), fullPage: true });
|
|
const p2 = await (await browser.newContext({ viewport: { width: 1080, height: 1080 } })).newPage();
|
|
await p2.goto(BASE + '/draftday/2026-11-16', { waitUntil: 'domcontentloaded' }); await p2.waitForSelector('body[data-ready="1"]', { timeout: 8000 }).catch(() => {});
|
|
ok((await p2.$$eval('.dd-r', e => e.length)) === 6 && /15 players drafted/.test(await p2.textContent('#ddStats')), 'the Draft Day card renders from the week\'s results');
|
|
await p2.screenshot({ path: path.join(OUT, 'draftday-2026-11-16.png') });
|
|
await ctx.close(); }
|
|
await browser.close();
|
|
} else console.log('16. (Playwright renders skipped)');
|
|
|
|
await stop();
|
|
console.log('\n' + pass + ' passed, ' + fail + ' failed');
|
|
fs.writeFileSync(path.join(OUT, 'smoke.txt'), new Date().toISOString() + ' ' + pass + ' passed, ' + fail + ' failed\n');
|
|
process.exit(fail ? 1 : 0);
|
|
}
|
|
main().catch(e => { console.error('smoke crashed:', e.stack || e.message); fail++; process.exit(1); });
|