Game Pass tier testing moves to Admin > Game Pass (Marty 2026-10-25): the member Games card shows every account, the admin's included, exactly what a member sees (weekly pass only while sovTiers is off; a holder sees the tier they hold). The /my admin preview note and the admin bypass on GET /api/my/gamepass and POST /api/my/gamepass/buy are gone. New Admin > Game Pass > Tier test and preview card (labelled TEST / PREVIEW): all five tiers as members will see them with on-sale/hidden chips and the admin's own status, Test buy (real waiting order fulfilled by a fresh package), Cancel test order, Give my account (test comp, no sale), End. New admin-only routes GET /api/admin/gamepass/preview, POST /api/admin/gamepass/test-buy | test-cancel | test-comp, always on the signed-in admin's own account. sovTiers untouched. QA: sov-passes-local + store reworked to the new flow (all pass); my.js and admin.js ?v= bumped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+55
-26
@@ -10,6 +10,9 @@
|
||||
// fresh package purchase (faked locally with /api/dev/gamepass-purchase), and the card sends the member to Buy credits.
|
||||
// 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.
|
||||
// 2026-10-25 (Marty): no admin-only tier UI on the member card. The ADMIN_EMAIL account gets the member view on /my (weekly only,
|
||||
// hidden-tier buys refused there too); every tier test runs from Admin > Game Pass > Tier test and preview (/api/admin/gamepass/preview,
|
||||
// test-buy, test-cancel, test-comp), always on the admin's own account. A holder of a tier sees it on the card like any member.
|
||||
import crypto from 'node:crypto';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
@@ -91,32 +94,58 @@ try {
|
||||
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)
|
||||
// 2. the admin account on /my gets the MEMBER view (2026-10-25): weekly only, no preview note, hidden tiers refused on the member route
|
||||
g = (await api('/api/my/gamepass', null, hA)).j;
|
||||
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);
|
||||
ok(g.passes && g.passes.length === 1 && g.passes[0].tier === 'weekly' && !g.tierPreview, 'admin on /my, sovTiers off: the member view, weekly only, no preview', JSON.stringify((g.passes || []).map(x => x.tier)));
|
||||
r = await api('/api/my/gamepass/buy', { data: { tier: 'explorer' } }, hA);
|
||||
ok(r.status === 400 && r.j.error === 'The Explorer pass is not open yet.', 'admin on the member route: Explorer refused like any member (tests moved to Admin > Game Pass)', JSON.stringify(r.j));
|
||||
{ const { page, errs, ctx } = await pageFor(hA); await page.goto(B + '/my#passes'); await page.waitForSelector('#gpCard:not([hidden]) #gpBuy', { 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());
|
||||
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') });
|
||||
ok(!/Explorer|Champion|Sovereign|Legend|Admin preview/.test(txt) && errs.length === 0, 'admin /my Games card: the weekly card a member sees, no tier boxes, no admin preview note', errs.join(' | '));
|
||||
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((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);
|
||||
ok(r.status === 200 && r.j.needPay && r.j.tier === 'champion' && r.j.email === ADMIN_EMAIL && r.j.package === 50, 'test-buy Champion: a waiting order for a $50 package on the admin account', JSON.stringify(r.j));
|
||||
r = await api('/api/admin/gamepass/test-cancel', { data: { tier: 'champion' } }, adminH);
|
||||
g = (await api('/api/admin/gamepass/preview', null, adminH)).j;
|
||||
ok(r.j.ok && r.j.order && !g.passes.find(x => x.tier === 'champion').waiting, 'test-cancel drops the Champion test order', JSON.stringify(r.j));
|
||||
r = await api('/api/admin/gamepass/test-comp', { data: { tier: 'champion' } }, adminH);
|
||||
ok(r.j.ok && r.j.tier === 'champion' && r.j.email === ADMIN_EMAIL && r.j.until > Date.now(), 'test-comp Champion starts one period on the admin account at once', JSON.stringify(r.j));
|
||||
r = await api('/api/admin/gamepass/revoke', { data: { email: ADMIN_EMAIL, tier: 'champion', why: 'admin tier test' } }, adminH);
|
||||
g = (await api('/api/my/gamepass', null, hA)).j;
|
||||
ok(r.j.ok && !g.active && g.passes.length === 1, 'ending the test Champion puts the admin card back to the weekly member view', JSON.stringify({ a: g.active, rows: g.passes.map(x => x.tier) }));
|
||||
{ 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.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'));
|
||||
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 });
|
||||
await page.screenshot({ path: path.join(SHOTS, '3b-admin-confirm-test-explorer.png') });
|
||||
await page.click('#dlgOk');
|
||||
await page.waitForFunction(() => /#buy/.test(location.hash) || !!document.querySelector('.pane.on#pane-buy, [data-pane="buy"].on'), null, { timeout: 10000 }).catch(() => {});
|
||||
await sleep(800);
|
||||
ok(errs.length === 0, 'Get Explorer: no page errors, the member is sent to buy a package', page.url() + ' ' + errs.join(' | '));
|
||||
await page.screenshot({ path: path.join(SHOTS, '4-admin-sent-to-buy.png') });
|
||||
let g1 = (await api('/api/my/gamepass', null, hA)).j; const ex1 = g1.passes.find(x => x.tier === 'explorer');
|
||||
ok(!g1.active && ex1 && ex1.waiting === true && !ex1.active, 'the click opened a waiting Explorer order; nothing active yet', JSON.stringify(ex1));
|
||||
ok(!/gamepass bought with credits/.test(srvLog), 'no credit charge: the seeded purchased credits were not spent on the pass', '');
|
||||
const dv0 = (await api('/api/dev/gamepass-purchase', { data: { cents: 2000, email: ADMIN_EMAIL } })).j;
|
||||
ok(dv0 && dv0.order && dv0.order.tier === 'explorer', 'a fresh $20 package fulfils the Explorer order', JSON.stringify(dv0));
|
||||
await page.goto(B + '/my#passes'); await page.waitForFunction(() => /Explorer active/.test((document.getElementById('gpCard') || {}).textContent || ''), null, { timeout: 15000 }).catch(() => {});
|
||||
await page.waitForFunction(() => /test order waiting for a \$20 package/.test((document.getElementById('gpTest') || {}).textContent || ''), null, { timeout: 10000 }).catch(() => {});
|
||||
txt = await page.textContent('#gpTest').catch(() => '');
|
||||
ok(/test order waiting for a \$20 package/.test(txt) && errs.length === 0, 'Test buy Explorer from the admin panel: the card shows the waiting test order', errs.join(' | '));
|
||||
await page.locator('#gpTestCard').screenshot({ path: path.join(SHOTS, '4-admin-test-order-waiting.png') }); await ctx.close(); }
|
||||
let g1 = (await api('/api/admin/gamepass/preview', null, adminH)).j; const ex1 = g1.passes.find(x => x.tier === 'explorer');
|
||||
ok(!g1.active && ex1 && ex1.waiting === true && !ex1.active, 'the click opened a waiting Explorer order; nothing active yet', JSON.stringify(ex1));
|
||||
ok(!/gamepass bought with credits/.test(srvLog), 'no credit charge: the seeded purchased credits were not spent on the pass', '');
|
||||
const dv0 = (await api('/api/dev/gamepass-purchase', { data: { cents: 2000, email: ADMIN_EMAIL } })).j;
|
||||
ok(dv0 && dv0.order && dv0.order.tier === 'explorer', 'a fresh $20 package fulfils the Explorer test order', JSON.stringify(dv0));
|
||||
// a HOLDER sees the tier on the member card the way any member holding it would (no preview note, nothing they cannot buy listed)
|
||||
{ const { page, errs, ctx } = await pageFor(hA); await page.goto(B + '/my?from=shardsofvalor#passes');
|
||||
await page.waitForFunction(() => /Explorer active/.test((document.getElementById('gpCard') || {}).textContent || ''), null, { timeout: 15000 }).catch(() => {});
|
||||
await sleep(600); await hide(page);
|
||||
const after = await page.textContent('#gpCard');
|
||||
ok(/Explorer active/.test(after) && errs.length === 0, 'after the package the card shows Explorer active (Central date)', errs.join(' | '));
|
||||
await page.locator('#gpCard').screenshot({ path: path.join(SHOTS, '5-admin-explorer-active.png') }); await ctx.close(); }
|
||||
ok(/#games/.test(page.url()), 'the Shards of Valor link (#passes) lands on the pass card, not the Buy pane', page.url());
|
||||
ok(/Explorer active/.test(after) && /never better than gear players can earn/.test(after) && /main story of Shards of Valor is free/.test(after) && !/Admin preview|Champion|Sovereign|Legend/.test(after) && !/\u2014/.test(after) && errs.length === 0, 'holder card: Explorer active, weekly + Explorer only, no admin preview, no em dashes', errs.join(' | '));
|
||||
await page.locator('#gpCard').screenshot({ path: path.join(SHOTS, '5-admin-explorer-active-holder-card.png') }); await ctx.close(); }
|
||||
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() }));
|
||||
@@ -137,18 +166,18 @@ try {
|
||||
|
||||
// 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);
|
||||
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));
|
||||
let dvS = (await api('/api/dev/gamepass-purchase', { data: { cents: 10000, email: ADMIN_EMAIL } })).j;
|
||||
ok(dvS && dvS.order && dvS.order.tier === 'sovereign' && Math.abs(dvS.order.until - (Date.now() + 30 * 86400000)) < 120000, 'a fresh $100 package fulfils Sovereign: 30 days', JSON.stringify(dvS));
|
||||
ok(!/gamepass bought with credits/.test(srvLog), 'still no credit charge anywhere', '');
|
||||
r = await api('/api/my/gamepass/buy', { data: { tier: 'explorer' } }, hA);
|
||||
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/my/gamepass/buy', { data: { tier: 'legend' } }, hA);
|
||||
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 }));
|
||||
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;
|
||||
g = (await api('/api/admin/gamepass/preview', null, adminH)).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));
|
||||
|
||||
Reference in New Issue
Block a user