using System.Net; using System.Net.Http.Json; using Npgsql; using Xunit; namespace TeamUp.IntegrationTests; /// /// End-to-end skeleton proof: the web host boots, the platform migration applies (vector /// extension + the 7 module schemas), health is green, every module endpoint seam is wired, and /// the OpenAPI document is served. All tests share one container (sequential, same collection). /// [Collection(PostgresCollection.Name)] public sealed class BootAndMigrateTests(PostgresFixture postgres) { private static readonly string[] ExpectedSchemas = ["identity", "orgboard", "skills", "integrations", "memory", "assembler", "governance"]; [Fact] public async Task Health_endpoint_reports_200() { await using var factory = new TeamUpWebFactory(postgres.ConnectionString); using var client = factory.CreateClient(); var response = await client.GetAsync("/health"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); } [Fact] public async Task Startup_migration_creates_vector_extension_and_module_schemas() { await using var factory = new TeamUpWebFactory(postgres.ConnectionString); using (factory.CreateClient()) { // Creating the client forces the host to start, which applies the migration. } await using var connection = new NpgsqlConnection(postgres.ConnectionString); await connection.OpenAsync(); await using (var extensionCmd = new NpgsqlCommand("SELECT 1 FROM pg_extension WHERE extname = 'vector'", connection)) { Assert.NotNull(await extensionCmd.ExecuteScalarAsync()); } foreach (var schema in ExpectedSchemas) { await using var schemaCmd = new NpgsqlCommand( "SELECT 1 FROM information_schema.schemata WHERE schema_name = @schema", connection); schemaCmd.Parameters.AddWithValue("schema", schema); Assert.NotNull(await schemaCmd.ExecuteScalarAsync()); } } [Theory] [InlineData("identity")] [InlineData("orgboard")] [InlineData("skills")] [InlineData("integrations")] [InlineData("memory")] [InlineData("assembler")] [InlineData("governance")] public async Task Module_ping_endpoint_responds(string module) { await using var factory = new TeamUpWebFactory(postgres.ConnectionString); using var client = factory.CreateClient(); var response = await client.GetAsync($"/api/{module}/ping"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var payload = await response.Content.ReadFromJsonAsync(); Assert.NotNull(payload); Assert.Equal(module, payload!.Module); } [Fact] public async Task OpenApi_document_is_served() { await using var factory = new TeamUpWebFactory(postgres.ConnectionString); using var client = factory.CreateClient(); var response = await client.GetAsync("/openapi/v1.json"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); } private sealed record ModulePingResponse(string Module, string Status); }