Files
wownerogue/test/productGrants.test.js
T
jwinterm a62eefb47b fix: resolve security/correctness review + AAA graphics pass
Backend (Tier 0/1/3): single-payout double-pay -> needs_review; admin-retry tx_hash guard; UNIQUE index on games.payment_id (migration 023) + atomic claim; reconnect no longer resets block-timeout; completeGame keys on user_id+dungeon_seed (not socket_id); token-gated /api/user/:socketId/* endpoints; payout min/max enforcement; orphaned-active-game boot recovery; sessionManager cleanup FK fix; XFF rightmost-hop; global uncaughtException/unhandledRejection guard; server binds 127.0.0.1; provably-fair client-seed (HMAC) + RNG [0,1) bound; difficulty preset ranges reach the digger; chat no longer leaks full socket.id; removed dangerous-keyword SQL theater.

Match mode (Tier 2, still MATCH_ENABLED-gated): fixed match_queue/match_move crash paths + scheduler dead-code + leaked ceiling timer; pot collected before start with abort+refund; BigInt/basis-point fee math, capped payout; no-address winner claimable; winnerId==placement[0]; finalize schema + payout-first isolation; reconnect re-key with ownership; refunds on all cancel paths; real countdown; map/timer cleanup. +16 tests.

Graphics: new overlay FX layer (torch light, vignette, embers, sparkle/burst/flash/shake, self-suspending rAF); gameplay juice; atmospheric screens; CSS design-token chrome with framed modals; richer Kenney tile renderer; imported Kenney dungeon/interior sheets + fx particles.

Verification: 45 suites / 312 tests pass; 40 changed JS files parse; 20 server modules load clean; no regressions.
2026-07-09 17:46:58 -04:00

45 lines
1.3 KiB
JavaScript

const ProductGrants = require('../src/payments/productGrants');
describe('product grants', () => {
test('derives credit grants from credit package fields when grants are absent', () => {
const grants = ProductGrants.normalizeProductGrants({ id: 'small', credits: 10, bonus: 2 });
expect(grants).toMatchObject({
credits: 12,
packs: [],
premiumLevel: null
});
});
test('normalizes bundled pack grants and premium tier', () => {
const grants = ProductGrants.normalizeProductGrants({
id: 'bundle',
credits: 10,
grants: {
credits: 15,
packs: ['generated-skins', { id: 'kenney-3d-characters' }, 'bad-pack'],
premiumLevel: 'Supporter'
}
});
expect(grants.credits).toBe(15);
expect(grants.packs.map(p => p.id)).toEqual(['generated-skins', 'kenney-3d-characters']);
expect(grants.premiumLevel).toBe('supporter');
});
test('public summaries omit internal source/expiry fields', () => {
const summary = ProductGrants.publicGrantSummary({
credits: 0,
packs: [{ id: 'iso-dungeon', source: 'operator', expiresAt: '2030-01-01' }],
premiumLevel: null
});
expect(summary).toEqual({
credits: 0,
raceEntries: 0,
packs: ['iso-dungeon'],
premiumLevel: null
});
});
});