Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

test(arena): tighten the tournament route assertions

nirholas39f9d30f3c61
diff --git a/tests/arena-tournament-api.test.js b/tests/arena-tournament-api.test.js
index d2ec33b26..ea5fa47e1 100644
--- a/tests/arena-tournament-api.test.js
+++ b/tests/arena-tournament-api.test.js
@@ -1,4 +1,4 @@
-// Two guards on the Social Trading Arena's HTTP surface.
+// Three guards on the Social Trading Arena's HTTP surface.
//
// 1. ROUTING. Filesystem routing matches a `[param].js` file only on the LAST
// path segment, so `api/tournaments/[id].js` answered /api/tournaments/:id
@@ -111,3 +111,34 @@ describe('threeToAtomics', () => {
expect(threeToAtomics(undefined, 6)).toBeNull();
});
});
+
+describe('joinTournament re-entry', () => {
+ beforeEach(() => {
+ db.queries.length = 0;
+ db.conflict = true;
+ });
+
+ it('reactivates an entry the user had withdrawn', async () => {
+ const { entry, created } = await joinTournament({ tournamentId: 't1', agentId: 'a1', wallet: 'W1', snapshot: {} });
+
+ expect(created).toBe(false);
+ expect(entry).toMatchObject({ agent_id: 'a1', status: 'active' });
+ expect(db.queries.some((q) => /update tournament_entries[\s\S]*status = 'active'/i.test(q))).toBe(true);
+ });
+
+ it('only revives a withdrawn entry, never a disqualified one', async () => {
+ await joinTournament({ tournamentId: 't1', agentId: 'a1', wallet: null, snapshot: {} });
+ const update = db.queries.find((q) => /update tournament_entries/i.test(q));
+
+ expect(update).toMatch(/status = 'withdrawn'/);
+ expect(update).not.toMatch(/disqualified/);
+ });
+
+ it('leaves a first-time entry on the insert path', async () => {
+ db.conflict = false;
+ const { created } = await joinTournament({ tournamentId: 't1', agentId: 'a1', wallet: 'W1', snapshot: {} });
+
+ expect(created).toBe(true);
+ expect(db.queries.some((q) => /update tournament_entries/i.test(q))).toBe(false);
+ });
+});