Files
instantadpay/qa/walk.mjs
T
martbost 1e040f21ff Chat knowledge base: the assistant answers from maintained entries, and support replies become entries
- kb.js: entries { id, title, questions, answer, tags, pattern, handoff, order, source, updated } in MySQL table kb_entries (created on boot) or DATA_DIR/kb.json without DATABASE_URL. BM25 over title, question variants and tags (answer at a low weight) with word bigrams; the top hits (within 30% of the best, score 3+) go into the system prompt as KNOWLEDGE BASE, and when nothing fits the prompt says to answer "I'm not sure, ask support".
- One source: chatbot.js CANNED seeds the KB (ids c-*, its regex becomes the entry's instant-answer pattern, same first-match order), kb-seed.js seeds the home FAQ, Platform Facts, wallets FAQ and the Coinbase support reply (f-*). The fast path now serves the KB entry, so an admin edit changes the instant answer; the in-code CANNED only answers if the KB store fails. Unedited seeds follow code changes, edited ones are left alone, deleted seeds stay deleted.
- Admin > Knowledge base: list, search, filter by source, add, edit, delete, and Try a question (instant answer or what the AI is given). Support tickets: "Save as KB entry" under each sent reply opens a draft with the member's question and the reply (greeting and sign-off trimmed). Em dashes in admin input become commas.
- chatbot.js: OPENROUTER_URL override for tests; solo-ads answer em dash removed; KNOWLEDGE_DATE 2026-10-20.
- qa/chatbot-sync.mjs: takes the later of KNOWLEDGE_DATE and /api/chat/kb-stamp (newest KB edit by a person, Central day; seed refreshes do not count).
- QA: qa/kb-retrieval.cjs (13 sample questions rank the right entry first, off-topic returns nothing), qa/kb-chat.mjs (local copy + mock OpenRouter: Coinbase answered from the KB, fast path without an AI call, admin CRUD, restart keeps edits), bash qa/run.sh kb; walk covers admin#kb and Save as KB entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 05:37:09 -05:00

287 lines
23 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: sign in, every member pane + sub-tab, 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)
// 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://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 });
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/;
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())) 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('response', r => { const st = r.status(); const u = r.url(); if (st >= 500 && u.startsWith(base)) 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 };
});
if (r.brokenImgs.length) note('bug', label, 'broken images: ' + r.brokenImgs.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,.iap-welcome').forEach(m => m.hidden = true); });
const browser = await chromium.launch();
if (MODE === 'public' || MODE === 'all') {
const ctx = 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',
'/join/martbost?v=instant', '/join/martbost?v=adspend', '/join/martbost?v=free', '/join/martbost?v=ledger', '/join/martbost?v=two',
'/admin', '/my', '/shorts', '/presentation', '/presentation?ref=martbost', '/support', '/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 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 ctx.close(); await m.close();
}
if (MODE === 'member' || MODE === 'all') {
const ctx = 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());
const L = 'LOCAL ';
await page.goto(LOCAL + '/my', { waitUntil: 'networkidle' });
await page.fill('#mcEmail', 'qa-walk@example.com'); await page.click('#mcSendBtn');
await page.waitForSelector('#mcVerifyBtn:not([hidden])'); await page.click('#mcVerifyBtn'); await page.waitForTimeout(2000);
if (await page.$('#onboardModal:not([hidden])')) { await page.fill('#obUsername', 'qawalker'); await page.click('#obSave'); await page.waitForTimeout(1200); }
await hide(page); flush(bag, L + 'sign-in');
const PANES = ['overview', 'line', 'pipeline', 'buy', 'campaigns', 'earn', 'earnings', 'promo', 'training', 'help', 'games', 'wallet', 'profile'];
for (const pn of PANES) {
const label = L + 'my#' + 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 + '/my-' + pn + '.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
await page.request.patch(LOCAL + '/api/admin/site', { headers: { Authorization: 'Bearer ' + (process.env.ADMIN_PASSWORD || 'localtest'), 'Content-Type': 'application/json' }, data: { gamePassEnabled: '1' } }).catch(() => {});
await page.goto(LOCAL + '/my#games?pass=1', { waitUntil: 'networkidle' }); await page.waitForTimeout(1500); await hide(page);
const gpVis = await page.evaluate(() => { const c = document.getElementById('gpCard'); return !!(c && !c.hidden && c.offsetHeight > 40 && /Game Pass/.test(c.textContent) && c.querySelector('#gpBuy, #gpGoBuy')); });
if (!gpVis) note('bug', L + 'my#games/gamepass', 'Game Pass card did not render with gamePassEnabled on (deep link /my#games?pass=1)');
else { await domChecks(page, L + 'my#games/gamepass'); console.log('ok Game Pass card'); }
await page.request.patch(LOCAL + '/api/admin/site', { headers: { Authorization: 'Bearer ' + (process.env.ADMIN_PASSWORD || 'localtest'), 'Content-Type': 'application/json' }, data: { gamePassEnabled: '0' } }).catch(() => {});
await page.goto(LOCAL + '/my#games'); await page.reload({ waitUntil: 'load' }); await page.waitForTimeout(2500); await hide(page); // a hash-only goto would not reload the card
if (await page.evaluate(() => { const c = document.getElementById('gpCard'); return !!(c && !c.hidden); })) note('bug', L + 'my#games/gamepass', 'Game Pass card shows while gamePassEnabled is off');
flush(bag, L + 'my#games/gamepass');
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');
// viral links: the builder renders a ?ref= link; any page + ?ref=<member> redirects clean and sets the sponsor cookie; an unknown ref sets nothing
await page.click('.promo-pills [data-promo="viral"]'); await page.waitForTimeout(1200);
const vl = await page.$eval('#viralLink', e => e.textContent).catch(() => '');
if (!/^https:\/\/instantadpay\.com\/.*[?&]ref=[a-z0-9_]+$/i.test(vl)) note('bug', L + 'promo/viral', 'builder link not rendered: ' + vl);
const me = await page.evaluate(() => fetch('/api/me').then(r => r.json()));
const tok = me.username || me.refCode;
// served in place (no redirect: Facebook drops the name otherwise), cookie on the response, og:url carries the ref
const rr = await page.request.get(LOCAL + '/?ref=' + tok + '&x=1', { maxRedirects: 0 });
const sc = (rr.headersArray().filter(h => h.name.toLowerCase() === 'set-cookie').map(h => h.value)).join('; ');
const rb = await rr.text();
if (rr.status() !== 200 || !/<title>/.test(rb)) note('bug', L + 'viral/inplace', 'expected the page at the decorated address, got ' + rr.status());
if (!new RegExp('iap\\.sponsor=' + tok + ';').test(sc) || !/iap\.angle=page;/.test(sc)) note('bug', L + 'viral/cookie', 'sponsor/angle cookie not set: ' + sc);
if (!new RegExp('property="og:url" content="[^"]*[?&]ref=' + tok + '"').test(rb)) note('bug', L + 'viral/og', 'og:url does not carry the ref');
const ru = await page.request.get(LOCAL + '/?ref=nobody_zz9', { maxRedirects: 0 });
const su = (ru.headersArray().filter(h => h.name.toLowerCase() === 'set-cookie').map(h => h.value)).join('; ');
const ub = await ru.text();
if (ru.status() !== 200 || /iap\.sponsor=/.test(su) || /ref=nobody_zz9/.test(ub)) note('bug', L + 'viral/unknown', 'unknown ref must serve the plain page with no cookie and a clean og:url: ' + ru.status() + ' ' + su);
const rj = await page.request.get(LOCAL + '/join/' + tok + '?ref=' + tok, { maxRedirects: 0 });
if (rj.status() !== 200) note('bug', L + 'viral/join', '/join keeps its own ?ref handling, got ' + rj.status());
console.log('ok viral links: builder + redirect + cookie');
// help desk (2026-10-16): Help pane -> new ticket -> thread -> reply; the ref is reused by the admin Support walk below
let helpRef = '';
await page.click('.bo-menu [data-pane="help"]'); await page.waitForTimeout(800); await hide(page);
await page.click('#helpNewBtn').catch(() => note('bug', L + 'my#help', 'no New ticket button'));
await page.waitForTimeout(300);
await page.click('#hnSend'); await page.waitForTimeout(600);
if (!(await page.$eval('#hnMsg', e => e.textContent.trim()).catch(() => ''))) note('warn', L + 'my#help', 'empty ticket showed no validation message');
await page.selectOption('#hnCat', 'Wallet & payouts').catch(() => {});
await page.fill('#hnSubject', 'QA walk: payout question');
await page.fill('#hnBody', 'This is the QA walk testing the help desk. Line two.\nhttps://instantadpay.com/ledger');
await page.click('#hnSend'); await page.waitForTimeout(1500); await hide(page);
helpRef = (/#help\?t=((?:IAP|LS)-\d+)/.exec(page.url()) || [])[1] || '';
if (!helpRef || !(await page.$('#hrSend'))) note('bug', L + 'my#help', 'new ticket did not open its thread: ' + page.url());
else {
await page.fill('#hrBody', 'QA walk follow-up reply.'); await page.click('#hrSend'); await page.waitForTimeout(1200);
const n = await page.$$eval('#helpBody .sup-msg', els => els.length).catch(() => 0);
if (n < 2) note('bug', L + 'my#help', 'reply did not show in the thread (' + n + ' messages)');
await page.click('#helpBack'); await page.waitForTimeout(900);
if (!(await page.$('#helpBody .sup-row[data-ref="' + helpRef + '"]'))) note('bug', L + 'my#help', 'ticket missing from the list');
await domChecks(page, L + 'my#help (ticket)'); console.log('ok Help pane ticket', helpRef);
}
flush(bag, L + 'my#help (ticket)');
await page.screenshot({ path: OUT + '/my-help-ticket.png' }).catch(() => {});
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');
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', 'support', 'reports', 'traffic', 'blog', 'releases', 'pnl', 'gamepass', 'kb', '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 + '.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
if (helpRef) {
await page.click('.bo-menu [data-pane="support"]'); await page.waitForTimeout(1000);
if (!(await page.$('#spTable [data-spref="' + helpRef + '"]'))) note('bug', L + 'admin#support', 'ticket ' + helpRef + ' not in the open list');
const badge = await page.$eval('#supBadge', e => e.hidden ? '' : e.textContent).catch(() => '');
if (!badge) note('bug', L + 'admin#support', 'no open-count badge in the menu');
await page.click('#spTable [data-spref="' + helpRef + '"]').catch(() => {}); await page.waitForTimeout(1000);
if (!(await page.$('#spBody'))) note('bug', L + 'admin#support', 'ticket view did not open');
else {
if (!/member account/.test(await page.$eval('#spView', e => e.textContent))) note('bug', L + 'admin#support', 'requester not recognised as a member');
await page.check('#spInternal'); await page.fill('#spBody', 'QA internal note, never shown to the member.'); await page.click('#spSend'); await page.waitForTimeout(1000);
await page.selectOption('#spTpl', '0').catch(() => {}); await page.waitForTimeout(200);
if (!(await page.$eval('#spBody', e => e.value).catch(() => ''))) note('bug', L + 'admin#support', 'saved reply did not insert');
await page.click('#spSend'); await page.waitForTimeout(400);
const ok = await page.$('#dlgOk'); if (ok) await ok.click(); else note('bug', L + 'admin#support', 'no in-page confirm before sending');
await page.waitForTimeout(1200);
const txt = await page.$eval('#spView', e => e.textContent).catch(() => '');
if (!/internal note/.test(txt) || !/Waiting on member/.test(await page.$eval('#spSt', e => e.selectedOptions[0].textContent).catch(() => ''))) note('bug', L + 'admin#support', 'note/reply/status not reflected');
await page.selectOption('#spPr', 'high'); await page.waitForTimeout(800);
await domChecks(page, L + 'admin#support (ticket)'); console.log('ok admin Support ticket', helpRef);
// "Save as KB entry" under the reply: a prefilled knowledge-base draft (question from the member, answer from the reply) that saves
flush(bag, L + 'admin#support (ticket)');
const save = await page.$('#spView [data-kbsave]');
if (!save) note('bug', L + 'admin#support', 'no "Save as KB entry" button under the sent reply');
else {
await save.click(); await page.waitForTimeout(1200);
const draft = await page.evaluate(() => ({ q: (document.getElementById('kbQs') || {}).value || '', a: (document.getElementById('kbAns') || {}).value || '', vis: !document.getElementById('kbEdit').hidden }));
if (!draft.vis || !draft.q.trim() || !draft.a.trim()) note('bug', L + 'admin#kb', 'Save as KB entry did not open a prefilled draft ' + JSON.stringify(draft).slice(0, 160));
await domChecks(page, L + 'admin#kb (draft from ticket)');
await page.click('#kbSave'); await page.waitForTimeout(1200);
const listed = await page.$eval('#kbTable', e => e.textContent).catch(() => '');
if (!/from a ticket/.test(listed)) note('bug', L + 'admin#kb', 'entry saved from the ticket is not in the list');
flush(bag, L + 'admin#kb (saved from ticket)'); console.log('ok admin Save as KB entry');
}
}
flush(bag, L + 'admin#support (ticket)');
await page.screenshot({ path: OUT + '/admin-support-ticket.png' }).catch(() => {});
await page.goto(LOCAL + '/admin#support?t=' + helpRef, { waitUntil: 'networkidle' }); await page.waitForTimeout(1000);
if (!(await page.$('#spBody'))) note('bug', L + 'admin#support', 'deep link #support?t=<ref> did not open the ticket');
flush(bag, L + 'admin#support (deep link)');
}
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');
// member sees Marty's reply: badge, thread without the internal note
if (helpRef) {
await page.goto(LOCAL + '/my', { waitUntil: 'networkidle' });
if (await page.$('#mcEmail:not([hidden])') && await page.$('#authArea:not([hidden])')) {
await page.fill('#mcEmail', 'qa-walk@example.com'); await page.click('#mcSendBtn'); await page.waitForSelector('#mcVerifyBtn:not([hidden])'); await page.click('#mcVerifyBtn'); await page.waitForTimeout(2000);
}
await hide(page); await page.waitForTimeout(800);
if (!(await page.$eval('#helpBadge', e => !e.hidden).catch(() => false))) note('bug', L + 'my#help', 'no unread badge after the admin replied');
await page.waitForTimeout(1500); await page.goto(LOCAL + '/my#help?t=' + helpRef); await page.waitForTimeout(1500); // same document: the hash change opens the ticket await hide(page);
const th = await page.$eval('#helpBody', e => e.textContent).catch(() => '');
if (!/Marty, InstantAdPay support/.test(th)) note('bug', L + 'my#help', 'admin reply not shown to the member');
if (/QA internal note/.test(th)) note('bug', L + 'my#help', 'INTERNAL NOTE LEAKED to the member');
flush(bag, L + 'my#help (reply seen)'); console.log('ok member sees reply, no internal note');
}
// public /support (signed out): the form, the guard, the private ticket link
{
const pctx = await browser.newContext({ viewport: { width: 390, height: 844 }, isMobile: true });
await pctx.addInitScript(() => { try { sessionStorage.setItem('iap.welcome.v1', '1'); } catch (e) {} });
const pp = await pctx.newPage(); const pbag = watch(pp, LOCAL);
await pp.goto(LOCAL + '/support', { waitUntil: 'networkidle' }); await pp.waitForTimeout(800);
await domChecks(pp, L + '/support');
if (!(await pp.$('#supForm'))) note('bug', L + '/support', 'form did not render');
else {
await pp.fill('#supName', 'QA Visitor'); await pp.fill('#supEmail', 'qa-visitor@example.com');
await pp.fill('#supSubject', 'QA: cannot sign in'); await pp.fill('#supBody', 'The sign-in code never arrives. QA walk.');
await pp.click('#supSend'); await pp.waitForTimeout(3500);
const tl = await pp.$eval('#supMain a.btn[href^="/support/t/"]', e => e.getAttribute('href')).catch(() => '');
if (!tl) note('bug', L + '/support', 'no confirmation with a private ticket link: ' + (await pp.$eval('#supMsg', e => e.textContent).catch(() => '')));
else {
await pp.goto(LOCAL + tl, { waitUntil: 'networkidle' }); await pp.waitForTimeout(800);
if (!(await pp.$('#tkSend'))) note('bug', L + '/support/t', 'private ticket page did not render');
else { await pp.fill('#tkBody', 'Adding one more detail.'); await pp.click('#tkSend'); await pp.waitForTimeout(1000); if ((await pp.$$('.sup-msg')).length < 2) note('bug', L + '/support/t', 'reply on the private link did not show'); }
await domChecks(pp, L + '/support/t'); console.log('ok /support + private link');
const bad = await pp.request.get(LOCAL + '/api/support/t/' + tl.split('/').pop().slice(0, -4) + 'AAAA');
if (bad.status() !== 404) note('bug', L + '/support/t', 'a tampered token was accepted: ' + bad.status());
}
const bot = await pp.request.post(LOCAL + '/api/support', { data: { email: 'qa-bot@example.com', subject: 'x bot', body: 'bot body here', fts: Date.now(), fage: 10 } });
if (bot.status() !== 400) note('bug', L + '/api/support', 'instant (form-age 10ms) post was not refused: ' + bot.status());
}
await pp.screenshot({ path: OUT + '/support-public.png' }).catch(() => {});
flush(pbag, L + '/support'); await pctx.close();
}
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);