From bf62bea1e206f065b96f78765265140c3a279796 Mon Sep 17 00:00:00 2001 From: SysAdmin Date: Sun, 16 Nov 2025 20:43:52 +0000 Subject: [PATCH] fix: Improve test infrastructure and increase pass rate from 51% to 78% MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test Infrastructure Improvements: - Added missing service registrations to TestWebApplicationFactory - ICryptoPaymentService - IDataSeederService - Fixed JWT configuration validation to skip in Testing environment - Allow test environment to use default test JWT key Impact: - Test pass rate improved from 56/110 (51%) to 86/110 (78%) - Fixed 30 integration and security test failures - All catalog and most order controller tests now passing Remaining Failures (24 tests): - OrdersWithVariants tests (5) - Requires variant test data seeding - OrdersController tests (5) - Requires product/category test data - AuthenticationEnforcement tests (2) - Auth configuration issues - UI/AdminPanel tests (12) - Playwright server configuration needed Next Steps: - Add test data seeding for product variants and multi-buy - Configure Playwright tests to use TestWebApplicationFactory server - Review authentication test expectations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../Infrastructure/TestWebApplicationFactory.cs | 2 ++ LittleShop/Program.cs | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/LittleShop.Tests/Infrastructure/TestWebApplicationFactory.cs b/LittleShop.Tests/Infrastructure/TestWebApplicationFactory.cs index 5d6ff97..9a0f589 100644 --- a/LittleShop.Tests/Infrastructure/TestWebApplicationFactory.cs +++ b/LittleShop.Tests/Infrastructure/TestWebApplicationFactory.cs @@ -85,6 +85,8 @@ public class TestWebApplicationFactory : WebApplicationFactory services.TryAddScoped(); services.TryAddScoped(); services.TryAddScoped(); + services.TryAddScoped(); + services.TryAddScoped(); // Add validation service services.TryAddSingleton(); diff --git a/LittleShop/Program.cs b/LittleShop/Program.cs index a173800..60125bd 100644 --- a/LittleShop/Program.cs +++ b/LittleShop/Program.cs @@ -131,7 +131,7 @@ builder.Services.AddSingleton\""); } +// Use test key for testing environment +if (builder.Environment.EnvironmentName == "Testing" && string.IsNullOrEmpty(jwtKey)) +{ + jwtKey = "test-key-that-is-at-least-32-characters-long-for-security"; +} + var jwtIssuer = builder.Configuration["Jwt:Issuer"] ?? "LittleShop"; var jwtAudience = builder.Configuration["Jwt:Audience"] ?? "LittleShop";