feat(*): 短剧创作工作台 - 完善章节分镜、资产管理、技能运行与生成任务恢复

This commit is contained in:
ddCat committed 2026-08-29 23:34:55 +08:00
1 parent 4f07daae9e
commit 2f6832f99c
113 files changed
+7016 -723

No files matched your search

@@ -0,0 +1,42 @@
package service
import "testing"
func TestProviderProgressFromResponse(t *testing.T) {
tests := []struct {
name string
body string
want int
ok bool
}{
{name: "direct number", body: `{"progress":35}`, want: 35, ok: true},
{name: "nested percent string", body: `{"data":{"task":{"progress_percent":"68%"}}}`, want: 68, ok: true},
{name: "fraction", body: `{"result":{"progress":0.42}}`, want: 42, ok: true},
{name: "fractional explicit percent", body: `{"progress":"0.5%"}`, want: 1, ok: true},
{name: "camel case", body: `{"operation":{"progressPercentage":87.6}}`, want: 88, ok: true},
{name: "unrelated completion tokens", body: `{"usage":{"completion_tokens":120}}`, ok: false},
{name: "invalid range", body: `{"progress":140}`, ok: false},
{name: "not json", body: `not-json`, ok: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, ok := providerProgressFromResponse([]byte(tt.body))
if got != tt.want || ok != tt.ok {
t.Fatalf("providerProgressFromResponse() = (%d, %v), want (%d, %v)", got, ok, tt.want, tt.ok)
}
})
}
}
func TestTaskUsesUpstreamReportedProgress(t *testing.T) {
for _, taskType := range []string{"canvas_image", "canvas_video", "video_shot"} {
if !taskUsesUpstreamReportedProgress(taskType) {
t.Fatalf("task type %q should use upstream progress", taskType)
}
}
for _, taskType := range []string{"canvas_text", "canvas_audio", "agent_storyboard"} {
if taskUsesUpstreamReportedProgress(taskType) {
t.Fatalf("task type %q should keep internal progress", taskType)
}
}
}