fix(config): persist disabled placeholder settings (#1902)
This commit is contained in:
parent
2ccac1819c
commit
9fb01bc7f8
2 changed files with 32 additions and 1 deletions
|
|
@ -381,7 +381,7 @@ type TypingConfig struct {
|
||||||
|
|
||||||
// PlaceholderConfig controls placeholder message behavior (Phase 10).
|
// PlaceholderConfig controls placeholder message behavior (Phase 10).
|
||||||
type PlaceholderConfig struct {
|
type PlaceholderConfig struct {
|
||||||
Enabled bool `json:"enabled,omitempty"`
|
Enabled bool `json:"enabled"`
|
||||||
Text string `json:"text,omitempty"`
|
Text string `json:"text,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -360,6 +360,37 @@ func TestSaveConfig_IncludesEmptyLegacyModelField(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSaveConfig_PreservesDisabledTelegramPlaceholder(t *testing.T) {
|
||||||
|
tmpDir := t.TempDir()
|
||||||
|
path := filepath.Join(tmpDir, "config.json")
|
||||||
|
|
||||||
|
cfg := DefaultConfig()
|
||||||
|
cfg.Channels.Telegram.Placeholder.Enabled = false
|
||||||
|
|
||||||
|
if err := SaveConfig(path, cfg); err != nil {
|
||||||
|
t.Fatalf("SaveConfig failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := os.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("ReadFile failed: %v", err)
|
||||||
|
}
|
||||||
|
if !strings.Contains(string(data), `"placeholder": {`) {
|
||||||
|
t.Fatalf("saved config should include telegram placeholder config, got: %s", string(data))
|
||||||
|
}
|
||||||
|
if !strings.Contains(string(data), `"enabled": false`) {
|
||||||
|
t.Fatalf("saved config should persist placeholder.enabled=false, got: %s", string(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
loaded, err := LoadConfig(path)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("LoadConfig failed: %v", err)
|
||||||
|
}
|
||||||
|
if loaded.Channels.Telegram.Placeholder.Enabled {
|
||||||
|
t.Fatal("telegram placeholder should remain disabled after SaveConfig/LoadConfig round-trip")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TestConfig_Complete verifies all config fields are set
|
// TestConfig_Complete verifies all config fields are set
|
||||||
func TestConfig_Complete(t *testing.T) {
|
func TestConfig_Complete(t *testing.T) {
|
||||||
cfg := DefaultConfig()
|
cfg := DefaultConfig()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue