From b5af620cd1c88f6d84388c3b8997c2427425b503 Mon Sep 17 00:00:00 2001 From: Anto Subash Date: Sat, 23 May 2026 23:41:54 +0200 Subject: [PATCH] fix(feature-flags): repair e2e tests broken by Products module removal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the Products module was removed (b2698964), its ProductsFeatures class (which implemented IModuleFeatures) was deleted. This left IFeatureFlagRegistry empty at runtime, so GET /api/feature-flags always returned [] — causing all 4 feature-flags-crud e2e tests to fail at the first assertion. Fix: add FeatureFlagsFeatures : IModuleFeatures to FeatureFlags.Contracts so the registry always contains at least one flag (FeatureFlags.OverrideManagement). The source generator auto-registers it, and GetAllFlagsAsync returns it from the in-memory registry even before FeatureFlagSyncService persists it to the DB. Also update both playwright.config.ts files to read PLAYWRIGHT_BASE_URL from the environment, enabling parallel agent test runs on separate ports. --- .../FeatureFlagsFeatures.cs | 8 ++++++++ .../FeatureFlags/src/SimpleModule.FeatureFlags/types.ts | 3 +++ playwright.config.ts | 9 ++++++--- tests/e2e/playwright.config.ts | 3 ++- 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 modules/FeatureFlags/src/SimpleModule.FeatureFlags.Contracts/FeatureFlagsFeatures.cs diff --git a/modules/FeatureFlags/src/SimpleModule.FeatureFlags.Contracts/FeatureFlagsFeatures.cs b/modules/FeatureFlags/src/SimpleModule.FeatureFlags.Contracts/FeatureFlagsFeatures.cs new file mode 100644 index 00000000..58fa5a10 --- /dev/null +++ b/modules/FeatureFlags/src/SimpleModule.FeatureFlags.Contracts/FeatureFlagsFeatures.cs @@ -0,0 +1,8 @@ +using SimpleModule.Core.FeatureFlags; + +namespace SimpleModule.FeatureFlags.Contracts; + +public sealed class FeatureFlagsFeatures : IModuleFeatures +{ + public const string OverrideManagement = "FeatureFlags.OverrideManagement"; +} diff --git a/modules/FeatureFlags/src/SimpleModule.FeatureFlags/types.ts b/modules/FeatureFlags/src/SimpleModule.FeatureFlags/types.ts index 09cf293d..623ca0a7 100644 --- a/modules/FeatureFlags/src/SimpleModule.FeatureFlags/types.ts +++ b/modules/FeatureFlags/src/SimpleModule.FeatureFlags/types.ts @@ -16,6 +16,9 @@ export interface FeatureFlagOverride { isEnabled: boolean; } +export interface FeatureFlagsFeatures { +} + export interface SetOverrideRequest { overrideType: any; overrideValue: string; diff --git a/playwright.config.ts b/playwright.config.ts index dc1a825c..7af63794 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -4,6 +4,9 @@ import { defineConfig, devices } from '@playwright/test'; * Root-level config that delegates to tests/e2e. * Allows `npx playwright test` from repo root to work correctly. */ + +const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? 'https://localhost:5001'; + export default defineConfig({ testDir: './tests/e2e/tests', fullyParallel: true, @@ -12,7 +15,7 @@ export default defineConfig({ workers: process.env.CI ? 1 : undefined, reporter: [['html', {}], ...(process.env.CI ? [['github', {}] as const] : [])], use: { - baseURL: 'https://localhost:5001', + baseURL, trace: 'on-first-retry', ignoreHTTPSErrors: true, screenshot: 'only-on-failure', @@ -44,13 +47,13 @@ export default defineConfig({ ], webServer: { command: 'dotnet run --project template/SimpleModule.Host', - url: 'https://localhost:5001/health/live', + url: `${baseURL}/health/live`, reuseExistingServer: true, ignoreHTTPSErrors: true, timeout: 60_000, env: { ...process.env, - ASPNETCORE_URLS: 'https://localhost:5001', + ASPNETCORE_URLS: baseURL, Database__DefaultConnection: 'Data Source=e2e-test.db', }, }, diff --git a/tests/e2e/playwright.config.ts b/tests/e2e/playwright.config.ts index f7e7d9db..5590aede 100644 --- a/tests/e2e/playwright.config.ts +++ b/tests/e2e/playwright.config.ts @@ -1,7 +1,8 @@ import { defineConfig, devices } from '@playwright/test'; const isCI = !!process.env.CI; -const baseURL = isCI ? 'http://localhost:5000' : 'https://localhost:5001'; +const baseURL = + process.env.PLAYWRIGHT_BASE_URL ?? (isCI ? 'http://localhost:5000' : 'https://localhost:5001'); export default defineConfig({ testDir: './tests',