31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { describe, it, expect, beforeAll } from 'vitest';
|
|
import { freshPlayer, loadArtifact, withReadRetry } from './_setup/harness.js';
|
|
import type { SeedArtifact } from './_setup/types.js';
|
|
|
|
describe('e2e-prod: leaderboards', () => {
|
|
let artifact: SeedArtifact;
|
|
beforeAll(() => {
|
|
artifact = loadArtifact();
|
|
});
|
|
|
|
it('submits a score and sees it in the ranking', async () => {
|
|
const client = await freshPlayer(artifact);
|
|
const me = (await client.player.reload()).player?.id;
|
|
expect(me).toBeTruthy();
|
|
|
|
const lb = client.leaderboards.findBySlug(artifact.leaderboard.slug);
|
|
const score = 4242;
|
|
await lb.submit(score);
|
|
|
|
const entries = await withReadRetry(
|
|
() => lb.list(50),
|
|
(list) => list.some((e) => e.playerId === me),
|
|
);
|
|
const mine = entries.find((e) => e.playerId === me);
|
|
expect(mine).toBeDefined();
|
|
// int64 fields (score, rank) serialize as JSON strings via protojson — coerce to number.
|
|
expect(Number(mine?.score)).toBe(score);
|
|
expect(Number(mine?.rank ?? 0)).toBeGreaterThanOrEqual(1);
|
|
});
|
|
});
|