| 1 | using System.Net.Http.Json; |
| 2 | using System.Text.Json; |
| 3 | using AgentForge.Plugins; |
| 4 | using AgentForge.Services; |
| 5 | using Microsoft.Extensions.DependencyInjection; |
| 6 | |
| 7 | namespace AgentForge.Tests; |
| 8 | |
| 9 | public sealed class SlashCatalogBaselineTests(ForgeWebApplicationFactory factory) : IClassFixture<ForgeWebApplicationFactory> |
| 10 | { |
| 11 | private static readonly JsonSerializerOptions JsonOptions = new() { PropertyNameCaseInsensitive = true }; |
| 12 | |
| 13 | [Fact] |
| 14 | public void Standard_bundle_command_counts_match_baseline() |
| 15 | { |
| 16 | var catalog = factory.Services.GetRequiredService<ForgePluginRuntime>().CommandCatalog; |
| 17 | var bySurface = catalog.CountBySurface(); |
| 18 | |
| 19 | Assert.Equal(14, catalog.Commands.Count); |
| 20 | Assert.Equal(12, bySurface["command-bar"]); |
| 21 | Assert.Equal(12, bySurface["global"]); |
| 22 | Assert.Equal(8, bySurface["mr-comment"]); |
| 23 | Assert.Equal(1, bySurface["issue-comment"]); |
| 24 | } |
| 25 | |
| 26 | [Fact] |
| 27 | public async Task Capabilities_commands_include_cide_path_aliases() |
| 28 | { |
| 29 | var caps = await factory.CreateClient().GetFromJsonAsync<JsonElement>("/api/v1/capabilities", JsonOptions); |
| 30 | var commands = caps.GetProperty("commands").EnumerateArray().ToList(); |
| 31 | var issueOpen = commands.Single(c => c.GetProperty("commandId").GetString() == "forge.issue.open"); |
| 32 | var aliases = issueOpen.GetProperty("pathAliases").EnumerateArray().Select(e => e.GetString()).ToList(); |
| 33 | |
| 34 | Assert.Contains("/forge issue open", aliases); |
| 35 | Assert.Equal("/issue open", issueOpen.GetProperty("path").GetString()); |
| 36 | } |
| 37 | |
| 38 | [Fact] |
| 39 | public async Task Capabilities_plugins_include_tier_and_command_count() |
| 40 | { |
| 41 | var caps = await factory.CreateClient().GetFromJsonAsync<JsonElement>("/api/v1/capabilities", JsonOptions); |
| 42 | var issue = caps.GetProperty("plugins").EnumerateArray() |
| 43 | .Single(p => p.GetProperty("id").GetString() == "issue"); |
| 44 | |
| 45 | Assert.Equal("core", issue.GetProperty("tier").GetString()); |
| 46 | Assert.Equal(5, issue.GetProperty("commandCount").GetInt32()); |
| 47 | } |
| 48 | |
| 49 | [Fact] |
| 50 | public async Task Health_reports_command_count_and_surface_breakdown() |
| 51 | { |
| 52 | var health = await factory.CreateClient().GetFromJsonAsync<JsonElement>("/health", JsonOptions); |
| 53 | Assert.Equal(14, health.GetProperty("commandCount").GetInt32()); |
| 54 | Assert.Equal(12, health.GetProperty("commandsBySurface").GetProperty("command-bar").GetInt32()); |
| 55 | |
| 56 | var issuePlugin = health.GetProperty("plugins").EnumerateArray() |
| 57 | .Single(p => p.GetProperty("id").GetString() == "issue"); |
| 58 | Assert.Equal("core", issuePlugin.GetProperty("tier").GetString()); |
| 59 | Assert.Equal(5, issuePlugin.GetProperty("commandCount").GetInt32()); |
| 60 | } |
| 61 | } |
| 62 | |