This commit is contained in:
2026-08-16 16:57:36 +02:00
parent 96f8c1115c
commit 532d439c41
106 changed files with 10147 additions and 494 deletions
@@ -119,6 +119,12 @@ func TestRunSteps_enhanceMockProviderFailure(t *testing.T) {
if !foundFailed {
t.Fatalf("expected ai_enhance failed in progress=%v", prog)
}
if strings.TrimSpace(out.ProcessedDescription) == "" {
t.Fatal("provider failure must leave nonempty ProcessedDescription when title exists")
}
if descriptionEchoesTitle(out.ProcessedDescription, out.ProcessedName) {
t.Fatalf("failure synth must not echo title: name=%q desc=%q", out.ProcessedName, out.ProcessedDescription)
}
}
func TestRunSteps_enhanceMockTimeout(t *testing.T) {
@@ -150,6 +156,53 @@ func TestRunSteps_enhanceMockTimeout(t *testing.T) {
if !ok {
t.Fatalf("expected ai_enhance failed, progress=%v", prog)
}
if strings.TrimSpace(out.ProcessedDescription) == "" {
t.Fatal("timeout must leave nonempty ProcessedDescription when title exists")
}
if descriptionEchoesTitle(out.ProcessedDescription, out.ProcessedName) {
t.Fatalf("timeout synth must not echo title: name=%q desc=%q", out.ProcessedName, out.ProcessedDescription)
}
}
func TestRunSteps_enhanceTimeoutSynthesizesDescriptionAndInternalMode(t *testing.T) {
t.Parallel()
e := &Engine{
Completer: stubCompleter{fn: func(_, _ string) (Completion, error) {
return Completion{}, context.DeadlineExceeded
}},
ProviderMode: AIProviderInternal,
Vector: NoopVectorCategorizer{},
}
out, err := e.RunSteps(context.Background(), "co-timeout-synth", ProductInput{
Mapped: map[string]any{
"name": "VOX EBR700",
"description": "",
"brand": "VOX",
"category": "50",
},
Language: "sl",
CategoryNamesByUID: map[string]string{
"50": "Štedilniki",
},
}, "enhance_only", nil, StepPolicy{AllowAI: true})
if err != nil {
t.Fatalf("RunSteps should swallow timeout: %v", err)
}
if strings.TrimSpace(out.ProcessedName) == "" {
t.Fatal("expected nonempty ProcessedName")
}
if strings.TrimSpace(out.ProcessedDescription) == "" {
t.Fatal("timeout must synthesize nonempty ProcessedDescription when title exists")
}
if descriptionEchoesTitle(out.ProcessedDescription, out.ProcessedName) {
t.Fatalf("synth must not echo title: name=%q desc=%q", out.ProcessedName, out.ProcessedDescription)
}
if out.AIProviderMode != AIProviderInternal {
t.Fatalf("ai_provider_mode=%q want %q (attempted enhance, not unknown)", out.AIProviderMode, AIProviderInternal)
}
if _, ok := out.FieldSources[FieldEnhanceInputHash]; ok {
t.Fatalf("timeout must clear enhance hash, got %v", out.FieldSources[FieldEnhanceInputHash])
}
}
func TestOpenAIClient_Complete_httptestHappyPath(t *testing.T) {