Game Pass tier prices = InstantAdPay one-click packages (Marty 2026-10-25): Explorer $20 (was 19.99), Champion $50 (was 39.99), Sovereign $100 (was 99.99), Legend $250 (was 249.99); weekly $5 unchanged. TIER_DEFS and the siteConfig defaults in cents 2000/5000/10000/25000, so the cheapest qualifying package is exactly the pass price (no silent overpay). A pass is still paid by one fresh package of at least the tier price. Member Games card: each tier says it comes with the $X package and its ad credits (my.js ?v=20261025pr). Admin Game Pass note, docs/GAME-PASS.md, chatbot tier fact (price = package, member keeps the package credits; still 'coming soon' while sovTiers is off). sovTiers untouched (0). QA: sov-passes-store + sov-passes-local ALL PASS with the new prices; qa member 0 bugs, qa public 0 bugs; qa/gamepass.mjs 2 date-based fails identical on the previous commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-25 13:14:29 -05:00
parent 47638ac1fe
commit b239417cc5
9 changed files with 56 additions and 46 deletions
+9 -9
View File
@@ -28,7 +28,7 @@ const B = 'http://127.0.0.1:' + PORT;
const SHOTS = process.env.SHOTS || 'D:/tmp/sov-passes'; fs.mkdirSync(SHOTS, { recursive: true });
const SOV = crypto.randomBytes(24).toString('hex'); // throwaway, never printed
const ADMIN_PW = 'localtest', ADMIN_EMAIL = 'qa-admin@example.com', MEMBER = 'qa-sov-member@example.com';
const SEED_ID = 9001, SEED_CREDITS = 1999 + 9999 + 500; // Explorer + Sovereign, then 500 left (short for a second Explorer)
const SEED_ID = 9001, SEED_CREDITS = 2000 + 10000 + 500; // Explorer + Sovereign, then 500 left (short for a second Explorer)
const DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'iap-sovpasses-')); fs.mkdirSync(path.join(DATA, 'uploads'));
let fails = 0; const ok = (c, label, extra) => { console.log((c ? 'PASS ' : 'FAIL ') + label + (extra ? ' ' + extra : '')); if (!c) fails++; };
const hide = page => page.evaluate(() => { document.querySelectorAll('.lgate,.iap-welcome,#onboardModal').forEach(m => m.hidden = true); });
@@ -77,8 +77,8 @@ try {
ok(up && /qa stub: position #9001/.test(srvLog), 'local copy up with the seeded position', '');
await api('/api/admin/site', { method: 'PATCH', data: { fraudMaxSignupsPerIpDay: 10, gamePassEnabled: '1' } }, adminH);
const site = (await api('/api/admin/site', null, adminH)).j; const sc = (site && (site.site || site)) || {};
ok(sc.sovTiers === '0' && Number(sc.gamePassExplorerPriceCredits) === 1999 && Number(sc.gamePassChampionPriceCredits) === 3999 && Number(sc.gamePassExplorerDays) === 30 && sc.passTournamentTierSales === '0', 'defaults: sovTiers 0, Explorer 1999 / Champion 3999 credits, 30 days, passTournamentTierSales 0', JSON.stringify({ sovTiers: sc.sovTiers, e: sc.gamePassExplorerPriceCredits, c: sc.gamePassChampionPriceCredits }));
ok(Number(sc.gamePassSovereignPriceCredits) === 9999 && Number(sc.gamePassSovereignDays) === 30 && sc.gamePassSovereignEnabled === '1' && Number(sc.gamePassLegendPriceCredits) === 24999 && Number(sc.gamePassLegendDays) === 365 && sc.gamePassLegendEnabled === '1' && Number(sc.gamePassPriceCredits) === 500 && Number(sc.gamePassDays) === 7, 'defaults: Sovereign 9999 / 30 days, Legend 24999 / 365 days (kill switches 1), weekly 500 / 7 unchanged', JSON.stringify({ s: [sc.gamePassSovereignPriceCredits, sc.gamePassSovereignDays], l: [sc.gamePassLegendPriceCredits, sc.gamePassLegendDays] }));
ok(sc.sovTiers === '0' && Number(sc.gamePassExplorerPriceCredits) === 2000 && Number(sc.gamePassChampionPriceCredits) === 5000 && Number(sc.gamePassExplorerDays) === 30 && sc.passTournamentTierSales === '0', 'defaults: sovTiers 0, Explorer 2000 / Champion 5000 cents ($20 / $50, 2026-10-25), 30 days, passTournamentTierSales 0', JSON.stringify({ sovTiers: sc.sovTiers, e: sc.gamePassExplorerPriceCredits, c: sc.gamePassChampionPriceCredits }));
ok(Number(sc.gamePassSovereignPriceCredits) === 10000 && Number(sc.gamePassSovereignDays) === 30 && sc.gamePassSovereignEnabled === '1' && Number(sc.gamePassLegendPriceCredits) === 25000 && Number(sc.gamePassLegendDays) === 365 && sc.gamePassLegendEnabled === '1' && Number(sc.gamePassPriceCredits) === 500 && Number(sc.gamePassDays) === 7, 'defaults: Sovereign 10000 / 30 days, Legend 25000 / 365 days (kill switches 1), weekly 500 / 7 unchanged', JSON.stringify({ s: [sc.gamePassSovereignPriceCredits, sc.gamePassSovereignDays], l: [sc.gamePassLegendPriceCredits, sc.gamePassLegendDays] }));
const hA = await signIn(ADMIN_EMAIL, 'qaadmin'), hM = await signIn(MEMBER, 'qasovm');
// 1. a member with sovTiers off: weekly only, Explorer refused
@@ -105,7 +105,7 @@ try {
await page.locator('#gpCard').screenshot({ path: path.join(SHOTS, '2-admin-member-card-weekly-only.png') }); await ctx.close(); }
// the admin portal preview: all five tiers with what each includes, every one open to the admin's own account
g = (await api('/api/admin/gamepass/preview', null, adminH)).j;
ok(g.test === true && g.email === ADMIN_EMAIL && g.tierPreview === true && g.passes.map(x => x.tier).join() === 'weekly,explorer,champion,sovereign,legend' && g.passes.map(x => x.price).join() === '500,1999,3999,9999,24999' && g.passes.every(x => x.open) && g.passes.filter(x => x.tier !== 'weekly').every(x => x.sale === false), 'GET /api/admin/gamepass/preview: all five tiers (500 / 1999 / 3999 / 9999 / 24999), open to the admin, none on sale', JSON.stringify(g.passes.map(x => [x.tier, x.price, x.open, x.sale])));
ok(g.test === true && g.email === ADMIN_EMAIL && g.tierPreview === true && g.passes.map(x => x.tier).join() === 'weekly,explorer,champion,sovereign,legend' && g.passes.map(x => x.price).join() === '500,2000,5000,10000,25000' && g.passes.map(x => x.package).join() === '5,20,50,100,250' && g.passes.every(x => x.usd === x.package) && g.passes.every(x => x.open) && g.passes.filter(x => x.tier !== 'weekly').every(x => x.sale === false), 'GET /api/admin/gamepass/preview: all five tiers (500 / 2000 / 5000 / 10000 / 25000, each price = its package), open to the admin, none on sale', JSON.stringify(g.passes.map(x => [x.tier, x.price, x.open, x.sale])));
ok((await api('/api/admin/gamepass/preview', null, hM)).status === 401 && (await api('/api/admin/gamepass/test-buy', { data: { tier: 'explorer' } }, hM)).status === 401, 'tier test endpoints refuse a member session (401)', '');
// test cancel + test comp + end, on the admin's own account
r = await api('/api/admin/gamepass/test-buy', { data: { tier: 'champion' } }, adminH);
@@ -123,7 +123,7 @@ try {
await page.fill('#adEmail', ADMIN_EMAIL); await page.click('#adSend'); await page.waitForSelector('#adVerify:not([hidden])'); await page.click('#adVerify'); await sleep(1200);
const nav = await page.$('.bo-menu [data-pane="gamepass"]'); if (nav) { await nav.click(); await page.waitForSelector('#gpTest [data-gpt-buy="explorer"]', { timeout: 10000 }).catch(() => {}); }
let txt = await page.textContent('#gpTest').catch(() => '');
ok(/Test \/ preview, admin only/.test(txt) && /hidden from members/.test(txt) && /Sovereign/.test(txt) && /Necromancer/.test(txt) && /Legend/.test(txt) && /\$249\.99/.test(txt) && /for 1 year/.test(txt) && /Archer/.test(txt) && /Druid/.test(txt) && /level cap 30/.test(txt) && /\$19\.99/.test(txt) && /Shards of Valor > Passes/.test(txt) && !/\u2014/.test(txt) && errs.length === 0, 'Admin > Game Pass > Tier test and preview: labelled test/preview, all five tiers with what each includes, no em dashes', errs.join(' | ') || (nav ? '' : 'admin nav not found'));
ok(/Test \/ preview, admin only/.test(txt) && /hidden from members/.test(txt) && /Sovereign/.test(txt) && /Necromancer/.test(txt) && /Legend/.test(txt) && /\$250 /.test(txt) && /for 1 year/.test(txt) && /Archer/.test(txt) && /Druid/.test(txt) && /level cap 30/.test(txt) && /\$20 /.test(txt) && !/\.99/.test(txt) && /Shards of Valor > Passes/.test(txt) && !/\u2014/.test(txt) && errs.length === 0, 'Admin > Game Pass > Tier test and preview: labelled test/preview, all five tiers with what each includes, no em dashes', errs.join(' | ') || (nav ? '' : 'admin nav not found'));
await page.locator('#gpTestCard').scrollIntoViewIfNeeded(); await sleep(300);
await page.locator('#gpTestCard').screenshot({ path: path.join(SHOTS, '3-admin-tier-test-panel.png') });
await page.click('#gpTest [data-gpt-buy="explorer"]'); await page.waitForSelector('#dlgOk', { timeout: 5000 });
@@ -164,7 +164,7 @@ try {
const gr = await grant({ memberId: 0, email: ADMIN_EMAIL, game: 'shardsofvalor', kind: 'daily', pol: 0.2, ref: 'qa:1' });
ok(gr.pass === true && gr.allowed === 0.2, 'polgrant: pass true (a boolean) for the Explorer holder', JSON.stringify(gr));
// 3b. Sovereign (9999 credits, 30 days) and the yearly Legend (24999, 365 days), 2026-10-22: the admin buys Sovereign through the
// 3b. Sovereign (10000 cents = $100, 30 days) and the yearly Legend (25000 = $250, 365 days), 2026-10-22: the admin buys Sovereign through the
// real charge, then is short for Legend (waiting order, $250 package) and for a second Explorer; a $250 package settles Legend.
r = await api('/api/admin/gamepass/test-buy', { data: { tier: 'sovereign' } }, adminH);
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'sovereign' && r.j.package === 100, 'admin Sovereign (sovTiers off, testing): a waiting order for a $100 package, credits untouched', JSON.stringify(r.j));
@@ -174,7 +174,7 @@ try {
r = await api('/api/admin/gamepass/test-buy', { data: { tier: 'explorer' } }, adminH);
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'explorer' && /package of \$20 or more/.test(r.j.message), 'a second Explorer -> waiting order, "package of $20 or more"', JSON.stringify({ needPay: r.j.needPay, payUrl: r.j.payUrl, msg: r.j.message }));
r = await api('/api/admin/gamepass/test-buy', { data: { tier: 'legend' } }, adminH);
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'legend' && r.j.price === 24999 && r.j.payUrl === '/my?from=gamepass&tier=legend#buy' && /package of \$250 or more/.test(r.j.message), 'Legend: waiting order, "package of $250 or more", payUrl with tier', JSON.stringify({ needPay: r.j.needPay, payUrl: r.j.payUrl, msg: r.j.message }));
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'legend' && r.j.price === 25000 && r.j.payUrl === '/my?from=gamepass&tier=legend#buy' && /package of \$250 or more/.test(r.j.message), 'Legend: waiting order, "package of $250 or more", payUrl with tier', JSON.stringify({ needPay: r.j.needPay, payUrl: r.j.payUrl, msg: r.j.message }));
let dv = (await api('/api/dev/gamepass-purchase', { data: { cents: 10000, email: ADMIN_EMAIL } })).j;
ok(dv && dv.order && dv.order.tier === 'explorer' && dv.order.until === ex.until + 30 * 86400000, 'a $100 package fulfils the waiting Explorer (extends it from its end), never Legend', JSON.stringify(dv));
g = (await api('/api/admin/gamepass/preview', null, adminH)).j;
@@ -193,8 +193,8 @@ try {
// 4. Admin > Game Pass: the tier table
const st = (await api('/api/admin/gamepass/stats', null, adminH)).j;
ok(st.tiers && st.tiers.explorer.active === 0 && st.tiers.explorer.soldTotal === 2 && st.tiers.explorer.usdTotal === 39.98 && st.tiers.explorer.waitingOrders === 0 && st.tierSales === false, 'admin stats: Explorer 2 sold ($39.98: credits + the $100 package order), not counted active (the account is at Legend); sale switch off', JSON.stringify(st.tiers.explorer));
ok(st.tiers.sovereign && st.tiers.sovereign.active === 0 && st.tiers.sovereign.soldTotal === 1 && st.tiers.sovereign.usdTotal === 99.99 && st.tiers.legend.active === 1 && st.tiers.legend.soldTotal === 1 && st.tiers.legend.usdTotal === 249.99 && st.tiers.legend.waitingOrders === 0 && st.settings.tiers.legend.days === 365 && st.settings.tiers.sovereign.sale === false, 'admin stats: Sovereign 1 sold ($99.99), Legend 1 active + 1 sold ($249.99), not on sale', JSON.stringify({ s: st.tiers.sovereign, l: st.tiers.legend }));
ok(st.tiers && st.tiers.explorer.active === 0 && st.tiers.explorer.soldTotal === 2 && st.tiers.explorer.usdTotal === 40 && st.tiers.explorer.waitingOrders === 0 && st.tierSales === false, 'admin stats: Explorer 2 sold ($40: credits + the $100 package order), not counted active (the account is at Legend); sale switch off', JSON.stringify(st.tiers.explorer));
ok(st.tiers.sovereign && st.tiers.sovereign.active === 0 && st.tiers.sovereign.soldTotal === 1 && st.tiers.sovereign.usdTotal === 100 && st.tiers.legend.active === 1 && st.tiers.legend.soldTotal === 1 && st.tiers.legend.usdTotal === 250 && st.tiers.legend.waitingOrders === 0 && st.settings.tiers.legend.days === 365 && st.settings.tiers.sovereign.sale === false, 'admin stats: Sovereign 1 sold ($100), Legend 1 active + 1 sold ($250), not on sale', JSON.stringify({ s: st.tiers.sovereign, l: st.tiers.legend }));
{ const ctx = await browser.newContext({ viewport: { width: 1280, height: 1000 } }); const page = await ctx.newPage(); const errs = []; page.on('pageerror', e => errs.push(String(e)));
await page.goto(B + '/admin', { waitUntil: 'networkidle' });
await page.fill('#adEmail', ADMIN_EMAIL); await page.click('#adSend'); await page.waitForSelector('#adVerify:not([hidden])'); await page.click('#adVerify'); await sleep(1200);
+17 -17
View File
@@ -4,7 +4,7 @@
// extend from max(now, until), side-by-side expiry, highest active tier wins, the sovTiers switch (off refuses, admin may buy),
// waiting orders per tier fulfilled by a big-enough package (each tx once, highest price first), the same caps for every tier
// (no extra POL), comp and revoke, admin stats per tier (each account once at its top tier, Central week/month). Exit 1 on failure.
// 2026-10-22: section 10 adds Sovereign (9999 / 30 days) and the yearly Legend (24999 / 365 days): rank, off-switch refusal,
// 2026-10-22: section 10 adds Sovereign (10000 / 30 days) and the yearly Legend (25000 / 365 days; prices = packages since 2026-10-25): rank, off-switch refusal,
// buy, short -> waiting order ($100 / $250 package), extend from max(now, until), kill switches, comp/revoke, flag payload, stats.
'use strict';
const fs = require('fs'); const os = require('os'); const path = require('path');
@@ -55,7 +55,7 @@ async function buyX(email, payer, now, tier, opts) {
ok(v.passes.length === 1 && v.passes[0].tier === 'weekly' && v.show === true && v.tierPreview === false, 'sovTiers off: a member sees only the weekly pass', JSON.stringify(v.passes.map(x => x.tier)));
v = gp.view('admin@x.com', T0); ok(v.passes.length === 1 && !v.tierPreview, 'the member view (GET /api/my/gamepass) is the same for the admin account: weekly only (2026-10-25)', JSON.stringify(v.passes.map(x => x.tier)));
v = gp.view('admin@x.com', T0, { preview: true }); // Admin > Game Pass > Tier test and preview
ok(v.passes.map(x => x.tier).join() === 'weekly,explorer,champion,sovereign,legend' && v.tierPreview === true && v.passes.slice(1).every(x => x.open === true) && v.passes.map(x => x.price).join() === '500,1999,3999,9999,24999' && v.passes.map(x => x.days).join() === '7,30,30,30,365' && v.passes.map(x => x.package).join() === '5,20,50,100,250', 'sovTiers off: the admin sees all five (preview), prices 500 / 1999 / 3999 / 9999 / 24999, days 7 / 30 / 30 / 30 / 365, packages $5 / $20 / $50 / $100 / $250', JSON.stringify(v.passes));
ok(v.passes.map(x => x.tier).join() === 'weekly,explorer,champion,sovereign,legend' && v.tierPreview === true && v.passes.slice(1).every(x => x.open === true) && v.passes.map(x => x.price).join() === '500,2000,5000,10000,25000' && v.passes.map(x => x.days).join() === '7,30,30,30,365' && v.passes.map(x => x.package).join() === '5,20,50,100,250', 'sovTiers off: the admin sees all five (preview), prices 500 / 2000 / 5000 / 10000 / 25000, days 7 / 30 / 30 / 30 / 365, packages $5 / $20 / $50 / $100 / $250', JSON.stringify(v.passes));
r = await buyX('admin@x.com', paid, T0, 'explorer', { preview: true });
ok(r.ok && r.tier === 'explorer' && r.until === T0 + 30 * DAY && r.days === 30, 'sovTiers off: the admin can buy Explorer (testing)', JSON.stringify(r));
r = await buyX('a@x.com', paid, T0); // tier missing = weekly
@@ -69,15 +69,15 @@ async function buyX(email, payer, now, tier, opts) {
// 3. on: each tier extends only itself; buying again extends from max(now, until)
charged = null; r = await buyX('b@x.com', async (price, label) => { charged = { price, label }; return { ok: true }; }, T0, 'explorer');
ok(r.ok && r.until === T0 + 30 * DAY && charged.price === 1999 && charged.label === 'Explorer pass (30 days)', 'sovTiers on: Explorer charges 1999 credits, 30 days', JSON.stringify(charged));
ok(r.ok && r.until === T0 + 30 * DAY && charged.price === 2000 && charged.label === 'Explorer pass (30 days)', 'sovTiers on: Explorer charges 2000 credits, 30 days', JSON.stringify(charged));
let rec = passes.get('b@x.com');
ok(rec.tiers.explorer.until === T0 + 30 * DAY && !rec.tiers.weekly && !rec.tiers.champion && rec.until === 0 && rec.bought[0].tier === 'explorer' && rec.bought[0].usd === 19.99, 'only the Explorer tier moved; legacy until (weekly) stays 0; bought row has tier + $19.99', JSON.stringify(rec));
ok(rec.tiers.explorer.until === T0 + 30 * DAY && !rec.tiers.weekly && !rec.tiers.champion && rec.until === 0 && rec.bought[0].tier === 'explorer' && rec.bought[0].usd === 20, 'only the Explorer tier moved; legacy until (weekly) stays 0; bought row has tier + $20', JSON.stringify(rec));
r = await buyX('b@x.com', paid, T0 + 10 * DAY, 'explorer');
ok(r.until === T0 + 60 * DAY, 'Explorer again while active: extends from its until (+30 days, nothing lost)', new Date(r.until).toISOString());
r = await buyX('c@x.com', paid, T0, 'champion'); ok(r.ok && r.until === T0 + 30 * DAY, 'Champion: 30 days', '');
r = await buyX('c@x.com', paid, T0 + 45 * DAY, 'champion');
ok(r.until === T0 + 75 * DAY, 'Champion again after it ended: extends from now', new Date(r.until).toISOString());
charged = null; await buyX('c2@x.com', async (price) => { charged = price; return { ok: true }; }, T0, 'champion'); ok(charged === 3999, 'Champion charges 3999 credits', String(charged));
charged = null; await buyX('c2@x.com', async (price) => { charged = price; return { ok: true }; }, T0, 'champion'); ok(charged === 5000, 'Champion charges 5000 credits', String(charged));
// 4. side by side: Champion over Explorer, then Explorer shows through; weekly underneath
await buyX('d@x.com', paid, T0, 'weekly'); // weekly to T0+7
@@ -104,7 +104,7 @@ async function buyX(email, payer, now, tier, opts) {
const ordE = r.order;
r = await buyX('p@x.com', short, T0, 'explorer'); ok(r.order === ordE, 'same tier again reuses its waiting order', '');
r = await buyX('p@x.com', short, T0, 'champion'); const ordC = r.order;
ok(r.needPay && r.order !== ordE && r.package === 50 && /package of \$50 or more/.test(r.message), 'Champion short: its own waiting order; copy names the $50 package (there is no $40 one)', r.message);
ok(r.needPay && r.order !== ordE && r.package === 50 && /package of \$50 or more/.test(r.message), 'Champion short: its own waiting order; copy names the $50 package (exactly the price since 2026-10-25)', r.message);
r = await buyX('p@x.com', short, T0, 'weekly');
ok(r.payUrl === '/my?from=gamepass#buy' && /package of \$5 or more/.test(r.message), 'weekly short: payUrl and copy exactly as before', r.payUrl);
let ev = await gp.onEvent({ type: 'Purchase', priceCents: 500, tx: '0xa1', ts: T0 + 60000, devEmail: 'p@x.com' });
@@ -148,7 +148,7 @@ async function buyX(email, payer, now, tier, opts) {
await buyX('s5@x.com', short, NOW, 'champion');
const st = gp.adminStats(NOW); const S = st.tiers;
ok(S.weekly.active === 1 && S.explorer.active === 2 && S.champion.active === 1, 'active counts each account once at its top tier (s1 = explorer, not weekly)', JSON.stringify({ w: S.weekly.active, e: S.explorer.active, c: S.champion.active }));
ok(S.weekly.soldWeek === 2 && S.explorer.soldWeek === 0 && S.explorer.soldMonth === 1 && S.champion.soldWeek === 1 && S.champion.soldMonth === 1 && S.champion.soldTotal === 2 && S.champion.usdTotal === 79.98, 'Central week (from Mon 00:00) and month (from the 1st 00:00) boundaries', JSON.stringify({ w: [S.weekly.soldWeek, S.weekly.soldMonth], e: [S.explorer.soldWeek, S.explorer.soldMonth], c: [S.champion.soldWeek, S.champion.soldMonth, S.champion.soldTotal, S.champion.usdTotal] }));
ok(S.weekly.soldWeek === 2 && S.explorer.soldWeek === 0 && S.explorer.soldMonth === 1 && S.champion.soldWeek === 1 && S.champion.soldMonth === 1 && S.champion.soldTotal === 2 && S.champion.usdTotal === 100, 'Central week (from Mon 00:00) and month (from the 1st 00:00) boundaries', JSON.stringify({ w: [S.weekly.soldWeek, S.weekly.soldMonth], e: [S.explorer.soldWeek, S.explorer.soldMonth], c: [S.champion.soldWeek, S.champion.soldMonth, S.champion.soldTotal, S.champion.usdTotal] }));
ok(S.champion.renewals30d === 1 && S.weekly.renewals30d === 0, 'renewals30d: a second Champion purchase by a Champion holder', String(S.champion.renewals30d));
ok(S.weekly.expiring7d === 2 && S.explorer.comped === 1 && S.champion.waitingOrders === 1, 'expiring7d (weekly passes ending in 7 Central days), comped, waiting orders per tier', JSON.stringify({ exp: S.weekly.expiring7d, comped: S.explorer.comped, wait: S.champion.waitingOrders }));
ok(st.passes.active === 4 && st.passes.soldTotal === 5 && st.passes.comped === 1 && st.passes.waitingOrders === 1, 'the existing all-tier passes block still adds up', JSON.stringify(st.passes));
@@ -158,13 +158,13 @@ async function buyX(email, payer, now, tier, opts) {
ok(rows.sales === 2 && rows.salesUsd === 10, 'passTournamentTierSales off: only the 2 weekly sales ($10) feed the pool', JSON.stringify({ sales: rows.sales, usd: rows.salesUsd }));
SC.passTournamentTierSales = '1';
const rows2 = await gp.runTournament(Date.parse('2026-11-03T18:00:00Z'), { force: true });
ok(rows2.sales === 3 && rows2.salesUsd === 49.99, 'passTournamentTierSales on: the Champion renewal ($39.99) is added', JSON.stringify({ sales: rows2.sales, usd: rows2.salesUsd }));
// 10. Sovereign ($99.99 / 30 days) and Legend ($249.99 / 365 days), 2026-10-22 (Dallas's structure)
ok(rows2.sales === 3 && rows2.salesUsd === 60, 'passTournamentTierSales on: the Champion renewal ($50) is added', JSON.stringify({ sales: rows2.sales, usd: rows2.salesUsd }));
// 10. Sovereign ($100 / 30 days) and Legend ($250 / 365 days), 2026-10-22 (Dallas's structure); prices = packages since 2026-10-25
for (const k of [...passes.keys()]) passes.delete(k); for (const k of [...orders.keys()]) orders.delete(k);
delete SC.passTournamentTierSales; SC.sovTiers = '0';
ok(gp.TIERS.join() === 'weekly,explorer,champion,sovereign,legend' && gp.TIER_NAMES.sovereign === 'Sovereign' && gp.TIER_NAMES.legend === 'Legend', 'rank: weekly < explorer < champion < sovereign < legend; names from the one table', gp.TIERS.join());
const C0 = gp.cfg().tiers;
ok(C0.weekly.price === 500 && C0.weekly.days === 7 && C0.explorer.price === 1999 && C0.champion.price === 3999 && C0.sovereign.price === 9999 && C0.sovereign.days === 30 && C0.legend.price === 24999 && C0.legend.days === 365 && !C0.sovereign.sale && !C0.legend.sale && C0.weekly.sale, 'defaults: weekly 500/7 (unchanged), Sovereign 9999/30, Legend 24999/365; sovTiers off = not on sale, weekly on sale', JSON.stringify(C0));
ok(C0.weekly.price === 500 && C0.weekly.days === 7 && C0.explorer.price === 2000 && C0.champion.price === 5000 && C0.sovereign.price === 10000 && C0.sovereign.days === 30 && C0.legend.price === 25000 && C0.legend.days === 365 && !C0.sovereign.sale && !C0.legend.sale && C0.weekly.sale, 'defaults: weekly 500/7 (unchanged), Sovereign 10000/30, Legend 25000/365; sovTiers off = not on sale, weekly on sale', JSON.stringify(C0));
// off switch: members refused, nothing written, nothing charged; the weekly pass still sells
charged = null; const spy = async (price, label) => { charged = { price, label }; return { ok: true }; };
r = await buyX('m@x.com', spy, T0, 'sovereign'); ok(r.error === 'The Sovereign pass is not open yet.' && !charged, 'sovTiers off: Sovereign refused for a member, nothing charged', JSON.stringify(r));
@@ -174,15 +174,15 @@ async function buyX(email, payer, now, tier, opts) {
v = gp.view('m@x.com', T0); ok(v.passes.map(x => x.tier).join() === 'weekly' && !v.tierPreview, 'sovTiers off: the member still sees only the weekly pass', JSON.stringify(v.passes.map(x => x.tier)));
charged = null; r = await buyX('m@x.com', spy, T0); ok(r.ok && r.tier === 'weekly' && charged.price === 500 && charged.label === 'Game Pass (7 days)' && r.until === T0 + 7 * DAY, 'sovTiers off: the weekly Game Pass sells exactly as before', JSON.stringify(charged));
charged = null; r = await buyX('adm@x.com', spy, T0, 'legend', { preview: true });
ok(r.ok && r.tier === 'legend' && r.days === 365 && r.until === T0 + 365 * DAY && charged.price === 24999 && charged.label === 'Legend pass (365 days)', 'sovTiers off: the admin can buy Legend (testing): 24999 credits, 365 days', JSON.stringify({ r, charged }));
ok(r.ok && r.tier === 'legend' && r.days === 365 && r.until === T0 + 365 * DAY && charged.price === 25000 && charged.label === 'Legend pass (365 days)', 'sovTiers off: the admin can buy Legend (testing): 25000 credits, 365 days', JSON.stringify({ r, charged }));
SC.sovTiers = '1';
// buy with enough purchased credits
charged = null; r = await buyX('sv@x.com', spy, T0, 'sovereign');
ok(r.ok && r.tier === 'sovereign' && r.days === 30 && r.until === T0 + 30 * DAY && charged.price === 9999 && charged.label === 'Sovereign pass (30 days)', 'sovTiers on: Sovereign charges 9999 credits, 30 days', JSON.stringify(charged));
ok(r.ok && r.tier === 'sovereign' && r.days === 30 && r.until === T0 + 30 * DAY && charged.price === 10000 && charged.label === 'Sovereign pass (30 days)', 'sovTiers on: Sovereign charges 10000 credits, 30 days', JSON.stringify(charged));
rec = passes.get('sv@x.com');
ok(rec.tiers.sovereign.until === T0 + 30 * DAY && !rec.tiers.weekly && !rec.tiers.legend && rec.until === 0 && rec.bought[0].tier === 'sovereign' && rec.bought[0].usd === 99.99 && rec.bought[0].cents === 9999 && rec.bought[0].via === 'package', 'only the Sovereign tier moved; bought row has tier, $99.99, a 9999-cent package', JSON.stringify(rec));
ok(rec.tiers.sovereign.until === T0 + 30 * DAY && !rec.tiers.weekly && !rec.tiers.legend && rec.until === 0 && rec.bought[0].tier === 'sovereign' && rec.bought[0].usd === 100 && rec.bought[0].cents === 10000 && rec.bought[0].via === 'package', 'only the Sovereign tier moved; bought row has tier, $100, a 10000-cent package', JSON.stringify(rec));
charged = null; r = await buyX('lg@x.com', spy, T0, 'legend');
ok(r.ok && r.until === T0 + 365 * DAY && charged.price === 24999 && passes.get('lg@x.com').bought[0].usd === 249.99, 'sovTiers on: Legend charges 24999 credits, a YEAR (365 days), $249.99 row', JSON.stringify(charged));
ok(r.ok && r.until === T0 + 365 * DAY && charged.price === 25000 && passes.get('lg@x.com').bought[0].usd === 250, 'sovTiers on: Legend charges 25000 credits, a YEAR (365 days), $250 row', JSON.stringify(charged));
// extend: from max(now, until)
r = await buyX('lg@x.com', paid, T0 + 100 * DAY, 'legend'); ok(r.until === T0 + 730 * DAY, 'Legend again while active: +365 days from its end (nothing lost)', new Date(r.until).toISOString());
r = await buyX('sv@x.com', paid, T0 + 10 * DAY, 'sovereign'); ok(r.until === T0 + 60 * DAY, 'Sovereign again while active: +30 days from its end', new Date(r.until).toISOString());
@@ -203,7 +203,7 @@ async function buyX(email, payer, now, tier, opts) {
ok(gs.allowed === 1.5 && gs.pass === true, 'polgrant: a Legend holder is capped at 1.50 on daily play, pass: true (a boolean)', JSON.stringify(gs));
// waiting orders: a $50 package does not cover Sovereign, $100 does; $100 does not cover Legend, $250 does
r = await buyX('wo@x.com', short, T0, 'sovereign');
ok(r.needPay && r.tier === 'sovereign' && r.payUrl === '/my?from=gamepass&tier=sovereign#buy' && r.package === 100 && /package of \$100 or more/.test(r.message) && r.price === 9999, 'Sovereign short: waiting order, payUrl with tier, "$100 package"', r.message);
ok(r.needPay && r.tier === 'sovereign' && r.payUrl === '/my?from=gamepass&tier=sovereign#buy' && r.package === 100 && /package of \$100 or more/.test(r.message) && r.price === 10000, 'Sovereign short: waiting order, payUrl with tier, "$100 package"', r.message);
const ordS = r.order;
r = await buyX('wo@x.com', short, T0, 'legend'); const ordL = r.order;
ok(r.needPay && r.order !== ordS && r.package === 250 && /package of \$250 or more/.test(r.message) && r.payUrl === '/my?from=gamepass&tier=legend#buy', 'Legend short: its own waiting order, "$250 package"', r.message);
@@ -242,14 +242,14 @@ async function buyX(email, payer, now, tier, opts) {
const st2 = gp.adminStats(T0 + DAY); const S2 = st2.tiers;
ok(Object.keys(S2).join() === 'weekly,explorer,champion,sovereign,legend' && S2.sovereign.name === 'Sovereign' && S2.legend.name === 'Legend', 'admin stats carry all five tiers by name', Object.keys(S2).join());
ok(S2.legend.active >= 3 && S2.legend.comped === 1 && S2.sovereign.comped === 1 && S2.legend.soldTotal >= 4 && S2.sovereign.soldTotal >= 4, 'admin stats: Legend/Sovereign active, sold and comped counted', JSON.stringify({ l: S2.legend, s: S2.sovereign }));
ok(st2.settings.tiers.legend.days === 365 && st2.settings.tiers.sovereign.price === 9999, 'admin settings block shows Legend 365 days, Sovereign 9999', '');
ok(st2.settings.tiers.legend.days === 365 && st2.settings.tiers.sovereign.price === 10000, 'admin settings block shows Legend 365 days, Sovereign 10000', '');
// tournament: Legend/Sovereign sales stay out of the pool unless passTournamentTierSales
for (const k of [...passes.keys()]) passes.delete(k);
const wkT = Date.parse('2026-11-10T18:00:00Z');
await buyX('t1@x.com', paid, wkT, 'weekly'); await buyX('t2@x.com', paid, wkT, 'legend'); await buyX('t3@x.com', paid, wkT, 'sovereign');
let tr = await gp.runTournament(wkT, { force: true }); ok(tr.sales === 1 && tr.salesUsd === 5, 'passTournamentTierSales default off: Sovereign/Legend sales do not feed the pool', JSON.stringify({ s: tr.sales, u: tr.salesUsd }));
SC.passTournamentTierSales = '1';
tr = await gp.runTournament(wkT, { force: true }); ok(tr.sales === 3 && tr.salesUsd === 354.98, 'passTournamentTierSales on: Legend ($249.99) and Sovereign ($99.99) are added', JSON.stringify({ s: tr.sales, u: tr.salesUsd }));
tr = await gp.runTournament(wkT, { force: true }); ok(tr.sales === 3 && tr.salesUsd === 355, 'passTournamentTierSales on: Legend ($250) and Sovereign ($100) are added', JSON.stringify({ s: tr.sales, u: tr.salesUsd }));
delete SC.passTournamentTierSales;
try { fs.rmSync(dataDir, { recursive: true, force: true }); } catch (e) {}