v1.0.0: players table + migration from singleton account (ISS-105)
CI / build + unit + e2e (pull_request) Successful in 14m25s

This commit is contained in:
2026-09-24 14:26:34 +00:00
parent 837aa60a7d
commit b2034ebc52
21 changed files with 258 additions and 166 deletions
+5 -6
View File
@@ -2,7 +2,7 @@ import fs from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
import * as schema from '@/lib/db/schema';
import { getLocalPlayer, updateLocalPlayerEconomy } from '@/lib/db/localPlayer';
import { getGameDb } from '@/lib/db/client';
import { PLANE_TYPES } from '@/lib/game/catalog';
import { POST } from './route';
@@ -38,14 +38,13 @@ describe('POST /api/market/buy-plane', () => {
expect(((await res.json()) as { error: string }).error).toMatch(/insufficient funds/i);
// Cash untouched by the failed attempt.
const account = (await (await getGameDb()).db.select().from(schema.account))[0];
expect(account.cash).toBe(20_000);
expect((await getLocalPlayer(await getGameDb())).cash).toBe(20_000);
});
it('deducts the full price and adds a full-tank plane at EDDF to the snapshot', async () => {
const { db } = await getGameDb();
// Single-row account table — top up cash so the purchase can succeed.
await db.update(schema.account).set({ cash: 500_000 });
const inst = await getGameDb();
// Local player row — top up cash so the purchase can succeed.
await updateLocalPlayerEconomy(inst, { cash: 500_000 });
const res = await post({ model: 'atr72' });
expect(res.status).toBe(200);