Files
instantadpay/qa/sov-passes-stub.cjs
martbost 0688bdeb72 Pass tiers: Explorer ($20/30 days) and Champion ($40/30 days) beside the weekly Game Pass, behind sovTiers (default off, admin-only preview)
Islands and looks in Shards of Valor, never power and never more POL: every tier gets exactly the weekly pass caps and polgrant
still answers pass: true. Per-tier expiry side by side (record.tiers, legacy until mirrors weekly, lazy migration); flag() adds
tier (highest active) and tiers; hand-off token gamePass { active, until, tier }; /api/partner/player pass { active, until, tier,
tiers }. Buy { tier } with purchased credits or a waiting order per tier that a big-enough package fulfils (highest price first,
each tx once). No auto-renew, no proration. Admin: per-tier stats (Central week/month), comp per tier, end-a-tier (refund).
Tournament pool keeps weekly sales only unless passTournamentTierSales. Member card shows three tiers; /my#passes opens it.
Tests: qa/sov-passes-store.cjs, qa/sov-passes-local.mjs (bash qa/run.sh sov-passes). Cache tags my.js/admin.js 20261018tiers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 14:46:51 -05:00

20 lines
1.4 KiB
JavaScript

// LOCAL TESTS ONLY (qa/sov-passes-local.mjs preloads it with `node -r`): seeds purchased-grade credits on one fake position so the
// REAL ads.gamePurchase(purchasedOnly) path can be exercised without a chain. Refuses to load in production.
// QA_SEED_EMAIL the account that owns the position (gets memberId QA_SEED_ID on its sessions)
// QA_SEED_ID the fake position's member id
// QA_SEED_CREDITS the on-chain credit balance that position reports
'use strict';
if (process.env.NODE_ENV === 'production') throw new Error('qa/sov-passes-stub.cjs must never load in production');
const path = require('path');
const SITE = path.resolve(__dirname, '..');
const chain = require(path.join(SITE, 'chain.js'));
const auth = require(path.join(SITE, 'auth.js'));
const EMAIL = String(process.env.QA_SEED_EMAIL || '').toLowerCase(), ID = Number(process.env.QA_SEED_ID) || 0, CREDITS = Number(process.env.QA_SEED_CREDITS) || 0;
const origBal = chain.creditBalance;
chain.creditBalance = async (id, type) => (ID && Number(id) === ID) ? CREDITS : origBal(id, type);
const origMember = chain.member;
chain.member = async id => (ID && Number(id) === ID) ? null : origMember(id);
const origRefresh = auth.refreshMemberId;
auth.refreshMemberId = async sess => (sess && EMAIL && String(sess.email || '').toLowerCase() === EMAIL) ? ID : origRefresh(sess);
console.log('qa stub: position #' + ID + ' holds ' + CREDITS + ' purchased credits for ' + EMAIL);