This commit is contained in:
2026-08-16 19:21:49 +02:00
parent d6fe7c38d5
commit 106f602232
8 changed files with 212 additions and 15 deletions
@@ -107,7 +107,7 @@ func TestRunSteps_callsEnhanceWhenInputHashDiffers(t *testing.T) {
e := &Engine{
Completer: stubCompleter{fn: func(system, user string) (Completion, error) {
calls++
return Completion{Text: `{"name":"Fresh","description":"New copy."}`, TotalTokens: 3}, nil
return Completion{Text: `{"name":"Fresh","description":"Fresh retail copy with enough detail for a quality enhance hash."}`, TotalTokens: 3}, nil
}},
Vector: NoopVectorCategorizer{},
}
@@ -243,6 +243,42 @@ func TestRunSteps_thinOKDoesNotPersistEnhanceHash(t *testing.T) {
}
}
func TestRunSteps_synthesizedDescDoesNotPersistEnhanceHash(t *testing.T) {
e := &Engine{
Completer: stubCompleter{fn: func(system, user string) (Completion, error) {
// Empty description forces synthesizeProductDescription.
return Completion{Text: `{"name":"GIGABYTE GS27QC","description":""}`, TotalTokens: 3}, nil
}},
Vector: NoopVectorCategorizer{},
}
descTpl := map[string]any{
"sections": []any{
map[string]any{"type": "h1", "instructions": "Heading"},
map[string]any{"type": "p", "instructions": "Body"},
},
}
out, err := e.RunSteps(context.Background(), "co", ProductInput{
Name: "GIGABYTE GS27QC",
Mapped: map[string]any{"name": "GIGABYTE GS27QC", "category": "7", "brand": "GIGABYTE"},
DescriptionTemplate: descTpl,
Language: "sl",
}, "enhance_only", nil, StepPolicy{AllowAI: true, AllowEPREL: true})
if err != nil {
t.Fatal(err)
}
if !strings.Contains(out.ProcessedDescription, "<h1>") {
t.Fatalf("expected formula synthesize HTML, got %q", out.ProcessedDescription)
}
if h, _ := out.FieldSources[FieldEnhanceInputHash].(string); h != "" {
t.Fatalf("synthesized description must not persist enhance hash (got %q)", h)
}
for _, lf := range out.LocalizedContent {
if lf.EnhanceInputHash != "" {
t.Fatalf("localized synthesized hash must be empty: %+v", lf)
}
}
}
func TestRunSteps_weakPriorHashDoesNotSkipReprocess(t *testing.T) {
calls := 0
e := &Engine{