| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "reflect" |
| 5 | "testing" |
| 6 | |
| 7 | "reasonix/internal/config" |
| 8 | "reasonix/internal/provider/openai" |
| 9 | ) |
| 10 | |
| 11 | func TestProviderViewKeepsOfficialDeepSeekVisionSelection(t *testing.T) { |
| 12 | p := config.ProviderEntry{ |
| 13 | Name: "deepseek", |
| 14 | Kind: "openai", |
| 15 | BaseURL: "https://api.deepseek.com", |
| 16 | Models: []string{"deepseek-v4-flash", "deepseek-v4-pro"}, |
| 17 | VisionModels: []string{"deepseek-v4-flash", "deepseek-v4-pro"}, |
| 18 | } |
| 19 | view := providerViewFromEntry(p, true, true) |
| 20 | if view.VisionCapability != "configurable" { |
| 21 | t.Fatalf("VisionCapability = %q, want configurable", view.VisionCapability) |
| 22 | } |
| 23 | if !reflect.DeepEqual(view.VisionModels, []string{"deepseek-v4-flash", "deepseek-v4-pro"}) { |
| 24 | t.Fatalf("ProviderView must round-trip Settings image-input checkboxes: %v", view.VisionModels) |
| 25 | } |
| 26 | resolved := p |
| 27 | resolved.Model = "deepseek-v4-pro" |
| 28 | if config.EffectiveVision(&resolved) { |
| 29 | t.Fatal("Flash/Pro image-input checkboxes must not enable runtime image payloads") |
| 30 | } |
| 31 | |
| 32 | p.Models = append(p.Models, openai.OfficialDeepSeekVisionModel) |
| 33 | p.VisionModels = []string{openai.OfficialDeepSeekVisionModel} |
| 34 | view = providerViewFromEntry(p, true, true) |
| 35 | if !reflect.DeepEqual(view.VisionModels, []string{openai.OfficialDeepSeekVisionModel}) { |
| 36 | t.Fatalf("ProviderView.VisionModels = %v, want selected vision SKU", view.VisionModels) |
| 37 | } |
| 38 | resolved = p |
| 39 | resolved.Model = openai.OfficialDeepSeekVisionModel |
| 40 | if !config.EffectiveVision(&resolved) { |
| 41 | t.Fatal("selecting the official DeepSeek vision SKU with image input checked must enable image input") |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | func TestSaveProviderPersistsOfficialDeepSeekVisionModels(t *testing.T) { |
| 46 | isolateDesktopUserDirs(t) |
| 47 | |
| 48 | if err := NewApp().SaveProvider(ProviderView{ |
| 49 | Name: "deepseek", |
| 50 | Kind: "openai", |
| 51 | BaseURL: "https://api.deepseek.com", |
| 52 | Models: []string{"deepseek-v4-flash", "deepseek-v4-pro", openai.OfficialDeepSeekVisionModel}, |
| 53 | VisionModels: []string{openai.OfficialDeepSeekVisionModel}, |
| 54 | VisionModelsSet: true, |
| 55 | Default: "deepseek-v4-flash", |
| 56 | }); err != nil { |
| 57 | t.Fatalf("SaveProvider: %v", err) |
| 58 | } |
| 59 | |
| 60 | cfg := config.LoadForEdit(config.UserConfigPath()) |
| 61 | got, ok := cfg.Provider("deepseek") |
| 62 | if !ok { |
| 63 | t.Fatal("saved provider not found") |
| 64 | } |
| 65 | if !reflect.DeepEqual(got.VisionModels, []string{openai.OfficialDeepSeekVisionModel}) { |
| 66 | t.Fatalf("saved official DeepSeek vision_models = %v, want selected vision SKU", got.VisionModels) |
| 67 | } |
| 68 | flash := *got |
| 69 | flash.Model = "deepseek-v4-flash" |
| 70 | if !config.EffectiveVision(&flash) { |
| 71 | t.Fatal("saved Flash must accept images on the official DeepSeek endpoint") |
| 72 | } |
| 73 | sku := *got |
| 74 | sku.Model = openai.OfficialDeepSeekVisionModel |
| 75 | if !config.EffectiveVision(&sku) { |
| 76 | t.Fatal("saved vision SKU with image input checked must enable image input") |
| 77 | } |
| 78 | } |
| 79 |