test(harness): stabilize backend+frontend QA test suite (12/12+63/63 unit+integration, 45/45 frontend)
Stabilize test harness across full stack: Backend integration tests: - Fix Auth/Club/Migration/RLS/Member/Tenant/RLS Isolation/Shift/Task test suites - Add AssemblyInfo.cs for test configuration - Enhance CustomWebApplicationFactory + TestAuthHandler for stable test environment - Expand RlsIsolationTests with comprehensive multi-tenant RLS verification Frontend test harness: - Align vitest.config.ts with backend API changes - Add bunfig.toml for bun test environment stability - Enhance api.test.ts with proper test setup integration - Expand test/setup.ts with fixture initialization All tests now passing: backend 12/12 unit + 63/63 integration, frontend 45/45
This commit is contained in:
@@ -51,11 +51,26 @@ public class CustomWebApplicationFactory<TProgram> : WebApplicationFactory<TProg
|
||||
services.AddAuthentication(defaultScheme: "Test")
|
||||
.AddScheme<AuthenticationSchemeOptions, TestAuthHandler>("Test", options => { });
|
||||
|
||||
// Build service provider and ensure database created
|
||||
// Build service provider and run migrations
|
||||
var sp = services.BuildServiceProvider();
|
||||
using var scope = sp.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
db.Database.EnsureCreated();
|
||||
db.Database.Migrate();
|
||||
|
||||
using var conn = new Npgsql.NpgsqlConnection(_postgresContainer.GetConnectionString());
|
||||
conn.Open();
|
||||
using var cmd = conn.CreateCommand();
|
||||
cmd.CommandText = @"
|
||||
DO $$ BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'rls_test_user') THEN
|
||||
CREATE USER rls_test_user WITH PASSWORD 'rlspass';
|
||||
GRANT CONNECT ON DATABASE workclub_test TO rls_test_user;
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO rls_test_user;
|
||||
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO rls_test_user;
|
||||
END IF;
|
||||
END $$;
|
||||
";
|
||||
cmd.ExecuteNonQuery();
|
||||
});
|
||||
|
||||
builder.UseEnvironment("Test");
|
||||
|
||||
Reference in New Issue
Block a user