1c2ef3780c
When all member login slots are taken the Ads screen offers "Reserve the next slot" instead of a dead button. Same price and checks as a slot (purchased credits only), paid at reserve time; the campaign is 'queued' with queuedAt, never serves and has no 30-day clock. First paid, first served: the member sees their place and an estimated start (Central time, labelled an estimate) built from the live slots' end dates and the line ahead. A freed slot (ended, paused, or found by the new 1-minute tick) goes to the oldest reservation: starts now, expires now + 30 days, never more than loginSlotsMax live. Idempotent across the deploy overlap: JSON mode takes a lock file and records every promotion/cancel in DATA_DIR/login-queue.json, re-read before any change; MySQL mode uses guarded UPDATEs (status + live count in one statement). Owner gets an on-site notice and an email (unsubscribes respected). A paused slot resumes only when live + queued < max. Cancel before start = full refund (credited back as purchased credits; any unburned accrual released). Edits while queued are free and keep the free correction. Admin: Login-ad queue card with cancel + refund, plus the Member content action. New credit activity log (credit-log.json / credit_log table): reserved (queue #N), bought, started, refunds, shown on the Ads screen. Audit skips queued/cancelled login rows. Chatbot CANNED + FACTS updated (6 slots, paid queue, full refund before start). Tags bumped: ads-screen.js, admin.js, my.js 20261023q. Tests: qa/loginqueue.test.cjs (two app copies promoting at once) + qa/loginqueue.e2e.mjs; bash qa/run.sh loginqueue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
2.8 KiB
Bash
57 lines
2.8 KiB
Bash
#!/usr/bin/env bash
|
|
# InstantAdPay QA harness runner. From the site dir:
|
|
# bash qa/run.sh public # live public pages only (no local server)
|
|
# bash qa/run.sh member # local copy: member + admin walk
|
|
# bash qa/run.sh earn # local copy: earning flows end to end (~2-3 min)
|
|
# bash qa/run.sh all # public + member + earn
|
|
# bash qa/run.sh kb # chat knowledge base: retrieval unit test + chat endpoint e2e on a local copy with a mock OpenRouter
|
|
# bash qa/run.sh sponsorfollow # sponsor follow rule + network tank unit tests + carry hold guard
|
|
# bash qa/run.sh lsid # page-builder lead -> rotator conversion + postback, audience pixel events and cookieless hits
|
|
# bash qa/run.sh loginqueue # prepaid login-slot queue: ads.js unit test (two app copies promoting at once) + HTTP/Ads-screen e2e on a local copy
|
|
# 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
|
|
cd "$(dirname "$0")/.."
|
|
MODE="${1:-all}"
|
|
OUT="qa/out"; mkdir -p "$OUT"
|
|
TMP="${TMPDIR:-${TEMP:-/tmp}}/iap-qa-$$"
|
|
status=0
|
|
|
|
start_local() { # $1 = port
|
|
local port="$1"
|
|
rm -rf "$TMP-$port"; mkdir -p "$TMP-$port/uploads"
|
|
(PORT="$port" DATA_DIR="$TMP-$port" ADMIN_EMAIL="${ADMIN_EMAIL:-martybostick@gmail.com}" ADMIN_PASSWORD=localtest node server.js > "$OUT/server-$port.log" 2>&1 &)
|
|
for i in $(seq 1 20); do curl -s -m 2 "http://127.0.0.1:$port/api/config" >/dev/null && return 0; sleep 1; done
|
|
echo "local server on :$port did not come up"; return 1
|
|
}
|
|
stop_local() { # $1 = port
|
|
for p in $(netstat -ano 2>/dev/null | grep ":$1 " | awk '{print $5}' | sort -u); do taskkill //F //PID "$p" >/dev/null 2>&1; done
|
|
rm -rf "$TMP-$1"
|
|
}
|
|
|
|
if [ "$MODE" = "public" ]; then
|
|
node qa/walk.mjs public || status=1
|
|
elif [ "$MODE" = "member" ]; then
|
|
start_local 8796 && { LOCAL=http://127.0.0.1:8796 node qa/walk.mjs member || status=1; }; stop_local 8796
|
|
elif [ "$MODE" = "sponsorfollow" ]; then
|
|
node qa/sponsorfollow.test.cjs || status=1
|
|
node qa/carry-hold.test.cjs || status=1
|
|
elif [ "$MODE" = "loginqueue" ]; then
|
|
node qa/loginqueue.test.cjs || status=1
|
|
node qa/loginqueue.e2e.mjs || status=1
|
|
elif [ "$MODE" = "lsid" ]; then
|
|
node qa/lsid-pixel.test.mjs || status=1
|
|
elif [ "$MODE" = "kb" ]; then
|
|
node qa/kb-retrieval.cjs || status=1
|
|
node qa/kb-chat.mjs || status=1
|
|
elif [ "$MODE" = "earn" ]; then
|
|
start_local 8797 && { LOCAL=http://127.0.0.1:8797 node qa/earn.mjs || status=1; }; stop_local 8797
|
|
else
|
|
node qa/walk.mjs public || status=1
|
|
start_local 8796 && { LOCAL=http://127.0.0.1:8796 node qa/walk.mjs member || status=1; }; stop_local 8796
|
|
start_local 8797 && { LOCAL=http://127.0.0.1:8797 node qa/earn.mjs || status=1; }; stop_local 8797
|
|
fi
|
|
echo
|
|
echo "reports: $OUT/walk-report.txt $OUT/earn-report.txt (screenshots alongside)"
|
|
exit $status
|