Pass tiers restructure (Dallas, Marty approved 2026-10-22): Explorer $19.99 (1999 credits) and Champion $39.99 (3999) for 30 days, new Sovereign $99.99 (9999, 30 days) and Legend $249.99 (24999, 365 days, the yearly pass). One table (gamepass.js TIER_DEFS: rank, names, settings stem, defaults, member-card perks); settings gamePassSovereign*/gamePassLegend* with kill switches; flag()/partner player/hand-off token carry sovereign/legend; buy, waiting orders ($100/$250 package copy), extend from max(now, until), comp/revoke, admin By pass tier table and comp options; chatbot tier fact says coming soon while sovTiers is off. All behind sovTiers (still 0): weekly Game Pass price, length and caps unchanged. Tests: sov-passes store + local extended (all pass), member QA 0 bugs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+41
-10
@@ -6,6 +6,8 @@
|
||||
// Explorer in the browser through the REAL ads.gamePurchase(purchasedOnly) charge; the 500 left is short for a second Explorer
|
||||
// (waiting order, $20 package copy); the Shards of Valor hand-off token and GET /api/partner/player carry tier explorer;
|
||||
// polgrant answers pass: true with the weekly pass caps; Admin > Game Pass shows the tier table. Exit 1 on any failure.
|
||||
// 2026-10-22: + Sovereign / Legend: members refused while sovTiers is off, the admin preview lists all five, the admin buys Sovereign
|
||||
// (real charge), a Legend waiting order is settled by a $250 package (a year), the token / partner player carry tier legend + tiers.
|
||||
import crypto from 'node:crypto';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
@@ -21,7 +23,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 = 2500;
|
||||
const SEED_ID = 9001, SEED_CREDITS = 1999 + 9999 + 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); });
|
||||
@@ -70,7 +72,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) === 2000 && Number(sc.gamePassChampionPriceCredits) === 4000 && Number(sc.gamePassExplorerDays) === 30 && sc.passTournamentTierSales === '0', 'defaults: sovTiers 0, Explorer 2000 / Champion 4000 credits, 30 days, passTournamentTierSales 0', JSON.stringify({ sovTiers: sc.sovTiers, e: sc.gamePassExplorerPriceCredits, c: sc.gamePassChampionPriceCredits }));
|
||||
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] }));
|
||||
const hA = await signIn(ADMIN_EMAIL, 'qaadmin'), hM = await signIn(MEMBER, 'qasovm');
|
||||
|
||||
// 1. a member with sovTiers off: weekly only, Explorer refused
|
||||
@@ -78,20 +81,24 @@ try {
|
||||
ok(g.passes && g.passes.length === 1 && g.passes[0].tier === 'weekly' && !g.tierPreview, 'member, sovTiers off: only the weekly pass is offered', JSON.stringify((g.passes || []).map(x => x.tier)));
|
||||
let r = await api('/api/my/gamepass/buy', { data: { tier: 'explorer' } }, hM);
|
||||
ok(r.status === 400 && r.j.error === 'The Explorer pass is not open yet.', 'member, sovTiers off: Explorer buy refused', JSON.stringify(r.j));
|
||||
for (const [tier, name] of [['sovereign', 'Sovereign'], ['legend', 'Legend']]) { r = await api('/api/my/gamepass/buy', { data: { tier } }, hM);
|
||||
ok(r.status === 400 && r.j.error === 'The ' + name + ' pass is not open yet.', 'member, sovTiers off: ' + name + ' buy refused', JSON.stringify(r.j)); }
|
||||
g = (await api('/api/my/gamepass', null, hM)).j; ok(!g.active && !g.waiting && g.passes.length === 1, 'the refused buys left the member with no pass and no waiting order', JSON.stringify({ a: g.active, w: g.waiting }));
|
||||
browser = await chromium.launch();
|
||||
{ const { page, errs, ctx } = await pageFor(hM); await page.goto(B + '/my#passes'); await page.waitForSelector('#gpCard:not([hidden]) #gpBuy', { timeout: 15000 });
|
||||
const txt = await page.textContent('#gpCard'); ok(!/Explorer|Champion/.test(txt) && errs.length === 0, 'member page: the weekly card as before, no Explorer/Champion text, no page errors', errs.join(' | '));
|
||||
const txt = await page.textContent('#gpCard'); ok(!/Explorer|Champion|Sovereign|Legend/.test(txt) && errs.length === 0, 'member page: the weekly card as before, no Explorer/Champion/Sovereign/Legend text, no page errors', errs.join(' | '));
|
||||
await page.locator('#gpCard').screenshot({ path: path.join(SHOTS, '1-member-weekly-only.png') }); await ctx.close(); }
|
||||
|
||||
// 2. the admin: preview of all three, buys Explorer in the browser with the seeded purchased credits (the real charge)
|
||||
g = (await api('/api/my/gamepass', null, hA)).j;
|
||||
ok(g.tierPreview === true && g.passes.map(x => x.tier).join() === 'weekly,explorer,champion', 'admin, sovTiers off: preview with all three tiers', JSON.stringify(g.passes.map(x => [x.tier, x.price, x.open])));
|
||||
ok(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', 'admin, sovTiers off: preview with all five tiers, 500 / 1999 / 3999 / 9999 / 24999', JSON.stringify(g.passes.map(x => [x.tier, x.price, x.open])));
|
||||
{ const { page, errs, ctx } = await pageFor(hA); await page.goto(B + '/my?from=shardsofvalor#passes');
|
||||
await page.waitForSelector('#gpCard [data-gp-tier="explorer"]', { timeout: 15000 }); await sleep(600); await hide(page);
|
||||
const txt = await page.textContent('#gpCard');
|
||||
ok(/never make you stronger than players who earn their gear/.test(txt) && /main story of Shards of Valor is free/.test(txt) && /Admin preview/.test(txt) && !/\u2014/.test(txt), 'tier card copy: never stronger, main story free, admin preview note, no em dashes', '');
|
||||
ok(/#games/.test(page.url()), 'the Shards of Valor link (#passes) lands on the pass card, not the Buy pane', page.url());
|
||||
await page.locator('#gpCard').screenshot({ path: path.join(SHOTS, '2-admin-preview-three-tiers.png') });
|
||||
ok(/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), 'admin preview card lists Sovereign and Legend ($249.99 for 1 year) with what each includes', '');
|
||||
await page.locator('#gpCard').screenshot({ path: path.join(SHOTS, '2-admin-preview-all-tiers.png') });
|
||||
await page.click('#gpCard [data-gp-tier="explorer"]'); await page.waitForSelector('#dlgOk', { timeout: 5000 });
|
||||
await page.screenshot({ path: path.join(SHOTS, '3-admin-confirm-explorer.png') });
|
||||
await page.click('#dlgOk');
|
||||
@@ -102,9 +109,7 @@ try {
|
||||
g = (await api('/api/my/gamepass', null, hA)).j;
|
||||
const ex = g.passes.find(x => x.tier === 'explorer');
|
||||
ok(g.active && g.tier === 'explorer' && ex.active && Math.abs(ex.until - (Date.now() + 30 * 86400000)) < 120000, 'GET /api/my/gamepass: tier explorer, 30 days', JSON.stringify({ tier: g.tier, until: ex && new Date(ex.until).toISOString() }));
|
||||
ok(/gamepass bought with credits explorer qa-admin@example.com 2000/.test(srvLog), 'paid through the real ads.gamePurchase(purchasedOnly) path, 2000 credits', '');
|
||||
r = await api('/api/my/gamepass/buy', { data: { tier: 'explorer' } }, hA);
|
||||
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'explorer' && r.j.available === 500 && /\$20 package/.test(r.j.message), 'a second Explorer: only 500 purchased credits left -> waiting order, "$20 package"', JSON.stringify({ needPay: r.j.needPay, available: r.j.available, payUrl: r.j.payUrl }));
|
||||
ok(/gamepass bought with credits explorer qa-admin@example.com 1999/.test(srvLog), 'paid through the real ads.gamePurchase(purchasedOnly) path, 1999 credits', '');
|
||||
|
||||
// 3. the Shards of Valor hand-off token and the partner player answer carry tier explorer
|
||||
const ho = await api('/api/my/shardsofvalor', null, hA);
|
||||
@@ -119,15 +124,41 @@ 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
|
||||
// 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/my/gamepass/buy', { data: { tier: 'sovereign' } }, hA);
|
||||
ok(r.status === 200 && r.j.ok && r.j.tier === 'sovereign' && r.j.days === 30 && Math.abs(r.j.until - (Date.now() + 30 * 86400000)) < 120000, 'admin buys Sovereign (sovTiers off, testing): 30 days', JSON.stringify(r.j));
|
||||
ok(/gamepass bought with credits sovereign qa-admin@example.com 9999/.test(srvLog), 'Sovereign paid through the real ads.gamePurchase(purchasedOnly) path, 9999 credits', '');
|
||||
r = await api('/api/my/gamepass/buy', { data: { tier: 'explorer' } }, hA);
|
||||
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'explorer' && r.j.available === 500 && /\$20 package/.test(r.j.message), 'a second Explorer: only 500 purchased credits left -> waiting order, "$20 package"', JSON.stringify({ needPay: r.j.needPay, available: r.j.available, payUrl: r.j.payUrl }));
|
||||
r = await api('/api/my/gamepass/buy', { data: { tier: 'legend' } }, hA);
|
||||
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'legend' && r.j.available === 500 && r.j.price === 24999 && r.j.payUrl === '/my?from=gamepass&tier=legend#buy' && /\$250 package/.test(r.j.message), 'Legend with 500 credits: waiting order, "$250 package", 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/my/gamepass', null, hA)).j;
|
||||
ok(!g.passes.find(x => x.tier === 'legend').active && g.passes.find(x => x.tier === 'legend').waiting, 'Legend still waiting after a $100 package', JSON.stringify(g.passes.find(x => x.tier === 'legend')));
|
||||
dv = (await api('/api/dev/gamepass-purchase', { data: { cents: 25000, email: ADMIN_EMAIL } })).j;
|
||||
ok(dv && dv.order && dv.order.tier === 'legend' && Math.abs(dv.order.until - (Date.now() + 365 * 86400000)) < 120000, 'a $250 package fulfils the Legend order: a year', JSON.stringify(dv));
|
||||
g = (await api('/api/my/gamepass', null, hA)).j;
|
||||
const lg = g.passes.find(x => x.tier === 'legend'), sv = g.passes.find(x => x.tier === 'sovereign');
|
||||
ok(g.active && g.tier === 'legend' && g.until === lg.until && lg.active && sv.active && lg.days === 365, 'GET /api/my/gamepass: tier legend (highest), Sovereign and Explorer still running underneath', JSON.stringify({ tier: g.tier, l: lg.until, s: sv.until }));
|
||||
const ho2 = await api('/api/my/shardsofvalor', null, hA); const t2 = new URL(ho2.headers.get('location') || 'http://x/').searchParams.get('t'); const c2 = t2 ? decode(t2) : null;
|
||||
ok(c2 && c2.gamePass && c2.gamePass.active === true && c2.gamePass.tier === 'legend' && c2.gamePass.until === lg.until, 'hand-off token: gamePass { active, until, tier: legend }', JSON.stringify(c2 && c2.gamePass));
|
||||
const pl2 = await playerOf(ADMIN_EMAIL);
|
||||
ok(pl2.status === 200 && pl2.j.pass.tier === 'legend' && pl2.j.pass.tiers.legend === lg.until && pl2.j.pass.tiers.sovereign === sv.until && pl2.j.pass.tiers.explorer === ex.until + 30 * 86400000 && pl2.j.pass.tiers.champion === null && pl2.j.caps.daily === 1.5 && pl2.j.caps.total === 5, 'GET /api/partner/player: tier legend, tiers carry sovereign + legend, weekly pass caps 1.50 / 5', JSON.stringify(pl2.j.pass));
|
||||
const gr2 = await grant({ memberId: 0, email: ADMIN_EMAIL, game: 'shardsofvalor', kind: 'daily', pol: 5, ref: 'qa:2' });
|
||||
ok(gr2.pass === true && gr2.enforced === false && gr2.allowed === 5, 'polgrant: pass true (a boolean) for the Legend holder (caps not enforced on this copy: no capsStartDate; the cap values are the player answer above)', JSON.stringify(gr2));
|
||||
|
||||
// 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 === 1 && st.tiers.explorer.soldTotal === 1 && st.tiers.explorer.usdTotal === 20 && st.tiers.explorer.waitingOrders === 1 && st.tierSales === false, 'admin stats: Explorer 1 active, 1 sold ($20), 1 waiting; sale switch off', JSON.stringify(st.tiers.explorer));
|
||||
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 }));
|
||||
{ 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);
|
||||
const nav = await page.$('.bo-menu [data-pane="gamepass"]'); if (nav) { await nav.click(); await page.waitForFunction(() => /Explorer/.test((document.getElementById('gpTiers') || {}).textContent || ''), null, { timeout: 10000 }).catch(() => {}); }
|
||||
const txt = await page.textContent('#gpTiers').catch(() => '');
|
||||
ok(/Explorer/.test(txt) && /Champion/.test(txt), 'Admin > Game Pass renders the per-tier table', errs.join(' | ') || (nav ? '' : 'admin nav not found (sign-in flow)'));
|
||||
ok(/Explorer/.test(txt) && /Champion/.test(txt) && /Sovereign/.test(txt) && /Legend/.test(txt) && /365 d/.test(txt), 'Admin > Game Pass renders the per-tier table (all five, Legend 365 d)', errs.join(' | ') || (nav ? '' : 'admin nav not found (sign-in flow)'));
|
||||
await sleep(800); await page.locator('#gpTiers').evaluate(e => e.closest('.card').scrollIntoView()); await sleep(400); await page.locator('#gpTiers').evaluate(e => e.closest('.card').id = 'gpTiersCard'); await page.locator('#gpTiersCard').screenshot({ path: path.join(SHOTS, '5-admin-gamepass-tiers.png') }); await ctx.close(); }
|
||||
} catch (e) {
|
||||
console.error('FAIL harness error', e && e.stack || e); fails++;
|
||||
|
||||
Reference in New Issue
Block a user