Files
Teamup/tests/TeamUp.IntegrationTests/BootAndMigrateTests.cs
T
soroush.asadi e1911f58b1 M1: OrgBoard — organizations, teams, seats, the board & cartable
OrgBoard module (references SharedKernel only; RBAC via ICurrentUser/IPermissionService):
- Organization, Team, Seat (human/open/ai), WorkItem (board task: type, status, assignee,
  parent) entities; internal OrgBoardDbContext (schema "orgboard") + InitialOrgBoard
  migration; design-time factory. (WorkItem avoids the System.Threading.Tasks.Task clash.)
- Endpoints under /api/orgboard, every mutation permission-checked at the scope chain
  [team, org]: POST /organizations, POST/GET /teams, POST /tasks, GET /board (columns
  backlog->in progress->in review->done), PATCH /tasks/{id}/move, /assign, GET /cartable.

Test isolation: integration tests now use IClassFixture so each class gets its own
pgvector container (the bootstrap-once rule made a shared container collide).

Verified: build green; ArchitectureTests 8/8 (OrgBoard references only SharedKernel);
IntegrationTests 12/12 incl. a new board flow — owner sets up org+team, creates/moves/
assigns a task, sees it on the board and in the cartable; an invited Member can view the
board but is 403'd from creating a team.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 11:58:20 +03:30

91 lines
3.1 KiB
C#

using System.Net;
using System.Net.Http.Json;
using Npgsql;
using Xunit;
namespace TeamUp.IntegrationTests;
/// <summary>
/// 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).
/// </summary>
public sealed class BootAndMigrateTests(PostgresFixture postgres) : IClassFixture<PostgresFixture>
{
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<ModulePingResponse>();
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);
}