diff --git a/src/api/wizard.zig b/src/api/wizard.zig index 1764f9e4..a8318fae 100644 --- a/src/api/wizard.zig +++ b/src/api/wizard.zig @@ -32,7 +32,7 @@ pub const ProviderProbeResult = struct { // ─── Path Parsing ──────────────────────────────────────────────────────────── /// Extract the component name from a wizard API path. -/// Matches `/api/wizard/{component}` or `/api/wizard/{component}/models`. +/// Matches `/api/wizard/{component}` and supported wizard subroutes. /// Returns null if the path doesn't match the expected prefix or is empty. pub fn extractComponentName(target: []const u8) ?[]const u8 { const prefix = "/api/wizard/"; @@ -79,7 +79,7 @@ pub fn extractComponentName(target: []const u8) ?[]const u8 { return rest; } -/// Check if a target path matches `/api/wizard/{component}` or `/api/wizard/{component}/models`. +/// Check if a target path matches `/api/wizard/{component}` or a supported wizard subroute. pub fn isWizardPath(target: []const u8) bool { return extractComponentName(target) != null; } diff --git a/src/integration_tests.zig b/src/integration_tests.zig index 160cc442..956903ec 100644 --- a/src/integration_tests.zig +++ b/src/integration_tests.zig @@ -658,6 +658,17 @@ test "integration harness covers wizard failure contracts" { try std.testing.expect(std.mem.indexOf(u8, resp.body, "invalid JSON body") != null); } + { + const resp = try server.fetch(.{ + .path = "/api/wizard/nullclaw/models", + .method = .POST, + .body = "{\"provider\":\"\"}", + }); + defer resp.deinit(std.testing.allocator); + try std.testing.expectEqual(std.http.Status.bad_request, resp.status); + try std.testing.expect(std.mem.indexOf(u8, resp.body, "provider is required") != null); + } + { const resp = try server.fetch(.{ .path = "/api/wizard/missing-component/models", @@ -666,6 +677,15 @@ test "integration harness covers wizard failure contracts" { }); defer resp.deinit(std.testing.allocator); try std.testing.expectEqual(std.http.Status.not_found, resp.status); - try std.testing.expect(std.mem.indexOf(u8, resp.body, "component not found") != null); + try std.testing.expect(std.mem.indexOf(u8, resp.body, "component not found or models unavailable") != null); + } + + { + const resp = try server.fetch(.{ + .path = "/api/wizard/missing-component/models?provider=openai", + }); + defer resp.deinit(std.testing.allocator); + try std.testing.expectEqual(std.http.Status.not_found, resp.status); + try std.testing.expect(std.mem.indexOf(u8, resp.body, "component not found or models unavailable") != null); } }