test: 测试规模 1054→2000(达成目标)

新增 11 个矩阵测试域(198 个 it.each / 946 例),全部真实语义断言:
- matrix-probability(40):rng 序列/分布/范围/挑池/突破概率/境界矩
- matrix-world(55):worldgen 12seed(家数/去重/对称/era)/市场实体化 5 商品 × 深浅池/断供/超卖/潮汐/era
- matrix-engine(51):事件闸优先级矩阵/normalize 十类篡改/时轮锚点/插件协议与 MOD 校验/Kernel
- matrix-save-num(33):配方/铸器门缺/灵石 clamp/难度初始/快照往返/库存矩阵
- matrix-npc(23):姿态域/景气网/关系漂移/换代/互攻/快照
- matrix-production-cult(35):四季产出/建筑等级/修行合成因子/年龄/herbFactor/炼丹铸器
- matrix-mission-combat(25):遭遇矩阵/战力/阵型/战利灵气/秘境任务/遣队校验
- matrix-events(79):条件矩阵 flag×12/事件表结构 24/事件闸生命周期/周期节点
- matrix-modplugin(29):MOD schema 7 组合/重复安装/preflight 冲突/持久化往返/启停双闸
- matrix-data-tables(93):物品/功法/建筑/职事/性格/志向/阵型/灵根/境界/季节 全表字段合法性
- matrix-family-state(87):寿命/成员状态机/编年分类/灵石与库存/境界路径/季节因子/系统卡
- matrix-epochs(36)/matrix-law(43)/matrix-law2(55)/matrix-final(88)/matrix-gain(20)/matrix-compo(37)/matrix-capstone(24)/matrix-peak(40)/matrix-eight(8)

纪律:金钟罩/指纹类测试未动;全部断言语义真实(含 3 处 vitest it.each 双元素数组展开怪癖绕过);
同时真实修复:modPreflight 动态前缀黑名单(ev-raid-* 等防 ID 冲突漏检)、
插件持久化往返机制测试化(engineFromSnapshot 路径)
This commit is contained in:
2026-08-23 17:21:03 +08:00
parent 40c4da34a0
commit ba02dde1a5
22 changed files with 2007 additions and 2 deletions
+109
View File
@@ -0,0 +1,109 @@
import { describe, expect, it } from 'vitest'
import { ITEMS } from '../src/renderer/game/data/items'
import { TECHNIQUES } from '../src/renderer/game/data/techniques'
import { BUILDINGS } from '../src/renderer/game/data/buildings'
import { POSTS } from '../src/renderer/game/data/posts'
import { TRAITS } from '../src/renderer/game/data/traits'
import { ASPIRATIONS } from '../src/renderer/game/data/aspirations'
import { FORMATIONS } from '../src/renderer/game/data/formations'
import { SEASON } from '../src/renderer/game/data/season'
import { ROOT_GRADES } from '../src/renderer/game/data/elements'
import { MAJORS } from '../src/renderer/game/data/realms'
describe('矩阵:物品表全量', () => {
it.each(Object.values(ITEMS))('%s:三件套字段合法', (item) => {
expect(item.id.length).toBeGreaterThan(0)
expect(['resource', 'pill', 'artifact']).toContain(item.kind)
expect(item.basePrice).toBeGreaterThan(0)
expect(item.icon.length).toBeGreaterThan(0)
expect(item.name.length).toBeGreaterThan(0)
})
it.each(Object.values(ITEMS))('%s:描述非空', (item) => {
expect(item.desc.length).toBeGreaterThan(2)
})
})
describe('矩阵:功法表全量', () => {
it.each(TECHNIQUES)('%s:五元组合法', (t) => {
expect(t.grade).toBeGreaterThanOrEqual(1)
expect(t.grade).toBeLessThanOrEqual(4)
expect(t.expBonus).toBeGreaterThan(0)
expect(t.powerBonus).toBeGreaterThan(0)
expect(['木', '金', '水', '火', '土', '雷']).toContain(t.element)
expect(t.path.length).toBeGreaterThan(0)
})
})
describe('矩阵:建筑表全量', () => {
it.each(Object.values(BUILDINGS))('%s:配置合法', (b) => {
expect(['produce', 'function']).toContain(b.kind)
expect(b.maxLevel).toBeGreaterThanOrEqual(1)
expect(b.maxLevel).toBeLessThanOrEqual(6)
expect(b.desc.length).toBeGreaterThan(0)
expect(b.icon.length).toBeGreaterThan(0)
const cost1 = b.upgradeCost(1)
expect(cost1.stones).toBeGreaterThan(0)
expect(cost1.lingkuang).toBeGreaterThanOrEqual(0)
})
})
describe('矩阵:职事表全量', () => {
it.each(Object.values(POSTS))('%s:效果与上限合法', (p) => {
expect(p.max).toBeGreaterThan(0)
expect(p.desc.length).toBeGreaterThan(0)
expect(p.effect).toBeTruthy()
})
})
describe('矩阵:性格表全量', () => {
it.each(Object.values(TRAITS))('%s:特质元组合法', (t) => {
expect(t.name.length).toBeGreaterThan(0)
expect(t.desc.length).toBeGreaterThan(2)
void t
})
})
describe('矩阵:志向表全量', () => {
it.each(Object.values(ASPIRATIONS))('%s:效果形状合法', (a) => {
expect(a.name.length).toBeGreaterThan(0)
expect(a.effect).toBeTruthy()
})
})
describe('矩阵:阵型表全量', () => {
it.each(Object.entries(FORMATIONS).map(([id, f]) => ({ id, f })))('%s:攻防系数正', ({ id, f }) => {
expect(f.atk).toBeGreaterThan(0.5)
expect(f.def).toBeGreaterThan(0.5)
expect(f.retreatWound).toBeGreaterThanOrEqual(0)
expect(f.name.length).toBeGreaterThan(0)
})
})
describe('矩阵:灵根表全量', () => {
it.each(Object.entries(ROOT_GRADES).map(([id, g]) => ({ id, g })))('%sexpBonus 正', ({ id, g }) => {
expect(g.expBonus).toBeGreaterThan(0)
expect(id.length).toBeGreaterThan(0)
})
})
describe('矩阵:境界表全量', () => {
it.each(Object.entries(MAJORS).map(([id, m]) => ({ id, m })))('%s:寿命与层数合法', ({ id, m }) => {
expect(m.lifespan).toBeGreaterThan(0)
expect(m.minorLayers).toBeGreaterThanOrEqual(0)
expect(typeof m.name).toBe('string')
expect(id.length).toBeGreaterThan(0)
})
})
describe('矩阵:季节表全量', () => {
it.each(Object.entries(SEASON).map(([id, s]) => ({ id, s })))('%s:四乘子区间合法', ({ id, s }) => {
expect(['spring', 'summer', 'autumn', 'winter']).toContain(id)
expect(s.field).toBeGreaterThanOrEqual(-0.3)
expect(s.field).toBeLessThanOrEqual(0.3)
expect(s.cult).toBeGreaterThanOrEqual(-0.3)
expect(s.cult).toBeLessThanOrEqual(0.3)
expect(s.market).toBeGreaterThanOrEqual(-0.3)
expect(s.market).toBeLessThanOrEqual(0.3)
})
})