Files
linkspin/qa/walk.mjs
T
martbost 68061284ef QA for the themes: contrast check in both themes, QA_THEME walks, theme-switch assertions
qa/theme-contrast.mjs (bash qa/run.sh theme) loads the public pages and the member area in light and dark with Playwright, samples the main text/background pairs (body and muted text, links, buttons, chips, tags, stage pills, table text, panel headings, fields) with composited ancestor backgrounds and gradient averages, injects one probe per variant so every pair is measured even when a page has no live example, and reports the ratio per pair with pass/fail at 4.5:1 (3:1 for large text). One account per theme, since the account value wins at sign-in. Result today: 2,413 pairs, 0 fails, worst 4.63:1.

qa/walk.mjs honours QA_THEME=light|dark|auto (localStorage set before the first navigation; screenshots carry a -<theme> suffix so both sets survive), asserts the topbar and Profile switch (applies at once, saves to the account, repaints the other control), and screenshots the public home, the member's wall and the join page from the local copy. Requests the page cancels by navigating away (net::ERR_ABORTED) no longer count as failures, and the local-only /api/qr 404 (no qrcode module in a checkout) is ignored for images. Both QA_THEME walks: 0 bugs.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-01 10:57:58 -06:00

205 lines
16 KiB
JavaScript

// InstantAdPay QA harness: site walk.
// node qa/walk.mjs public -> live public pages (no sign-in): errors, failed requests, broken images, dead links, mobile
// node qa/walk.mjs member -> local copy: Control Room sign-in, every rail screen, the /tools panes + sub-tabs, every admin pane, forms
// node qa/walk.mjs all -> both
// Env: LIVE (default https://instantadpay.com), LOCAL (default http://127.0.0.1:8796), OUT (report dir),
// PW (playwright package dir; default D:/Projects/MarketingAgent/qa-tester/node_modules/playwright)
// QA_THEME=light|dark|auto (2026-11-01): set localStorage ls.theme before the first navigation so every pane is walked and
// screenshotted in that theme; screenshots get a -<theme> suffix so both sets survive in qa/out
// Exit code 1 when any [bug] finding remains after noise filtering.
import { pathToFileURL } from 'node:url';
import fs from 'node:fs';
const PW = process.env.PW || 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright';
const { chromium } = (await import(pathToFileURL(PW + '/index.js').href)).default;
const MODE = process.argv[2] || 'all';
const LIVE = process.env.LIVE || 'https://linkspin.app'; // this is LinkSpin's harness: the IAP default was a copy-paste leftover (2026-10-29)
const LOCAL = process.env.LOCAL || 'http://127.0.0.1:8796';
const OUT = process.env.OUT || 'qa/out';
fs.mkdirSync(OUT, { recursive: true });
const THEME = ['light', 'dark', 'auto'].includes(process.env.QA_THEME || '') ? process.env.QA_THEME : '';
const SUF = THEME ? '-' + THEME : '';
const themed = async ctx => { if (THEME) await ctx.addInitScript(t => { try { localStorage.setItem('ls.theme', t); } catch (e) {} }, THEME); return ctx; };
const findings = [];
const note = (sev, where, what) => findings.push({ sev, where, what });
const NOISE = /walletconnect|reown|web3modal|coingecko|fonts\.|\/api\/feed\/live|\/api\/auth\/logout|\/api\/me(\?|$)|\/api\/my\/support/; // /api/me aborts when the shell reloads after sign-in; the support desk is not reachable from a local copy
function watch(page, base) {
const bag = { console: [], failed: [], status: [] };
page.on('pageerror', e => bag.console.push('pageerror: ' + e.message));
page.on('console', m => {
if (m.type() !== 'error') return;
const loc = (m.location() && m.location().url) || '';
if (loc && !loc.startsWith(base)) return; // third-party or framed page, not ours
if (/status of (400|401|404)/.test(m.text()) || /status of 503/.test(m.text()) && /\/api\/my\/support/.test(loc)) return; // expected API answers surface as console noise
bag.console.push(m.text());
});
page.on('requestfailed', r => { const u = r.url(); const err = (r.failure() && r.failure().errorText) || ''; if (err === 'net::ERR_ABORTED') return; /* a request the page cancelled by navigating away (a poll or a save still in flight): never a server failure (2026-11-01) */ if (u.startsWith(base) && !NOISE.test(u)) bag.failed.push(u + ' ' + err); });
page.on('response', r => { const st = r.status(); const u = r.url(); if (st >= 500 && u.startsWith(base) && !(st === 503 && /\/api\/my\/support/.test(u))) bag.status.push(st + ' ' + u); });
return bag;
}
function flush(bag, label) {
for (const c of bag.console) note('bug', label, 'console: ' + c.slice(0, 200));
for (const f of bag.failed) note('bug', label, 'request failed: ' + f.slice(0, 200));
for (const s of bag.status) note('bug', label, 'HTTP ' + s.slice(0, 200));
bag.console.length = bag.failed.length = bag.status.length = 0;
}
async function domChecks(page, label) {
const r = await page.evaluate(() => {
const vis = el => el.offsetParent !== null;
const brokenImgs = [...document.images].filter(i => i.complete && i.naturalWidth === 0 && i.src && vis(i)).map(i => i.src);
const unfilled = [...document.querySelectorAll('body *')].filter(el => el.children.length === 0 && (el.textContent || '').trim() === '…' && vis(el)).length;
const overflow = document.documentElement.scrollWidth > document.documentElement.clientWidth + 2;
return { brokenImgs, unfilled, overflow, title: document.title };
});
const imgs = label.startsWith('LOCAL') ? r.brokenImgs.filter(s => !/\/api\/qr\?/.test(s)) : r.brokenImgs; // the qrcode module is not installed in a local checkout, so /api/qr answers 404 there
if (imgs.length) note('bug', label, 'broken images: ' + imgs.slice(0, 3).join(', '));
if (r.unfilled) note('warn', label, r.unfilled + ' element(s) still showing the loading ellipsis');
if (r.overflow) note('warn', label, 'page scrolls horizontally');
return r;
}
const hide = page => page.evaluate(() => { document.querySelectorAll('.modal-back,.lgate').forEach(m => m.hidden = true); });
const browser = await chromium.launch();
if (MODE === 'public' || MODE === 'all') {
const ctx = await themed(await browser.newContext({ viewport: { width: 1280, height: 900 } }));
const page = await ctx.newPage(); const bag = watch(page, LIVE);
const PUBLIC = ['/', '/ledger', '/contract', '/terms', '/privacy', '/disclaimer', '/wall/martbost', '/join/martbost',
'/join/martbost?v=instant', '/join/martbost?v=adspend', '/join/martbost?v=free', '/join/martbost?v=ledger', '/join/martbost?v=two',
'/traffic-guide', '/refuel', '/conversion-tracking', '/admin', '/my', '/shorts', '/nope-404'];
for (const p of PUBLIC) {
const label = 'LIVE ' + p;
try {
const resp = await page.goto(LIVE + p, { waitUntil: 'domcontentloaded', timeout: 45000 });
await page.waitForTimeout(2500);
const st = resp ? resp.status() : 0;
if (p === '/nope-404') { if (st !== 404) note('warn', label, 'expected 404, got ' + st); }
else if (st >= 400) note('bug', label, 'page HTTP ' + st);
const d = await domChecks(page, label);
const hrefs = await page.evaluate(() => [...new Set([...document.querySelectorAll('a[href]')].map(a => a.href).filter(h => h.startsWith(location.origin) && !h.includes('#') && !h.includes('/api/')))]);
for (const h of hrefs.slice(0, 40)) {
try { const r = await page.request.head(h, { timeout: 15000 }); if (r.status() >= 400) note('bug', label, 'dead link ' + h + ' -> ' + r.status()); }
catch (e) { note('warn', label, 'link check failed ' + h); }
}
flush(bag, label); console.log('ok', label, '|', d.title);
} catch (e) { note('bug', label, 'navigation failed: ' + e.message.slice(0, 160)); flush(bag, label); }
}
const m = await themed(await browser.newContext({ viewport: { width: 390, height: 844 }, isMobile: true }));
const mp = await m.newPage(); const mbag = watch(mp, LIVE);
for (const p of ['/', '/join/martbost?v=instant', '/wall/martbost', '/my']) {
await mp.goto(LIVE + p, { waitUntil: 'domcontentloaded', timeout: 45000 }).catch(e => note('bug', 'LIVE mobile ' + p, e.message));
await mp.waitForTimeout(2000); await domChecks(mp, 'LIVE mobile ' + p); flush(mbag, 'LIVE mobile ' + p);
await mp.screenshot({ path: OUT + '/mobile' + p.replace(/[^a-z0-9]+/gi, '-') + SUF + '.png' }).catch(() => {});
}
await ctx.close(); await m.close();
}
if (MODE === 'member' || MODE === 'all') {
const ctx = await themed(await browser.newContext({ viewport: { width: 1280, height: 950 } }));
const page = await ctx.newPage(); const bag = watch(page, LOCAL);
page.on('dialog', d => d.accept());
const L = 'LOCAL ';
// Control Room sign-in (2026-10-20): the shell opens its own email-code modal on any workspace screen
await page.goto(LOCAL + '/links', { waitUntil: 'networkidle' });
await page.waitForSelector('#siEmail'); await page.fill('#siEmail', 'qa-walk@example.com'); await page.click('#siGo');
await page.waitForSelector('#siCodeRow:not([hidden])', { timeout: 15000 }); await page.click('#siGo');
await page.waitForSelector('#siEmail', { state: 'detached', timeout: 10000 }).catch(() => note('bug', L + 'sign-in', 'sign-in modal did not close'));
flush(bag, L + 'sign-in');
const username = async () => { if (await page.$('#dlg-username')) { await page.fill('#dlg-username', 'qawalker'); await page.click('#dlgOk'); await page.waitForTimeout(1200); } };
// every Control Room screen on the rail
for (const sc of ['links', 'sources', 'pages', 'zones', 'ads', 'credits', 'reports', 'conversions', 'team', 'wallet', 'help']) {
const label = L + '/' + sc;
await page.goto(LOCAL + '/' + sc, { waitUntil: 'networkidle' }); await page.waitForTimeout(800); await username(); await hide(page);
if (await page.$('#siEmail')) note('bug', label, 'asked to sign in again');
const ok = await page.evaluate(() => { const el = document.getElementById('page'); return !!el && el.offsetHeight > 100 && !/could not load/.test((document.getElementById('crSub') || {}).textContent || ''); });
if (!ok && sc === 'help' && !process.env.HELPDESK_URL) note('warn', label, 'support desk not reachable from a local copy (expected)');
else if (!ok) note('bug', label, 'screen did not render (or said could not load)');
await domChecks(page, label); flush(bag, label);
await page.screenshot({ path: OUT + '/cr-' + sc + SUF + '.png' }).catch(() => {});
console.log('ok', label);
}
// the classic panes that live at /tools behind the Control Room tabs
await page.goto(LOCAL + '/tools', { waitUntil: 'load' }); await page.waitForTimeout(2500); // live feed stream: never network-idle await username();
const PANES = ['overview', 'promo', 'training', 'pipeline', 'line', 'profile'];
for (const pn of PANES) {
const label = L + 'tools#' + pn;
await page.click('.bo-menu [data-pane="' + pn + '"]'); await page.waitForTimeout(1200); await hide(page);
const vis = await page.evaluate(id => { const el = document.getElementById('pane-' + id); return el && !el.hidden && el.offsetHeight > 40; }, pn);
if (!vis) note('bug', label, 'pane did not render');
await domChecks(page, label);
const subs = await page.$$('#pane-' + pn + ' .subtabs [data-earn], #pane-' + pn + ' .promo-pills [data-promo]');
for (const s of subs) { try { await s.click(); await page.waitForTimeout(500); } catch (e) {} }
if (subs.length) await domChecks(page, label + ' (sub-tabs)');
flush(bag, label);
await page.screenshot({ path: OUT + '/tools-' + pn + SUF + '.png' }).catch(() => {});
console.log('ok', label, 'subtabs:', subs.length);
}
await page.click('.bo-menu [data-pane="promo"]'); await page.waitForTimeout(800);
if (!(await page.$$('#promoPosts .promo-block')).length) note('bug', L + 'promo', 'no post cards rendered');
const chat = await page.$('#chatMenuBtn'); if (chat) { await chat.click(); await page.waitForTimeout(800); await domChecks(page, L + 'messages'); flush(bag, L + 'messages'); await page.keyboard.press('Escape'); }
// theme switch (2026-11-01): the topbar control and the Profile card both exist, a click flips data-theme at once and saves to the account
{
const label = L + 'theme switch';
await page.evaluate(() => document.querySelectorAll('.chat-drawer,.modal-back,.lgate').forEach(m => m.hidden = true)); // the Messages drawer from the step above sits over the topbar
const seg = await page.$('#crTheme [data-theme="dark"]'); const prof = await page.$('#pane-profile .theme-seg [data-theme="light"]');
if (!seg) note('bug', label, 'no Light/Dark/Auto control in the topbar'); if (!prof) note('bug', label, 'no Light/Dark/Auto control on the Profile pane');
if (seg && prof) {
const saved1 = page.waitForResponse(r => r.url().includes('/api/my/profile'), { timeout: 10000 }).catch(() => null); await seg.click(); await saved1; await page.waitForTimeout(300);
const t1 = await page.evaluate(() => [document.documentElement.getAttribute('data-theme'), localStorage.getItem('ls.theme')]);
if (t1[0] !== 'dark' || t1[1] !== 'dark') note('bug', label, 'Dark did not apply (data-theme=' + t1[0] + ', ls.theme=' + t1[1] + ')');
await page.waitForTimeout(600); const acct = await (await page.request.get(LOCAL + '/api/me')).json();
if (acct.theme !== 'dark') note('bug', label, 'account did not store the theme (got ' + acct.theme + ')');
const onProfile = await page.evaluate(() => { const b = document.querySelector('#pane-profile .theme-seg [data-theme="dark"]'); return b && b.classList.contains('on'); });
if (!onProfile) note('bug', label, 'Profile control did not repaint after a topbar change');
await page.click('.bo-menu [data-pane="profile"]'); await page.waitForTimeout(400); const saved2 = page.waitForResponse(r => r.url().includes('/api/my/profile'), { timeout: 10000 }).catch(() => null); await prof.click(); await saved2; await page.waitForTimeout(300);
const t2 = await page.evaluate(() => document.documentElement.getAttribute('data-theme'));
if (t2 !== 'light') note('bug', label, 'Light from the Profile card did not apply (data-theme=' + t2 + ')');
// restore the walk's theme so the remaining screenshots match the set
await page.evaluate(t => { if (t) window.LSTheme.set(t); else { localStorage.removeItem('ls.theme'); window.LSTheme.apply(); } }, THEME);
if (THEME) await page.evaluate(t => fetch('/api/my/profile', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ theme: t }) }).then(r => r.status), THEME); // awaited: a save still in flight would abort on the next navigation
await page.waitForTimeout(400);
}
flush(bag, label); console.log('ok', label);
}
// public home, the member's wall and a campaign (join) page on the local copy, in this theme
for (const p of ['/', '/wall/qawalker', '/join/qawalker', '/join/qawalker?v=instant']) {
const label = L + p;
await page.goto(LOCAL + p, { waitUntil: 'domcontentloaded' }).catch(e => note('bug', label, 'navigation failed: ' + e.message.slice(0, 120))); await page.waitForTimeout(1500);
await domChecks(page, label); flush(bag, label);
await page.screenshot({ path: OUT + '/public' + p.replace(/[^a-z0-9]+/gi, '-').replace(/-$/, '') + SUF + '.png', fullPage: p === '/' }).catch(() => {});
console.log('ok', label);
}
await page.goto(LOCAL + '/tools', { waitUntil: 'load' }); await page.waitForTimeout(1500);
// the messages drawer can sit over the footer, so fire the link's own click handler
if (await page.$('#logoutLink')) { await page.evaluate(() => document.getElementById('logoutLink').click()); await page.waitForTimeout(1500); }
await page.goto(LOCAL + '/links', { waitUntil: 'networkidle' });
if (!(await page.waitForSelector('#siEmail', { timeout: 5000 }).catch(() => null))) note('bug', L + 'logout', 'still signed in after log out');
flush(bag, L + 'logout');
// admin
await page.goto(LOCAL + '/admin', { waitUntil: 'networkidle' });
await page.fill('#adEmail', process.env.ADMIN_EMAIL || 'martybostick@gmail.com'); await page.click('#adSend'); await page.waitForSelector('#adVerify:not([hidden])'); await page.click('#adVerify'); await page.waitForTimeout(1200);
for (const pn of ['overview', 'house', 'campaigns', 'members', 'content', 'reports', 'traffic', 'zones', 'domains', 'blog', 'kb', 'releases', 'pnl', 'settings']) {
const label = L + 'admin#' + pn;
await page.click('.bo-menu [data-pane="' + pn + '"]'); await page.waitForTimeout(1200);
const vis = await page.evaluate(id => { const el = document.getElementById('pane-' + id); return el && !el.hidden && el.offsetHeight > 40; }, pn);
if (!vis) note('bug', label, 'pane did not render');
await domChecks(page, label); flush(bag, label);
await page.screenshot({ path: OUT + '/admin-' + pn + SUF + '.png' }).catch(() => {});
console.log('ok', label);
}
await page.click('.bo-menu [data-pane="house"]'); await page.waitForTimeout(500);
for (const t of ['banner', 'text', 'login', 'solo', 'video', 'featured', 'visits']) { await page.selectOption('#hType', t); await page.waitForTimeout(120); }
await page.selectOption('#hType', 'text'); await page.click('#hCreate'); await page.waitForTimeout(800);
if (!(await page.$('#hErr:not([hidden])'))) note('warn', L + 'admin house form', 'empty submit showed no validation message');
flush(bag, L + 'admin house form');
await ctx.close();
}
await browser.close();
const bugs = findings.filter(f => f.sev === 'bug'), warns = findings.filter(f => f.sev === 'warn');
const lines = ['===== QA WALK (' + MODE + ') ' + new Date().toISOString() + ' =====', 'bugs: ' + bugs.length + ' | warnings: ' + warns.length,
...findings.map(f => '[' + f.sev + '] ' + f.where + ' :: ' + f.what)];
console.log('\n' + lines.join('\n'));
fs.writeFileSync(OUT + '/walk-report.txt', lines.join('\n') + '\n');
process.exit(bugs.length ? 1 : 0);