release v0.4.0

This commit is contained in:
saturn
2026-04-02 21:44:46 +08:00
parent 71ef6ff818
commit 77a1303510
6 changed files with 84 additions and 17 deletions

View File

@@ -48,4 +48,31 @@ describe('StoryInputComposer', () => {
expect(html).toContain('AI 帮我写')
expect(html).toContain('开始创作')
})
it('hides the style preset selector when no preset is enabled', () => {
Reflect.set(globalThis, 'React', React)
const html = renderToStaticMarkup(
createElement(StoryInputComposer, {
value: '测试内容',
onValueChange: () => undefined,
placeholder: '请输入内容',
minRows: 8,
videoRatio: '9:16',
onVideoRatioChange: () => undefined,
ratioOptions: [{ value: '9:16', label: '9:16' }],
artStyle: 'realistic',
onArtStyleChange: () => undefined,
styleOptions: [{ value: 'realistic', label: '真人风格' }],
stylePresetValue: '',
onStylePresetChange: () => undefined,
stylePresetOptions: [],
primaryAction: createElement('button', { type: 'button' }, '开始创作'),
}),
)
expect(html).toContain('RatioSelector')
expect(html).toContain('StyleSelector')
expect(html).not.toContain('StylePresetSelector')
})
})

View File

@@ -0,0 +1,29 @@
import { describe, expect, it } from 'vitest'
import { readApiErrorMessage } from '@/lib/api/read-error-message'
function buildJsonResponse(body: unknown, status = 400): Response {
return new Response(JSON.stringify(body), {
status,
headers: { 'Content-Type': 'application/json' },
})
}
describe('readApiErrorMessage', () => {
it('returns nested api error message instead of [object Object]', async () => {
const response = buildJsonResponse({
error: {
code: 'INVALID_PARAMS',
message: 'Episode name is required',
},
message: 'Invalid parameters',
})
await expect(readApiErrorMessage(response, '创建失败')).resolves.toBe('Episode name is required')
})
it('falls back when the response body is not json', async () => {
const response = new Response('bad gateway', { status: 502 })
await expect(readApiErrorMessage(response, '创建失败')).resolves.toBe('创建失败')
})
})