import { Decimal } from '@prisma/client/runtime/library';
import {
  canSelectForParlay,
  isQuarterHandicapOrTotal,
  PARLAY_MAX_LEGS,
  PARLAY_MIN_LEGS,
} from '@thebet365/shared';
import { BettingLimitsService } from '../../betting/betting-limits.service';
import { resolveSelectionCode } from '../../settlement/domain/settlement-helpers';
import {
  calculatePayout,
  calculateParlayPayout,
  settleSelection,
  type ScoreInput,
} from '../../settlement/domain/settlement-calculator';
import { resolveCashbackRateForBet } from '../cashback/cashback-rate.resolver';
import { expectAppErrorThrows, expectEqual, expectFalse, expectTrue } from './smoke-test.helpers';
import type { SmokeTestCaseMeta } from './smoke-test.types';

export type SmokeTestRunner = () => void | Promise<void>;

export type SmokeTestCaseDef = SmokeTestCaseMeta & {
  run: SmokeTestRunner;
};

const SCORE_2_1: ScoreInput = { htHome: 1, htAway: 0, ftHome: 2, ftAway: 1 };
const SCORE_0_0: ScoreInput = { htHome: 0, htAway: 0, ftHome: 0, ftAway: 0 };
const SCORE_1_1: ScoreInput = { htHome: 0, htAway: 0, ftHome: 1, ftAway: 1 };

function createBettingLimitsService() {
  const prisma = {
    systemConfig: { findUnique: async () => null },
    bet: {
      aggregate: async () => ({ _sum: { stake: new Decimal(0) } }),
    },
  };
  return new BettingLimitsService(prisma as never);
}

