QA for the themes: contrast check in both themes, QA_THEME walks, theme-switch assertions

qa/theme-contrast.mjs (bash qa/run.sh theme) mirrors LinkSpin's: signs in one account per theme (the account value wins at sign-in), walks every member pane, 24 public pages and the admin panes in light and dark with Playwright, samples the main text/background pairs 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). Result today: 8,169 pairs, 0 fails, worst 4.76:1 (the ok badge in light), worst dark 5.76:1.

qa/walk.mjs honours QA_THEME=light|dark|auto (localStorage iap.theme set before the first navigation; screenshots carry a -<theme> suffix so both sets survive), asserts the header and Profile switch (applies at once, saves to the account, repaints the other control, never touches the username), screenshots the public home, the member's wall and the join page from the local copy, and returns to /my with waitUntil load (a signed-in member area keeps polling, so networkidle never settles). 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:
martbost
2026-11-01 12:03:38 -06:00
parent 1aec9caf6c
commit 4ae7a318da
3 changed files with 215 additions and 8 deletions
+52 -8
View File
@@ -14,6 +14,11 @@ const LIVE = process.env.LIVE || 'https://instantadpay.com';
const LOCAL = process.env.LOCAL || 'http://127.0.0.1:8796';
const OUT = process.env.OUT || 'qa/out';
fs.mkdirSync(OUT, { recursive: true });
// QA_THEME=light|dark|auto (2026-11-01): set localStorage iap.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
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('iap.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/;
@@ -28,7 +33,7 @@ function watch(page, base) {
if (/status of (400|401|404)/.test(m.text())) 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)) 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 (2026-11-01)
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 } }));
await ctx.addInitScript(() => { try { sessionStorage.setItem('iap.welcome.v1', '1'); } catch (e) {} }); // the session pop-up would block every click in an automated run
const page = await ctx.newPage(); const bag = watch(page, LIVE);
const PUBLIC = ['/', '/ledger', '/contract', '/terms', '/privacy', '/disclaimer', '/wall/martbost', '/join/martbost',
@@ -79,19 +85,19 @@ 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 }));
await m.addInitScript(() => { try { sessionStorage.setItem('iap.welcome.v1', '1'); } catch (e) {} }); // the session pop-up would block every click in an automated run
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 } }));
await ctx.addInitScript(() => { try { sessionStorage.setItem('iap.welcome.v1', '1'); } catch (e) {} }); // the session pop-up would block every click in an automated run
const page = await ctx.newPage(); const bag = watch(page, LOCAL);
page.on('dialog', d => d.accept());
@@ -112,7 +118,7 @@ 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 + '/my-' + pn + '.png' }).catch(() => {});
await page.screenshot({ path: OUT + '/my-' + pn + SUF + '.png' }).catch(() => {});
console.log('ok', label, 'subtabs:', subs.length);
}
// Game Pass card on the Games tab (2026-10-16): hidden while gamePassEnabled is off, rendered with its state and Buy button once on; /my#games?pass=1 highlights it
@@ -231,6 +237,44 @@ if (MODE === 'member' || MODE === 'all') {
}
flush(bag, L + 'my#help (ticket)');
await page.screenshot({ path: OUT + '/my-help-ticket.png' }).catch(() => {});
// theme switch (2026-11-01): the header 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));
await page.click('.bo-menu [data-pane="profile"]'); await page.waitForTimeout(600); await hide(page);
const seg = await page.$('#boTheme [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 member-area header'); 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('iap.theme')]);
if (t1[0] !== 'dark' || t1[1] !== 'dark') note('bug', label, 'Dark did not apply (data-theme=' + t1[0] + ', iap.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 header change');
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 + ')');
const acct2 = await (await page.request.get(LOCAL + '/api/me')).json();
if (acct2.theme !== 'light') note('bug', label, 'account did not follow the Profile card (got ' + acct2.theme + ')');
if (acct2.username !== acct.username) note('bug', label, 'a theme save touched the username');
// restore the walk's theme so the remaining screenshots match the set
await page.evaluate(t => { if (t) window.IAPTheme.set(t); else { localStorage.removeItem('iap.theme'); window.IAPTheme.apply(); } }, THEME);
await page.evaluate(t => fetch('/api/my/profile', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ theme: t || null }) }).then(r => r.status), THEME); // awaited: a save still in flight would abort on the next navigation
await page.waitForTimeout(400);
}
await page.screenshot({ path: OUT + '/my-profile-theme' + SUF + '.png' }).catch(() => {});
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 hide(page);
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 + '/my', { waitUntil: 'load' }); await page.waitForTimeout(2500); await hide(page); // load, not networkidle: a signed-in member area keeps polling
const chat = await page.$('#chatMenuBtn'); if (chat) { await chat.click(); await page.waitForTimeout(800); await domChecks(page, L + 'messages'); flush(bag, L + 'messages'); }
const lo = await page.$('#logoutLink'); if (lo) { await lo.click(); await page.waitForTimeout(1000); }
if (!(await page.$('#authArea:not([hidden])'))) note('bug', L + 'logout', 'auth card not shown after log out');
@@ -244,7 +288,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);
}
// admin Support pane: the member's ticket is listed, opens, takes an internal note and a reply; the member then sees the reply and an unread badge