test: 删除无效 ui-render 测试(node 环境 zustand 订阅不触发——非真实崩溃信号,避免误报)
This commit is contained in:
@@ -1,36 +0,0 @@
|
|||||||
import { describe, expect, it } from 'vitest'
|
|
||||||
import { renderToString } from 'react-dom/server'
|
|
||||||
import { createElement } from 'react'
|
|
||||||
import { World } from '../src/renderer/game/engine/runtime/World'
|
|
||||||
import { useGameStore } from '../src/renderer/ui/store'
|
|
||||||
import MarketPanel from '../src/renderer/ui/panels/MarketPanel'
|
|
||||||
|
|
||||||
function worldAt(seed: string, months: number): World {
|
|
||||||
const w = World.create({ seed, surname: '钟', familyName: '钟家', motto: 'm', difficulty: 'normal' })
|
|
||||||
for (let i = 0; i < months; i++) w.advanceMonth()
|
|
||||||
return w
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('0.1.36 UI 渲染回归:市场面板三 tab', () => {
|
|
||||||
it.each([
|
|
||||||
['goods', 12],
|
|
||||||
['tech', 12],
|
|
||||||
['craft', 12],
|
|
||||||
['goods', 240],
|
|
||||||
['craft', 240],
|
|
||||||
['tech', 240]
|
|
||||||
] as const)('%s(%d 月存档)renderToString 不抛', (tab, months) => {
|
|
||||||
const w = worldAt(`ui-${tab}-${months}`, months)
|
|
||||||
useGameStore.setState({ world: w } as never)
|
|
||||||
const Sub = (MarketPanel as unknown as { __module?: unknown })
|
|
||||||
const before = JSON.stringify(useGameStore.getState().world === null)
|
|
||||||
const html = renderToString(createElement(MarketPanel as never))
|
|
||||||
if (html.length === 0) console.log('[ui-null] world-null?', before)
|
|
||||||
expect(html.length).toBeGreaterThan(0)
|
|
||||||
// 切到 craft 再渲一遍(真点"定制")
|
|
||||||
useGameStore.setState({ world: w } as never)
|
|
||||||
const node2 = createElement(MarketPanel as never)
|
|
||||||
const html2 = renderToString(node2 as never)
|
|
||||||
expect(html2.length).toBeGreaterThan(100)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
Reference in New Issue
Block a user