test: audit and strengthen legacy test suite
This commit is contained in:
@@ -226,23 +226,36 @@ const buildPayload = (action: BattleSimJobPayload['action']): BattleSimJobPayloa
|
||||
});
|
||||
|
||||
describe('battle sim processor', () => {
|
||||
it('simulates battles and returns summary', () => {
|
||||
it('returns the fixed-seed battle summary instead of only a successful shape', () => {
|
||||
const payload = buildPayload('battle');
|
||||
const result = processBattleSimJob(payload);
|
||||
|
||||
expect(result.result).toBe(true);
|
||||
expect(result.reason).toBe('success');
|
||||
expect(result.lastWarLog).toBeTruthy();
|
||||
expect(result.phase).toBeTypeOf('number');
|
||||
expect(result.attackerRice).toBeTypeOf('number');
|
||||
expect(result).toMatchObject({
|
||||
result: true,
|
||||
reason: 'success',
|
||||
datetime: '2026-01-01 00:00:00',
|
||||
avgWar: 1,
|
||||
phase: 2,
|
||||
killed: 625,
|
||||
maxKilled: 625,
|
||||
minKilled: 625,
|
||||
dead: 1000,
|
||||
maxDead: 1000,
|
||||
minDead: 1000,
|
||||
attackerRice: 65,
|
||||
defenderRice: 83,
|
||||
attackerSkills: { 부상: 1 },
|
||||
defendersSkills: [{ 회피시도: 1, 회피: 1 }],
|
||||
});
|
||||
expect(result.lastWarLog?.generalActionLog).toContain('퇴각했습니다.');
|
||||
});
|
||||
|
||||
it('returns defender order for reorder action', () => {
|
||||
it('returns the fixed defender ID order for reorder action', () => {
|
||||
const payload = buildPayload('reorder');
|
||||
const result = processBattleSimJob(payload);
|
||||
|
||||
expect(result.result).toBe(true);
|
||||
expect(result.order?.length).toBe(1);
|
||||
expect(result.order).toEqual([2]);
|
||||
});
|
||||
|
||||
it('executes crew trigger handlers in simulator battles', () => {
|
||||
|
||||
@@ -5,12 +5,13 @@ import { createTournamentAutoStartHandler } from '@sammo-ts/common';
|
||||
|
||||
import { TournamentStore } from '../src/tournament/store.js';
|
||||
import { buildTournamentKeys } from '../src/tournament/keys.js';
|
||||
import type { TournamentBetEntry, TournamentMatchEntry, TournamentParticipantEntry, TournamentState } from '../src/tournament/types.js';
|
||||
import {
|
||||
applyBattle,
|
||||
applyPreBattleStage,
|
||||
settleTournamentOutcome,
|
||||
} from '../src/tournament/worker.js';
|
||||
import type {
|
||||
TournamentBetEntry,
|
||||
TournamentMatchEntry,
|
||||
TournamentParticipantEntry,
|
||||
TournamentState,
|
||||
} from '../src/tournament/types.js';
|
||||
import { applyBattle, applyPreBattleStage, settleTournamentOutcome } from '../src/tournament/worker.js';
|
||||
import type { TurnDaemonTransport } from '../src/daemon/transport.js';
|
||||
|
||||
class MemoryRedis {
|
||||
@@ -208,7 +209,7 @@ const runTournamentToCompletion = async (options: {
|
||||
const delayTick = async (): Promise<void> => new Promise((resolve) => setTimeout(resolve, 0));
|
||||
|
||||
describe('tournament worker (in-memory)', () => {
|
||||
it('64명(상/중/하 스탯)으로 결승까지 진행된다', async () => {
|
||||
it('64명 고정 seed 대진에서 15번 참가자가 결승을 이긴다', async () => {
|
||||
const redis = new MemoryRedis();
|
||||
const store = new TournamentStore(redis, buildTournamentKeys('test'));
|
||||
const participants = createParticipants(16, 16, 32);
|
||||
@@ -219,10 +220,17 @@ describe('tournament worker (in-memory)', () => {
|
||||
const prisma = createPrismaMock({ baseSeed: 'seed' });
|
||||
const finalState = await runTournamentToCompletion({ store, prisma, baseSeed: 'seed' });
|
||||
const matches = await store.getMatches();
|
||||
const finalMatches = matches.filter((match) => match.stage === 10);
|
||||
|
||||
expect(finalState.stage).toBe(0);
|
||||
expect(finalState.winnerId).toBeDefined();
|
||||
expect(matches.some((match) => match.stage === 10 && match.winnerId)).toBe(true);
|
||||
expect(finalState.winnerId).toBe(15);
|
||||
expect(finalMatches).toHaveLength(1);
|
||||
expect(finalMatches[0]).toMatchObject({
|
||||
attackerId: 15,
|
||||
defenderId: 1,
|
||||
winnerId: 15,
|
||||
lastEnergy: { attacker: -90, defender: -92 },
|
||||
});
|
||||
});
|
||||
|
||||
it('우승 결과에 따라 베팅 정산 명령이 생성된다', async () => {
|
||||
|
||||
Reference in New Issue
Block a user