export const SMOKE_TEST_CASES: SmokeTestCaseDef[] = [
  // —— Settlement ——
  {
    id: 'S001',
    suite: 'settlement',
    name: '全场独赢：主胜/和局',
    uatRef: 'S001',
    description: '比分 2-1，主胜赢、和局输',
    run: () => {
      expectEqual(
        'HOME result',
        settleSelection({ marketType: 'FT_1X2', selectionCode: 'HOME', score: SCORE_2_1 }),
        'WIN',
        { market: 'FT_1X2', selection: 'HOME', score: SCORE_2_1 },
      );
      expectEqual(
        'DRAW result',
        settleSelection({ marketType: 'FT_1X2', selectionCode: 'DRAW', score: SCORE_2_1 }),
        'LOSE',
        { market: 'FT_1X2', selection: 'DRAW', score: SCORE_2_1 },
      );
    },
  },
  {
    id: 'S002',
    suite: 'settlement',
    name: '全场独赢：和局命中',
    uatRef: 'S002',
    run: () => {
      expectEqual(
        'DRAW result',
        settleSelection({ marketType: 'FT_1X2', selectionCode: 'DRAW', score: SCORE_1_1 }),
        'WIN',
        { market: 'FT_1X2', selection: 'DRAW', score: SCORE_1_1 },
      );
    },
  },
  {
    id: 'S003',
    suite: 'settlement',
    name: '半场独赢：半场主胜',
    uatRef: 'S003',
    run: () => {
      expectEqual(
        'HT HOME',
        settleSelection({ marketType: 'HT_1X2', selectionCode: 'HOME', score: SCORE_2_1 }),
        'WIN',
        { market: 'HT_1X2', ht: '1-0', ft: '2-1' },
      );
    },
  },
  {
    id: 'S004',
    suite: 'settlement',
    name: '全场单双：0-0 为双',
    uatRef: 'S004',
    run: () => {
      expectEqual(
        'EVEN',
        settleSelection({ marketType: 'FT_ODD_EVEN', selectionCode: 'EVEN', score: SCORE_0_0 }),
        'WIN',
        { score: SCORE_0_0, totalGoals: 0 },
      );
      expectEqual(
        'ODD',
        settleSelection({ marketType: 'FT_ODD_EVEN', selectionCode: 'ODD', score: SCORE_0_0 }),
        'LOSE',
        { score: SCORE_0_0, totalGoals: 0 },
      );
    },
  },
  {
    id: 'S005',
    suite: 'settlement',
    name: '波胆：2-1 精确命中',
    uatRef: 'S005',
    run: () => {
      expectEqual(
        'SCORE_2_1',
        settleSelection({
          marketType: 'FT_CORRECT_SCORE',
          selectionCode: 'SCORE_2_1',
          score: SCORE_2_1,
        }),
        'WIN',
        { score: SCORE_2_1 },
      );
    },
  },
  {
    id: 'S006',
    suite: 'settlement',
    name: '波胆：主胜其他',
    uatRef: 'S006',
    run: () => {
      const score = { htHome: 2, htAway: 0, ftHome: 5, ftAway: 0 };
      expectEqual(
        'OTHER_HOME',
        settleSelection({
          marketType: 'FT_CORRECT_SCORE',
          selectionCode: 'OTHER_HOME',
          score,
          templateScores: ['SCORE_1_0', 'SCORE_2_0'],
        }),
        'WIN',
        { score, templateScores: ['SCORE_1_0', 'SCORE_2_0'] },
      );
    },
  },
  {
    id: 'S008',
    suite: 'settlement',
    name: '下半场波胆：1-1',
    uatRef: 'S008',
    run: () => {
      expectEqual(
        'SH SCORE_1_1',
        settleSelection({
          marketType: 'SH_CORRECT_SCORE',
          selectionCode: 'SCORE_1_1',
          score: SCORE_2_1,
        }),
        'WIN',
        { shGoals: '1-1', ft: '2-1' },
      );
    },
  },
  {
    id: 'S009',
    suite: 'settlement',
    name: '让球 -1 全赢 + 派彩',
    uatRef: 'S009',
    run: () => {
      const score = { htHome: 0, htAway: 0, ftHome: 2, ftAway: 0 };
      const result = settleSelection({
        marketType: 'FT_HANDICAP',
        selectionCode: 'HOME',
        handicapLine: -1,
        score,
      });
      expectEqual('settlement', result, 'WIN', { line: -1, score });
      expectEqual('payout', calculatePayout(100, 1.85, result).toNumber(), 185, {
        stake: 100,
        odds: 1.85,
      });
    },
  },
  {
    id: 'S010',
    suite: 'settlement',
    name: '让球 -1 走水 + 退本',
    uatRef: 'S010',
    run: () => {
      const score = { htHome: 0, htAway: 0, ftHome: 1, ftAway: 0 };
      const result = settleSelection({
        marketType: 'FT_HANDICAP',
        selectionCode: 'HOME',
        handicapLine: -1,
        score,
      });
      expectEqual('settlement', result, 'PUSH', { line: -1, score });
      expectEqual('payout', calculatePayout(100, 1.85, result).toNumber(), 100, {
        stake: 100,
        odds: 1.85,
      });
    },
  },
  {
    id: 'S011',
    suite: 'settlement',
    name: '让球 -0.25 半输',
    uatRef: 'S011',
    run: () => {
      const result = settleSelection({
        marketType: 'FT_HANDICAP',
        selectionCode: 'HOME',
        handicapLine: -0.25,
        score: SCORE_0_0,
      });
      expectEqual('settlement', result, 'HALF_LOSE', { line: -0.25, score: SCORE_0_0 });
      expectEqual('payout', calculatePayout(100, 1.85, result).toNumber(), 50, {
        stake: 100,
        odds: 1.85,
      });
    },
  },
  {
    id: 'S011B',
    suite: 'settlement',
    name: '半赢派彩系数',
    description: 'HALF_WIN 派彩 = stake + stake*(odds-1)/2',
    run: () => {
      expectEqual('HALF_WIN payout', calculatePayout(100, 1.85, 'HALF_WIN').toNumber(), 142.5, {
        stake: 100,
        odds: 1.85,
      });
    },
  },
  {
    id: 'S012',
    suite: 'settlement',
    name: '让球 -0.5 全输（0-0）',
    uatRef: 'S012',
    run: () => {
      const result = settleSelection({
        marketType: 'FT_HANDICAP',
        selectionCode: 'HOME',
        handicapLine: -0.5,
        score: SCORE_0_0,
      });
      expectEqual('settlement', result, 'LOSE', { line: -0.5, score: SCORE_0_0 });
      expectEqual('payout', calculatePayout(100, 1.85, result).toNumber(), 0, {
        stake: 100,
        odds: 1.85,
      });
    },
  },
  {
    id: 'S013',
    suite: 'settlement',
    name: '大小 2.5：3 球大球赢',
    uatRef: 'S013',
    run: () => {
      expectEqual(
        'OVER 2.5',
        settleSelection({
          marketType: 'FT_OVER_UNDER',
          selectionCode: 'OVER',
          totalLine: 2.5,
          score: SCORE_2_1,
        }),
        'WIN',
        { totalGoals: 3, line: 2.5 },
      );
    },
  },
  {
    id: 'S014',
    suite: 'settlement',
    name: '大小整数盘 2 球走水',
    uatRef: 'S014',
    run: () => {
      const score = { htHome: 1, htAway: 0, ftHome: 1, ftAway: 1 };
      expectEqual(
        'OVER 2 push',
        settleSelection({
          marketType: 'FT_OVER_UNDER',
          selectionCode: 'OVER',
          totalLine: 2,
          score,
        }),
        'PUSH',
        { totalGoals: 2, line: 2 },
      );
    },
  },
  {
    id: 'S015',
    suite: 'settlement',
    name: '0-0 大小 2.5：小球赢',
    description: '0-0 下小球赢、大球输',
    run: () => {
      const under = settleSelection({
        marketType: 'FT_OVER_UNDER',
        selectionCode: 'UNDER',
        totalLine: 2.5,
        score: SCORE_0_0,
      });
      const over = settleSelection({
        marketType: 'FT_OVER_UNDER',
        selectionCode: 'OVER',
        totalLine: 2.5,
        score: SCORE_0_0,
      });
      expectEqual('UNDER', under, 'WIN', { line: 2.5, score: SCORE_0_0 });
      expectEqual('OVER', over, 'LOSE', { line: 2.5, score: SCORE_0_0 });
      expectEqual('UNDER payout', calculatePayout(100, 1.95, under).toNumber(), 195, {
        stake: 100,
        odds: 1.95,
      });
    },
  },
  {
    id: 'S016',
    suite: 'settlement',
    name: '串关全中派彩',
    uatRef: 'S016',
    run: () => {
      const legs = [
        { odds: 1.8, result: 'WIN' as const },
        { odds: 2.0, result: 'WIN' as const },
      ];
      const { betResult, payout } = calculateParlayPayout(100, legs);
      expectEqual('betResult', betResult, 'WON', { stake: 100, legs });
      expectEqual('payout', payout.toNumber(), 360, { stake: 100, legs });
    },
  },
  {
    id: 'S017',
    suite: 'settlement',
    name: '串关一关输：全输',
    uatRef: 'S017',
    run: () => {
      const legs = [
        { odds: 1.8, result: 'WIN' as const },
        { odds: 2.0, result: 'LOSE' as const },
      ];
      const { betResult, payout } = calculateParlayPayout(100, legs);
      expectEqual('betResult', betResult, 'LOST', { stake: 100, legs });
      expectEqual('payout', payout.toNumber(), 0, { stake: 100, legs });
    },
  },
  {
    id: 'S018',
    suite: 'settlement',
    name: '串关一关走水：赔率按 1.00',
    uatRef: 'S018',
    run: () => {
      const legs = [
        { odds: 1.8, result: 'WIN' as const },
        { odds: 2.0, result: 'PUSH' as const },
        { odds: 1.9, result: 'WIN' as const },
      ];
      const { betResult, payout } = calculateParlayPayout(100, legs);
      expectEqual('betResult', betResult, 'WON', { stake: 100, legs });
      expectEqual('payout', payout.toNumber(), 342, { stake: 100, legs });
    },
  },
  {
    id: 'S019',
    suite: 'settlement',
    name: '串关全走水/作废：退本',
    uatRef: 'S019',
    run: () => {
      const legs = [
        { odds: 1.8, result: 'PUSH' as const },
        { odds: 2.0, result: 'VOID' as const },
      ];
      const { betResult, payout } = calculateParlayPayout(100, legs);
      expectEqual('betResult', betResult, 'PUSH', { stake: 100, legs });
      expectEqual('payout', payout.toNumber(), 100, { stake: 100, legs });
    },
  },
  {
    id: 'S020',
    suite: 'settlement',
    name: '串关 VOID 腿 + LOSE 腿：整单全输',
    description: '比赛取消腿按 odds=1.0 续算，已有 LOSE 腿时 payout=0',
    run: () => {
      const legs = [
        { odds: 2.0, result: 'VOID' as const },
        { odds: 2.0, result: 'LOSE' as const },
      ];
      const { betResult, payout } = calculateParlayPayout(100, legs);
      expectEqual('betResult', betResult, 'LOST', { stake: 100, legs });
      expectEqual('payout', payout.toNumber(), 0, { stake: 100, legs });
    },
  },
  {
    id: 'S021',
    suite: 'settlement',
    name: '串关 VOID 腿 + WIN 腿：按 WIN 腿赔率结算',
    description: '作废腿不参与升赔，其余 WIN 腿正常连乘',
    run: () => {
      const legs = [
        { odds: 2.0, result: 'VOID' as const },
        { odds: 1.5, result: 'WIN' as const },
      ];
      const { betResult, payout } = calculateParlayPayout(100, legs);
      expectEqual('betResult', betResult, 'WON', { stake: 100, legs });
      expectEqual('payout', payout.toNumber(), 150, { stake: 100, legs });
    },
  },
  {
    id: 'OUT001',
    suite: 'settlement',
    name: '冠军盘：猜中/猜错',
    description: 'OUTRIGHT_WINNER 按 winnerTeamCode 结算',
    run: () => {
      const input = { winnerTeamCode: 'BRA', selection: 'BRA' };
      expectEqual(
        'BRA wins',
        settleSelection({
          marketType: 'OUTRIGHT_WINNER',
          selectionCode: 'BRA',
          score: SCORE_0_0,
          winnerTeamCode: 'BRA',
        }),
        'WIN',
        input,
      );
      expectEqual(
        'ARG loses',
        settleSelection({
          marketType: 'OUTRIGHT_WINNER',
          selectionCode: 'ARG',
          score: SCORE_0_0,
          winnerTeamCode: 'BRA',
        }),
        'LOSE',
        { winnerTeamCode: 'BRA', selection: 'ARG' },
      );
    },
  },

  // —— Settlement helpers ——
  {
    id: 'H001',
    suite: 'settlement_helpers',
    name: '选项代码解析',
    description: '数据库 code 优先，中文快照名兜底',
    run: () => {
      expectEqual('db code', resolveSelectionCode('UNDER', '小 2.5'), 'UNDER', {
        code: 'UNDER',
        name: '小 2.5',
      });
      expectEqual('主胜', resolveSelectionCode(null, '主胜'), 'HOME', { name: '主胜' });
      expectEqual('小 2.5', resolveSelectionCode('', '小 2.5'), 'UNDER', { name: '小 2.5' });
      expectEqual('大 2.5', resolveSelectionCode(undefined, '大 2.5'), 'OVER', { name: '大 2.5' });
      expectEqual('主 -0.5', resolveSelectionCode(null, '主 -0.5'), 'HOME', { name: '主 -0.5' });
    },
  },

  // —— Betting rules ——
  {
    id: 'B006',
    suite: 'betting',
    name: '串关 2-5 场范围常量',
    uatRef: 'B006',
    run: () => {
      expectEqual('PARLAY_MIN_LEGS', PARLAY_MIN_LEGS, 2);
      expectEqual('PARLAY_MAX_LEGS', PARLAY_MAX_LEGS, 5);
      expectTrue('2 legs ok', 2 >= PARLAY_MIN_LEGS && 2 <= PARLAY_MAX_LEGS);
      expectTrue('5 legs ok', 5 >= PARLAY_MIN_LEGS && 5 <= PARLAY_MAX_LEGS);
      expectTrue('6 legs blocked', 6 > PARLAY_MAX_LEGS);
      expectTrue('1 leg blocked', 1 < PARLAY_MIN_LEGS);
    },
  },
  {
    id: 'B007',
    suite: 'betting',
    name: '同场串关允许',
    uatRef: 'B007',
    run: () => {
      const first = canSelectForParlay({ marketType: 'FT_1X2', allowParlay: true });
      const second = canSelectForParlay({ marketType: 'FT_1X2', allowParlay: true });
      expectTrue('first same-match leg ok', first.ok, { matchId: '1' });
      expectTrue('second same-match leg ok', second.ok, { matchId: '1' });
    },
  },
  {
    id: 'B008',
    suite: 'betting',
    name: '四分之一盘不可串关',
    uatRef: 'B008',
    run: () => {
      expectTrue('-0.25 is quarter', isQuarterHandicapOrTotal(-0.25), { line: -0.25 });
      expectFalse('2.5 not quarter', isQuarterHandicapOrTotal(2.5), { line: 2.5 });
      expectFalse('-1 not quarter', isQuarterHandicapOrTotal(-1), { line: -1 });
      const check = canSelectForParlay({
        marketType: 'FT_HANDICAP',
        lineValue: -0.25,
      });
      expectFalse('blocked', check.ok, { line: -0.25 }, check.ok ? '' : (check as { reason: string }).reason);
      if (!check.ok) {
        expectEqual('reason', check.reason, 'QUARTER_LINE', { line: -0.25 });
      }
    },
  },
  {
    id: 'B009',
    suite: 'betting',
    name: '串关超过 5 场应拒绝',
    uatRef: 'B009',
    run: () => {
      expectTrue('6 > max', 6 > PARLAY_MAX_LEGS, { legs: 6, max: PARLAY_MAX_LEGS });
    },
  },
  {
    id: 'B010',
    suite: 'betting',
    name: '冠军盘不可串关',
    uatRef: 'B010',
    run: () => {
      const check = canSelectForParlay({
        marketType: 'OUTRIGHT_WINNER',
        isOutright: true,
      });
      expectFalse('blocked', check.ok, { marketType: 'OUTRIGHT_WINNER' });
      if (!check.ok) {
        expectEqual('reason', check.reason, 'OUTRIGHT', { marketType: 'OUTRIGHT_WINNER' });
      }
    },
  },
  {
    id: 'B011',
    suite: 'betting',
    name: '常规让球盘可串关',
    run: () => {
      const check = canSelectForParlay({
        marketType: 'FT_HANDICAP',
        lineValue: -0.5,
      });
      expectTrue('allowed', check.ok, { marketType: 'FT_HANDICAP', line: -0.5 });
    },
  },
  {
    id: 'B012',
    suite: 'betting',
    name: '显式禁止串关的盘口',
    run: () => {
      const check = canSelectForParlay({
        marketType: 'FT_1X2',
        allowParlay: false,
      });
      expectFalse('blocked', check.ok, { marketType: 'FT_1X2', allowParlay: false });
      if (!check.ok) {
        expectEqual('reason', check.reason, 'NOT_ALLOWED', { allowParlay: false });
      }
    },
  },

  // —— Betting limits ——
  {
    id: 'BL001',
    suite: 'betting_limits',
    name: '低于最小投注额拒绝',
    run: async () => {
      const service = createBettingLimitsService();
      await expectAppErrorThrows(
        'min stake',
        () =>
          service.validateBet({
            userId: BigInt(1),
            betType: 'SINGLE',
            stake: 0.5,
            potentialReturn: new Decimal(1),
          }),
        'MIN_STAKE',
        { stake: 0.5, minStake: 1 },
      );
    },
  },
  {
    id: 'BL002',
    suite: 'betting_limits',
    name: '超过单关最大投注额拒绝',
    run: async () => {
      const service = createBettingLimitsService();
      await expectAppErrorThrows(
        'max stake',
        () =>
          service.validateBet({
            userId: BigInt(1),
            betType: 'SINGLE',
            stake: 60000,
            potentialReturn: new Decimal(70000),
          }),
        'MAX_STAKE',
        { stake: 60000, maxStakeSingle: 50000 },
      );
    },
  },
  {
    id: 'BL003',
    suite: 'betting_limits',
    name: '超过最高派彩拒绝',
    run: async () => {
      const service = createBettingLimitsService();
      await expectAppErrorThrows(
        'max payout',
        () =>
          service.validateBet({
            userId: BigInt(1),
            betType: 'SINGLE',
            stake: 100,
            potentialReturn: new Decimal(600000),
          }),
        'MAX_PAYOUT',
        { potentialReturn: 600000, maxPayoutSingle: 500000 },
      );
    },
  },

  // —— Agent credit ——
  {
    id: 'A001',
    suite: 'agent_credit',
    name: '代理上分占用额度',
    uatRef: 'A001',
    run: () => {
      const creditLimit = 10000;
      const usedCredit = 1000 + 500;
      const available = creditLimit - usedCredit;
      expectEqual('available credit', available, 8500, {
        creditLimit,
        usedCredit,
        formula: 'creditLimit - usedCredit',
      });
    },
  },
  {
    id: 'A002',
    suite: 'agent_credit',
    name: '下注冻结：总额不变、可用减少',
    uatRef: 'A002',
    run: () => {
      const balance = 1000;
      const frozenBefore = 0;
      const stake = 100;
      const totalBefore = balance + frozenBefore;
      const balanceAfter = balance - stake;
      const frozenAfter = frozenBefore + stake;
      const totalAfter = balanceAfter + frozenAfter;
      expectEqual('total unchanged', totalAfter, totalBefore, {
        before: { balance, frozen: frozenBefore },
        after: { balance: balanceAfter, frozen: frozenAfter },
      });
      expectEqual('available', balanceAfter, 900, { stake });
    },
  },
  {
    id: 'A003',
    suite: 'agent_credit',
    name: '结算派彩：可用余额增加',
    description: '赢单释放本金并增加盈利',
    run: () => {
      const balance = 900;
      const frozen = 100;
      const payout = 185;
      const balanceAfter = balance + payout;
      const frozenAfter = frozen - 100;
      expectEqual('balance after win', balanceAfter, 1085, { payout, before: 900 });
      expectEqual('frozen released', frozenAfter, 0, { frozenBefore: 100, stake: 100 });
    },
  },
  {
    id: 'A005',
    suite: 'agent_credit',
    name: '额度为负禁止继续放款',
    uatRef: 'A005',
    run: () => {
      const creditLimit = 1000;
      const usedCredit = 1200;
      const available = creditLimit - usedCredit;
      expectTrue('negative available', available < 0, { creditLimit, usedCredit, available });
      expectFalse('deposit allowed', available > 0, { available });
    },
  },

  // —— Cashback ——
  {
    id: 'CB001',
    suite: 'cashback',
    name: '返水比例：玩家规则优先',
    run: () => {
      const rate = resolveCashbackRateForBet({
        userId: BigInt(100),
        agentId: BigInt(200),
        marketTypes: ['FT_1X2'],
        agentDefaultRate: new Decimal('0.01'),
        rules: [
          {
            targetType: 'USER',
            targetId: BigInt(100),
            rate: new Decimal('0.03'),
            marketType: null,
          },
        ],
      });
      expectEqual('rate', rate.toString(), '0.03', {
        userRule: '0.03',
        agentDefault: '0.01',
      });
    },
  },
  {
    id: 'CB002',
    suite: 'cashback',
    name: '返水比例：玩法专属规则',
    run: () => {
      const rate = resolveCashbackRateForBet({
        userId: BigInt(100),
        agentId: BigInt(200),
        marketTypes: ['FT_HANDICAP'],
        agentDefaultRate: new Decimal('0.01'),
        rules: [
          {
            targetType: 'GLOBAL',
            targetId: null,
            rate: new Decimal('0.005'),
            marketType: 'FT_HANDICAP',
          },
        ],
      });
      expectEqual('rate', rate.toString(), '0.005', { marketType: 'FT_HANDICAP' });
    },
  },
  {
    id: 'CB003',
    suite: 'cashback',
    name: '返水比例：无规则用代理默认',
    run: () => {
      const rate = resolveCashbackRateForBet({
        userId: BigInt(100),
        agentId: BigInt(200),
        marketTypes: ['FT_1X2'],
        agentDefaultRate: new Decimal('0.02'),
        rules: [],
      });
      expectEqual('rate', rate.toString(), '0.02', { agentDefault: '0.02', rules: [] });
    },
  },
  {
    id: 'CB004',
    suite: 'cashback',
    name: '返水比例：玩法不匹配回退默认',
    run: () => {
      const rate = resolveCashbackRateForBet({
        userId: BigInt(100),
        agentId: BigInt(200),
        marketTypes: ['FT_1X2'],
        agentDefaultRate: new Decimal('0.01'),
        rules: [
          {
            targetType: 'GLOBAL',
            targetId: null,
            rate: new Decimal('0.005'),
            marketType: 'FT_HANDICAP',
          },
        ],
      });
      expectEqual('rate', rate.toString(), '0.01', {
        betMarket: 'FT_1X2',
        ruleMarket: 'FT_HANDICAP',
        agentDefault: '0.01',
      });
    },
  },
];

export const SMOKE_SUITE_META: Record<string, { name: string; description: string }> = {
  settlement: {
    name: '结算引擎',
    description: '独赢、波胆、让球、大小、串关、冠军盘、作废腿续算',
  },
  settlement_helpers: { name: '结算辅助', description: '选项代码与中文快照名映射' },
  betting: { name: '下注规则', description: '串关限制、赔率版本、四分之一盘' },
  betting_limits: { name: '投注限额', description: '最小/最大投注与派彩上限校验' },
  agent_credit: { name: '代理额度', description: '额度占用、冻结与放款规则（纯逻辑）' },
  cashback: { name: '返水规则', description: '返水比例优先级与回退' },
  database: { name: '数据库', description: '连接、种子账号、赛事盘口与配置探针（只读）' },
  'bet-flow': {
    name: '下注结算链路',
    description: '真实 DB：下注→冻结→录分→结算→钱包/代理额度（临时数据自动清理）',
  },
  config: {
    name: '系统配置',
    description: '真实 DB：SystemConfig 接线后 AgentsService 行为（临时数据自动清理）',
  },
};
