Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(test): resolve SelectExistingFeatureFlagModal race condition in CI (#61909)

mendral-app[bot]fe8b598bac1f
diff --git a/frontend/src/scenes/experiments/ExperimentForm/SelectExistingFeatureFlagModal.test.tsx b/frontend/src/scenes/experiments/ExperimentForm/SelectExistingFeatureFlagModal.test.tsx
index 5a706c5918d5..d5051af7b5cd 100644
--- a/frontend/src/scenes/experiments/ExperimentForm/SelectExistingFeatureFlagModal.test.tsx
+++ b/frontend/src/scenes/experiments/ExperimentForm/SelectExistingFeatureFlagModal.test.tsx
@@ -104,7 +104,11 @@ describe('SelectExistingFeatureFlagModal', () => {
logic.actions.openSelectExistingFeatureFlagModal()
+ // Wait for the feature flags data to be populated rather than just checking loading state.
+ // This avoids a race where `loadCurrentTeamSuccess` fires after the modal opens and
+ // triggers a second `loadFeatureFlags` call, briefly resetting loading back to true.
await waitFor(() => {
+ expect(logic.values.featureFlags.results.length).toBeGreaterThan(0)
expect(logic.values.featureFlagsLoading).toBe(false)
})