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>
This commit is contained in:
+48
-9
@@ -4,6 +4,8 @@
|
||||
// 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';
|
||||
@@ -14,6 +16,9 @@ const LIVE = process.env.LIVE || 'https://linkspin.app'; // this is LinkSpin's h
|
||||
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
|
||||
@@ -28,7 +33,7 @@ function watch(page, base) {
|
||||
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(); if (u.startsWith(base) && !NOISE.test(u)) bag.failed.push(u + ' ' + (r.failure() && r.failure().errorText)); });
|
||||
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;
|
||||
}
|
||||
@@ -46,7 +51,8 @@ async function domChecks(page, label) {
|
||||
const overflow = document.documentElement.scrollWidth > document.documentElement.clientWidth + 2;
|
||||
return { brokenImgs, unfilled, overflow, title: document.title };
|
||||
});
|
||||
if (r.brokenImgs.length) note('bug', label, 'broken images: ' + r.brokenImgs.slice(0, 3).join(', '));
|
||||
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;
|
||||
@@ -56,7 +62,7 @@ const hide = page => page.evaluate(() => { document.querySelectorAll('.modal-bac
|
||||
const browser = await chromium.launch();
|
||||
|
||||
if (MODE === 'public' || MODE === 'all') {
|
||||
const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } });
|
||||
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',
|
||||
@@ -78,18 +84,18 @@ if (MODE === 'public' || MODE === 'all') {
|
||||
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 browser.newContext({ viewport: { width: 390, height: 844 }, isMobile: true });
|
||||
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, '-') + '.png' }).catch(() => {});
|
||||
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 browser.newContext({ viewport: { width: 1280, height: 950 } });
|
||||
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 ';
|
||||
@@ -109,7 +115,7 @@ if (MODE === 'member' || MODE === 'all') {
|
||||
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 + '.png' }).catch(() => {});
|
||||
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
|
||||
@@ -125,12 +131,45 @@ if (MODE === 'member' || MODE === 'all') {
|
||||
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 + '.png' }).catch(() => {});
|
||||
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' });
|
||||
@@ -145,7 +184,7 @@ if (MODE === 'member' || MODE === 'all') {
|
||||
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 + '.png' }).catch(() => {});
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user