Holding tank in the Control Room menu (Marty 2026-11-11): shown only to members who can adopt (eligible, or at the cap), badge = people adoptable right now, title says you can adopt up to <tankAdoptCap> at a time, opens More > My line; GET /api/my/tank/summary (cached waiting list, no full list); tank card says the cap; chatbot knows where the tank lives and the 10-at-a-time rule; cr-shell ?v=20261111tank, my.js ?v=20261111tank. qa/btc4hits-bridge 28/28 (incl. browser checks)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Marty Bostick
2026-11-11 08:17:31 -06:00
parent 5d79abe318
commit bfa13302e1
18 changed files with 76 additions and 23 deletions
+28 -1
View File
@@ -9,7 +9,7 @@ import { spawn } from 'node:child_process';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { fileURLToPath, pathToFileURL } from 'node:url';
const SITE = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
const PORT = Number(process.env.B4H_PORT || 8831), BASE = 'http://127.0.0.1:' + PORT;
const sleep = ms => new Promise(r => setTimeout(r, ms));
@@ -45,6 +45,33 @@ try {
ok(!fs.existsSync(path.join(dir, 'legacy-grants.json')) && !/legacy grant/.test(fs.readFileSync(log, 'utf8')), 'no welcome-back credits granted');
const a = JSON.parse(fs.readFileSync(path.join(dir, 'accounts.json'), 'utf8')).byEmail['newb4h@qa.test'];
ok(a && a.joinedVia === 'b4h' && a.joinedRef === 'legacy:btc4hits', 'account records angle b4h + source legacy:btc4hits', JSON.stringify(a && { v: a.joinedVia, r: a.joinedRef }));
// 1b. Holding tank menu item (2026-11-11): the summary route, and the rail item in a real browser
const cookies = (v.headers.getSetCookie ? v.headers.getSetCookie() : []).map(c => c.split(';')[0]);
const sum = await (await fetch(BASE + '/api/my/tank/summary', { headers: { Cookie: cookies.join('; ') } })).json();
ok(sum.adopter === false && sum.cap === 10 && typeof sum.waiting === 'number', '/api/my/tank/summary: a new member is not an adopter, cap 10 from the setting', JSON.stringify(sum));
ok((await fetch(BASE + '/api/my/tank/summary')).status === 401, '/api/my/tank/summary needs a sign-in');
try {
const PW = process.env.PW || 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright';
const { chromium } = (await import(pathToFileURL(PW + '/index.js').href)).default;
const browser = await chromium.launch();
const shot = async (summary) => {
const ctx = await browser.newContext(); await ctx.addCookies(cookies.map(c => { const i = c.indexOf('='); return { name: c.slice(0, i), value: c.slice(i + 1), domain: '127.0.0.1', path: '/' }; }));
const page = await ctx.newPage(); const errs = []; page.on('pageerror', e => errs.push(e.message));
if (summary) await page.route('**/api/my/tank/summary', r => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(summary) }));
await page.goto(BASE + '/links', { waitUntil: 'domcontentloaded' }); await page.waitForTimeout(2500);
const out = await page.evaluate(() => { const a = document.getElementById('crTank'); return a ? { hidden: a.hidden, href: a.getAttribute('href'), title: a.title, badge: (a.querySelector('.rbadge') || {}).textContent || '', label: (a.querySelector('.lbl') || {}).textContent || '' } : null; });
await ctx.close(); return Object.assign({ errs }, out || {});
};
const s1 = await shot(null);
ok(s1.href === '/tools#line' && s1.hidden === true, 'rail: Holding tank item hidden for a member who cannot adopt', JSON.stringify(s1));
const s2 = await shot({ adopter: true, eligible: true, full: false, held: 2, cap: 10, waiting: 1234 });
ok(s2.hidden === false && s2.label === 'Holding tank' && s2.badge === '999+', 'rail: shown for an adopter, with the waiting badge', JSON.stringify(s2));
ok(/You can adopt up to 10 people at a time\./.test(s2.title) && /1,234 waiting/.test(s2.title) && !/\u2014/.test(s2.title), 'rail: one line with the cap from the setting', s2.title);
const s3 = await shot({ adopter: true, eligible: false, full: true, held: 7, cap: 7, waiting: 0 });
ok(s3.hidden === false && !s3.badge && /up to 7 people at a time/.test(s3.title), 'rail: an adopter at the cap still sees it; cap read from the response (7), no badge when nobody waits', JSON.stringify(s3));
ok(!s1.errs.length && !s2.errs.length, 'no page errors', JSON.stringify(s1.errs.concat(s2.errs)).slice(0, 200));
await browser.close();
} catch (e) { ok(false, 'browser check ran', e.message); }
} else ok(false, 'dev sign-in code available', JSON.stringify(st));
// 2. admin spin links
ok((await admin('/api/admin/rotations?email=owner@qa.test', 'GET', null, false)).status === 401, 'GET needs admin');