File tree Expand file tree Collapse file tree 4 files changed +21
-4
lines changed Expand file tree Collapse file tree 4 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ ADMINS=
106106MONTHLY_CRON_ENABLED =
107107
108108# Functional tests
109- E2E_TEST_ENV = local
109+ E2E_TEST_ENV = " not running e2e tests "
110110E2E_TEST_SECRET = test-secret
111111E2E_TEST_ACCOUNT_BASE_EMAIL = test-account
112112E2E_TEST_ACCOUNT_BASE_PASSWORD = test-password
Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ describe("getExperiments", () => {
9999 } ) ;
100100
101101 it ( "calls Cirrus V2 when feature flag is enabled with preview param" , async ( ) => {
102+ process . env . NEXT_RUNTIME = "test" ;
102103 process . env . NIMBUS_SIDECAR_URL = "https://cirrus.example" ;
103104 getEnabledFeatureFlagsMock . mockReturnValue ( [
104105 "CirrusV2" ,
@@ -188,7 +189,8 @@ describe("getExperiments", () => {
188189 ) ;
189190 } ) ;
190191
191- it ( "fallsback to defaultExperimentData when not experiment data is returned by Cirrus" , async ( ) => {
192+ it ( "fallsback to defaultExperimentData when no experiment data is returned by Cirrus" , async ( ) => {
193+ process . env . NEXT_RUNTIME = "test" ;
192194 process . env . NIMBUS_SIDECAR_URL = "https://cirrus.example" ;
193195 getEnabledFeatureFlagsMock . mockReturnValue ( [
194196 "CirrusV2" ,
Original file line number Diff line number Diff line change @@ -59,7 +59,13 @@ export async function getExperiments(params: {
5959 serverUrl . pathname += "v1/features" ;
6060 }
6161
62- const nextHeaders = await loadNextHeaders ( ) ;
62+ const nextHeaders =
63+ // We also check for experiments in cron jobs, where there are
64+ // no HTTP requests. Skip the headers there; we don't need to
65+ // force-enable experiments in cronjobs.
66+ typeof process . env . NEXT_RUNTIME === "string"
67+ ? await loadNextHeaders ( )
68+ : null ;
6369 let previewMode = false ;
6470 if ( nextHeaders ) {
6571 const headersList = await nextHeaders . headers ( ) ;
Original file line number Diff line number Diff line change @@ -92,7 +92,16 @@ export async function getEnabledFeatureFlags(
9292 options : { isSignedOut ?: false ; email : string } | { isSignedOut : true } ,
9393) : Promise < FeatureFlagName [ ] > {
9494 // Force feature flags for E2E tests via URL query params
95- if ( process . env . E2E_TEST_ENV === "local" ) {
95+ if (
96+ // Check that we're running under Next.js; in cronjobs
97+ // there's no request to inspect. We're not force-enabling
98+ // feature flags in that environment anyway.
99+ typeof process . env . NEXT_RUNTIME === "string" &&
100+ // When running end-to-end tests locally or in a PR,
101+ // we can force-enable feature flags that haven't been enabled
102+ // yet on stage or on prod:
103+ process . env . E2E_TEST_ENV === "local"
104+ ) {
96105 const { headers } = await import ( "next/headers" ) ;
97106 const forcedFeatureFlags = ( await headers ( ) ) . get ( "x-forced-feature-flags" ) ;
98107
You can’t perform that action at this time.
0 commit comments