From 0c5c43d591fee30699f2cbf2918f5da267a3d717 Mon Sep 17 00:00:00 2001 From: npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w <52a228d6edf316ec6812ac3c9fc0d696ab59fc7954d77e7be31eedcddf91335b@sprout-oss.stage.blox.sqprod.co> Date: Mon, 8 Jun 2026 11:43:44 -0700 Subject: [PATCH] fix: auto-seed preview features in E2E mock bridge CI was failing 16 smoke tests (workflows.spec, channels.spec, smoke.spec, file-attachment.spec) because preview-gated UI (workflows, forum, pulse, projects) didn't render in mock-bridge tests. Tests clicked testIDs that were behind , timing out. - bridge.ts: seed sprout-feature-overrides-v1 in localStorage with all preview feature IDs enabled by default via addInitScript. New seedPreviewFeatures option (default true) opts out for specs that exercise the toggle UI itself. - screenshot-feature-flags.ts: pass seedPreviewFeatures: false so the Experiments toggle flow still drives each feature on via the UI. 59/59 affected smoke tests passing locally. Signed-off-by: Taylor Ho --- desktop/tests/e2e/screenshot-feature-flags.ts | 4 +- desktop/tests/helpers/bridge.ts | 39 ++++++++++++++++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/desktop/tests/e2e/screenshot-feature-flags.ts b/desktop/tests/e2e/screenshot-feature-flags.ts index 348651ddc9..a7119d318b 100644 --- a/desktop/tests/e2e/screenshot-feature-flags.ts +++ b/desktop/tests/e2e/screenshot-feature-flags.ts @@ -6,7 +6,9 @@ const WATERCOLOR_CHANNEL_ID = "a27e1ee9-76a6-5bdf-a5d5-1d85610dad11"; const FORUM_POST_ID = "mock-forum-release-thread"; test.beforeEach(async ({ page }) => { - await installMockBridge(page); + // This spec exercises the Experiments toggle flow itself (each preview + // feature is enabled via the settings UI), so don't pre-seed overrides. + await installMockBridge(page, undefined, { seedPreviewFeatures: false }); }); // Helper: enable a preview feature via settings, then close settings diff --git a/desktop/tests/helpers/bridge.ts b/desktop/tests/helpers/bridge.ts index d6d94b90a2..3b498d0004 100644 --- a/desktop/tests/helpers/bridge.ts +++ b/desktop/tests/helpers/bridge.ts @@ -97,11 +97,24 @@ type BridgeOptions = { relayHttpUrl?: string; relayWsUrl?: string; skipOnboardingSeed?: boolean; + /** + * When true (default), seed every preview feature in features.json as + * enabled in localStorage so E2E tests can interact with gated UI without + * clicking through the Experiments settings panel. Set to false in specs + * that test the toggle behavior itself (e.g. + * `screenshot-feature-flags.ts`). + */ + seedPreviewFeatures?: boolean; user?: keyof typeof TEST_IDENTITIES; }; const ONBOARDING_COMPLETION_STORAGE_KEY_PREFIX = "sprout-onboarding-complete.v1:"; +const FEATURE_OVERRIDES_STORAGE_KEY = "sprout-feature-overrides-v1"; +// Keep in sync with `tier: "preview"` entries in `/features.json`. E2E +// tests opt into all preview features by default so gated UI is reachable +// without clicking through Settings → Experiments on every spec. +const PREVIEW_FEATURE_IDS = ["workflows", "projects", "pulse", "forum"]; const DEFAULT_MOCK_PUBKEY = "deadbeef".repeat(8); const DEFAULT_RELAY_WS_URL = "ws://localhost:3000"; @@ -140,6 +153,17 @@ async function seedDefaultWorkspace(page: Page, relayWsUrl?: string) { ); } +async function seedPreviewFeaturesEnabled(page: Page) { + await page.addInitScript( + ({ key, ids }) => { + const overrides: Record = {}; + for (const id of ids) overrides[id] = true; + window.localStorage.setItem(key, JSON.stringify(overrides)); + }, + { key: FEATURE_OVERRIDES_STORAGE_KEY, ids: PREVIEW_FEATURE_IDS }, + ); +} + export async function installBridge(page: Page, options: BridgeOptions) { const identity = options.mode === "relay" @@ -152,6 +176,11 @@ export async function installBridge(page: Page, options: BridgeOptions) { if (!options.skipOnboardingSeed) { await seedOnboardingCompletionForKnownIdentities(page); } + // Default to opting every preview feature in. Specs that exercise the + // Experiments toggle UI itself pass `seedPreviewFeatures: false`. + if (options.seedPreviewFeatures !== false) { + await seedPreviewFeaturesEnabled(page); + } await page.addInitScript( ({ identity: bridgeIdentity, mock, mode, relayHttpUrl, relayWsUrl }) => { @@ -240,18 +269,24 @@ export async function installBridge(page: Page, options: BridgeOptions) { export async function installMockBridge( page: Page, mock?: MockBridgeOptions, - options?: { skipOnboardingSeed?: boolean }, + options?: { skipOnboardingSeed?: boolean; seedPreviewFeatures?: boolean }, ) { await installBridge(page, { mode: "mock", mock, skipOnboardingSeed: options?.skipOnboardingSeed, + seedPreviewFeatures: options?.seedPreviewFeatures, }); } export async function installRelayBridge( page: Page, user: keyof typeof TEST_IDENTITIES = "tyler", + options?: { seedPreviewFeatures?: boolean }, ) { - await installBridge(page, { mode: "relay", user }); + await installBridge(page, { + mode: "relay", + user, + seedPreviewFeatures: options?.seedPreviewFeatures, + }); }