diff --git a/qa/run.sh b/qa/run.sh index 830e057..5a5f274 100644 --- a/qa/run.sh +++ b/qa/run.sh @@ -14,6 +14,8 @@ # bash qa/run.sh override # level-4 override: week math, hunt, house, dust carry, cap, balance, two concurrent payers (fake chain + signer, throwaway data) # bash qa/run.sh policy # profile policy + link-farm scan: prohibited list, bio links, quarantine, 06:30 claim, walls of free/paying members, 404 walls (unit + local copy; also runs in member) # bash qa/run.sh fuel # Fuel Your Offers: refill notices, refuel streak, Refuel Kit, Engine Room (unit + two-copy tests, throwaway data) +# bash qa/run.sh theme # light/dark themes: WCAG contrast of the main text/background pairs on the member area + public pages, both themes (local copy) +# QA_THEME=dark bash qa/run.sh member # walk every pane in one theme; screenshots land as *-dark.png / *-light.png # Each local run boots server.js on its own port with a throwaway data dir (JSON store, no DB, no # mail key, devCode sign-in), so nothing touches production data. Reports land in qa/out/. set -u @@ -54,6 +56,8 @@ if [ "$MODE" = "public" ]; then node qa/walk.mjs public || status=1 elif [ "$MODE" = "fuel" ]; then for f in qa/refill.test.cjs qa/refuel*.test.cjs; do [ -f "$f" ] && { node "$f" || status=1; }; done +elif [ "$MODE" = "theme" ]; then + start_local 8797 && { LOCAL=http://127.0.0.1:8797 node qa/theme-contrast.mjs || status=1; }; stop_local 8797 elif [ "$MODE" = "override" ]; then node qa/override.test.cjs || status=1 elif [ "$MODE" = "member" ]; then diff --git a/qa/theme-contrast.mjs b/qa/theme-contrast.mjs new file mode 100644 index 0000000..0c389bc --- /dev/null +++ b/qa/theme-contrast.mjs @@ -0,0 +1,138 @@ +// Theme contrast check (2026-11-01): loads the member area and the public pages in both themes with Playwright, samples +// the main text/background pairs (body text, muted text, links, buttons, chips, tags, table text, panel headings, +// stage pills, fields) and reports the WCAG contrast ratio per pair, pass/fail at 4.5:1 (3:1 for large text: +// 24px+, or 18.66px+ bold). Also probes the token pairs directly (every .tag/.chip/.stg/.btn variant is injected +// once so a pair is measured even when the page has no live example). Runs against a local copy: +// bash qa/run.sh theme (boots server.js on :8797 with throwaway data, signs in, walks both themes) +// Env: LOCAL (default http://127.0.0.1:8797), OUT (default qa/out), PW (playwright dir). Exit 1 when any pair fails. +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 LOCAL = process.env.LOCAL || 'http://127.0.0.1:8797'; +const OUT = process.env.OUT || 'qa/out'; +fs.mkdirSync(OUT, { recursive: true }); + +// selectors sampled on every page (text element -> its effective background) +const SAMPLE = ['body', 'p', 'li', 'td', 'th', 'label', 'small', 'h1', 'h2', 'h3', 'h4', 'a', 'button', '.btn', '.muted', '.ink2', '.small', '.sec', '.eyebrow', + '.tag', '.chip', '.chip-t', '.pill', '.stg', '.st', '.badge', '.lbl', '.tile .k', '.tile .v', '.tile .delta', '.panel h2', '.ph h2', '.ph h3', '.card h3', '.card-head .sub', + '.tbl .hd', '.tbl .rw', '.tbl .ft', '.led', '.led b', '.code', '.axis', '.note', '.field', 'input', 'textarea', 'select', '.topbar .crumb', '.topbar h1', '.topbar .readout', '.topbar .who', + '.strip', '.strip b', '.rail a', '.nav a', '.foot', '.foot a', '.hero .lede', '.pkg .k', '.pkg .price', '.pkg .cr', '.feed .row', '.feed .when', '.stat .n', '.stat .l', '.statx .nv', '.statx .lb', + '.pb-head', '.pb-text', '.angle-hook', '.angle-tag', '.lin-row .em', '.lin-row .id', '.gs-step', '.tk-tier', '.wall-pos', '.wc-check', '.bio-meta p', '.bo-menu button', '.tabs button', '.subtab', + '.theme-seg button', '.arrive', '.prelaunch', '.prelaunch a', '.callout', '.obj summary', '.chat-badge', '.cmp td', '.ticker span', '.checks li', '.platecard p', '.closer p', 'footer', 'footer a']; +// probes injected once per page so every variant gets a reading (class list, text, size hint) +const PROBES = [ + ['tag', 'Tag'], ['tag ok', 'Tag ok'], ['tag warn', 'Tag warn'], ['tag bad', 'Tag bad'], ['tag dim', 'Tag dim'], ['tag t', 'Tag t'], + ['chip', 'Chip'], ['chip on', 'Chip on'], ['chip-t', 'Chip-t'], ['chip-t on', 'Chip-t on'], ['pill', 'Pill'], ['badge', 'Badge'], ['badge amber', 'Badge amber'], + ['btn', 'Button'], ['btn pri', 'Primary'], ['btn blue', 'Blue'], ['btn sec', 'Sec'], ['btn small sec', 'Small sec'], + ['st active', 'active'], ['st paused', 'paused'], ['st out', 'out'], ['st rejected', 'rejected'], + ['muted', 'Muted text'], ['ink2', 'Ink 2'], ['ok', 'ok text'], ['warn', 'warn text'], ['bad', 'bad text'], ['sec', 'Section label'], ['note', 'Note'], ['err', 'Error'], + ['code', 'code text'], ['field', 'field text'], ['callout', 'Callout'], ['lin-verdict', 'verdict'], ['tk-tier', 'tier'], ['angle-hook', 'hook'], ['angle-tag', 'angle tag'], + ['stg', 'stage', 'joined'], ['stg', 'stage', 'wallet'], ['stg', 'stage', 'payouts'], ['stg', 'stage', 'bought'], ['stg', 'stage', 'building'], ['stg', 'stage', 'quiet'], ['stg', 'stage', 'live'], ['stg', 'stage', 'low'], ['stg', 'stage', 'out'], ['stg', 'stage', 'paused'], ['stg', 'stage', 'ended'], ['stg', 'stage', 'sched'], + ['stg quiet', 'quiet'], ['chip warm', 'warm chip'], ['chip flat', 'flat chip'], ['pipe-card nm', 'name'], ['theme-seg-probe', 'seg'], +]; + +const browser = await chromium.launch(); +const results = []; +async function sample(page, label) { + const rows = await page.evaluate(({ SAMPLE, PROBES }) => { + const parse = c => { const m = String(c).match(/rgba?\(([^)]+)\)/); if (!m) return null; const p = m[1].split(/[,\s/]+/).filter(Boolean).map(Number); return { r: p[0], g: p[1], b: p[2], a: p.length > 3 ? p[3] : 1 }; }; + const over = (fg, bg) => ({ r: fg.r * fg.a + bg.r * (1 - fg.a), g: fg.g * fg.a + bg.g * (1 - fg.a), b: fg.b * fg.a + bg.b * (1 - fg.a), a: 1 }); + const lum = c => { const f = v => { v /= 255; return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4); }; return 0.2126 * f(c.r) + 0.7152 * f(c.g) + 0.0722 * f(c.b); }; + const ratio = (a, b) => { const l1 = lum(a), l2 = lum(b); return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05); }; + const hex = c => '#' + [c.r, c.g, c.b].map(v => Math.round(v).toString(16).padStart(2, '0')).join(''); + // gradients: average the colour stops (good enough for the two-stop panel/button gradients used here) + // gradients: average the non-transparent colour stops (a transparent stop is not a colour the text sits on) + const gradColour = img => { const stops = [...img.matchAll(/rgba?\([^)]+\)/g)].map(m => parse(m[0])).filter(c => c && c.a > 0); if (!stops.length) return null; const n = stops.length; return { r: stops.reduce((s, c) => s + c.r, 0) / n, g: stops.reduce((s, c) => s + c.g, 0) / n, b: stops.reduce((s, c) => s + c.b, 0) / n, a: stops.reduce((s, c) => s + c.a, 0) / n }; }; + const bgOf = el => { // walk up, compositing translucent layers over what lies beneath + const layers = []; let e = el; + while (e && e !== document.documentElement.parentNode) { + const cs = getComputedStyle(e); const bc = parse(cs.backgroundColor); const bi = cs.backgroundImage; + let c = null; + if (bi && bi !== 'none' && /gradient/.test(bi) && !/radial-gradient\(circle,/.test(bi)) c = gradColour(bi); + if (bc && bc.a > 0) c = c && c.a < 1 ? over(c, bc) : (c || bc); + if (c && c.a > 0) { layers.push(c); if (c.a >= 1) break; } + e = e.parentElement; + } + let out = { r: 255, g: 255, b: 255, a: 1 }; + const body = parse(getComputedStyle(document.body).backgroundColor); if (body && body.a > 0 && !layers.some(l => l.a >= 1)) out = body; + for (let i = layers.length - 1; i >= 0; i--) out = over(layers[i], out); + return out; + }; + const vis = el => { const r = el.getBoundingClientRect(); const cs = getComputedStyle(el); return r.width > 0 && r.height > 0 && cs.visibility !== 'hidden' && cs.display !== 'none' && el.closest('[hidden]') === null; }; + const hasText = el => [...el.childNodes].some(n => n.nodeType === 3 && n.textContent.trim().length > 0) || /^(INPUT|TEXTAREA|SELECT)$/.test(el.tagName); + // probes + const host = document.createElement('div'); host.id = 'contrastProbes'; host.style.cssText = 'position:absolute;left:0;top:0;padding:8px;display:flex;flex-wrap:wrap;gap:6px;z-index:9999;background:var(--panel,transparent)'; + const panel = document.querySelector('.panel,.card,.tile,.tbl') || document.body; panel.appendChild(host); + const hasSeg = !!document.querySelector('link[href*="/assets/cr.css"]'); // the theme switch lives on Control Room pages only + for (const [cls, text, st] of PROBES) { if (cls === 'theme-seg-probe' && !hasSeg) continue; const el = document.createElement(cls.startsWith('btn') ? 'button' : 'span'); el.className = cls.replace('theme-seg-probe', ''); if (cls === 'theme-seg-probe') { el.className = 'seg theme-seg'; el.innerHTML = ''; } else el.textContent = text; if (st) el.setAttribute('data-st', st); el.setAttribute('data-probe', (st ? cls + ' ' + st : cls)); host.appendChild(el); } + const out = []; const seen = new Set(); + const els = []; + for (const sel of SAMPLE) for (const el of document.querySelectorAll(sel)) els.push([sel, el]); + for (const el of host.querySelectorAll('[data-probe],[data-theme]')) els.push(['probe ' + (el.getAttribute('data-probe') || el.parentElement.getAttribute('data-probe') + ' ' + el.className), el]); + for (const [sel, el] of els) { + if (!vis(el) || !hasText(el)) continue; + const cs = getComputedStyle(el); const fg = parse(cs.color); if (!fg) continue; + let bg = bgOf(el); + // placeholder-only inputs: still measure the text colour against the field background + const fgc = fg.a < 1 ? over(fg, bg) : fg; + const size = parseFloat(cs.fontSize), weight = parseInt(cs.fontWeight, 10) || 400; + const large = size >= 24 || (size >= 18.66 && weight >= 700); + const r = ratio(fgc, bg); + const key = sel + '|' + hex(fgc) + '|' + hex(bg) + '|' + large; + if (seen.has(key)) continue; seen.add(key); + out.push({ sel, text: (el.textContent || el.placeholder || '').trim().slice(0, 28), fg: hex(fgc), bg: hex(bg), ratio: Math.round(r * 100) / 100, size: Math.round(size * 10) / 10, weight, large, need: large ? 3 : 4.5 }); + } + host.remove(); + return out; + }, { SAMPLE, PROBES }); + for (const r of rows) results.push(Object.assign({ page: label }, r)); +} + +async function run(theme) { + const ctx = await browser.newContext({ viewport: { width: 1280, height: 950 } }); + await ctx.addInitScript(t => { try { localStorage.setItem('ls.theme', t); } catch (e) {} }, theme); + const page = await ctx.newPage(); page.on('dialog', d => d.accept()); + const T = theme.toUpperCase() + ' '; + // public pages first (no session) + for (const p of ['/', '/join/martbost', '/wall/martbost', '/publishers', '/refuel']) { + await page.goto(LOCAL + p, { waitUntil: 'domcontentloaded' }).catch(() => {}); await page.waitForTimeout(1200); + await sample(page, T + p); + } + // Control Room sign-in + await page.goto(LOCAL + '/links', { waitUntil: 'networkidle' }); + if (await page.$('#siEmail')) { + await page.fill('#siEmail', 'qa-contrast-' + theme + '@example.com'); await page.click('#siGo'); // one account per theme: the account value wins over the local one at sign-in + await page.waitForSelector('#siCodeRow:not([hidden])', { timeout: 15000 }); await page.click('#siGo'); + await page.waitForSelector('#siEmail', { state: 'detached', timeout: 10000 }).catch(() => {}); + await page.waitForTimeout(800); + if (await page.$('#dlg-username')) { await page.fill('#dlg-username', 'qac' + theme); await page.click('#dlgOk'); await page.waitForTimeout(1200); } + await page.evaluate(t => fetch('/api/my/profile', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ theme: t }) }), theme); await page.waitForTimeout(300); + } + for (const sc of ['links', 'ads', 'credits', 'reports', 'team', 'wallet']) { + await page.goto(LOCAL + '/' + sc, { waitUntil: 'networkidle' }).catch(() => {}); await page.waitForTimeout(900); + await page.evaluate(() => document.querySelectorAll('.modal-back,.lgate').forEach(m => m.hidden = true)); + const applied = await page.evaluate(() => document.documentElement.getAttribute('data-theme')); if (applied !== theme) results.push({ page: T + '/' + sc, sel: 'THEME', text: 'data-theme=' + applied, fg: '-', bg: '-', ratio: 0, size: 0, weight: 0, large: false, need: 1 }); + await sample(page, T + '/' + sc); + } + await page.goto(LOCAL + '/tools', { waitUntil: 'load' }); await page.waitForTimeout(2500); + for (const pn of ['overview', 'promo', 'pipeline', 'line', 'profile']) { + await page.click('.bo-menu [data-pane="' + pn + '"]').catch(() => {}); await page.waitForTimeout(900); + await page.evaluate(() => document.querySelectorAll('.modal-back,.lgate').forEach(m => m.hidden = true)); + await sample(page, T + '/tools#' + pn); + } + await page.screenshot({ path: OUT + '/contrast-' + theme + '-tools.png' }).catch(() => {}); + await ctx.close(); +} +await run('light'); +await run('dark'); +await browser.close(); + +const fails = results.filter(r => r.ratio < r.need); +const lines = ['===== THEME CONTRAST ' + new Date().toISOString() + ' =====', 'pairs: ' + results.length + ' | fail: ' + fails.length, + '', 'FAILS (ratio < need):', ...fails.sort((a, b) => a.ratio - b.ratio).map(f => `[fail] ${f.page} :: ${f.sel} "${f.text}" ${f.fg} on ${f.bg} = ${f.ratio}:1 (need ${f.need}, ${f.size}px/${f.weight})`), + '', 'WORST 25 OVERALL:', ...results.slice().sort((a, b) => a.ratio - b.ratio).slice(0, 25).map(f => `${f.ratio}:1 ${f.page} :: ${f.sel} "${f.text}" ${f.fg} on ${f.bg} (${f.size}px/${f.weight}${f.large ? ' large' : ''})`), + '', 'ALL PAIRS:', ...results.map(f => `${f.ratio < f.need ? 'FAIL' : 'ok '} ${f.ratio}:1 ${f.page} :: ${f.sel} "${f.text}" ${f.fg} on ${f.bg} (${f.size}px/${f.weight}${f.large ? ' large' : ''})`)]; +fs.writeFileSync(OUT + '/theme-contrast.txt', lines.join('\n') + '\n'); +console.log(lines.slice(0, Math.min(lines.length, 60 + fails.length)).join('\n')); +process.exit(fails.length ? 1 : 0); diff --git a/qa/walk.mjs b/qa/walk.mjs index a1f4f73..762a0d5 100644 --- a/qa/walk.mjs +++ b/qa/walk.mjs @@ -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 - 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);