Skip to content

Commit c1a4b7a

Browse files
committed
fix(e2e): forward mock option from setRecipeFixture to configureDevServer
setRecipeFixture accepted a `mock` option in its call sites but silently discarded it — RecipeFixtureOptions had no `mock` property and the destructuring never extracted it. Since the e2e directory lacks a tsconfig, TypeScript couldn't catch the extra property. Without `mock` reaching configureDevServer: - createMockEnvFile was never called (no scenario env var) - The MSW entry point was never set (no fetch interception) - No session cookie injection occurred - account.tsx's isLoggedIn check always returned false - All authenticated tests redirected to /account/login The fix adds `mock` to RecipeFixtureOptions and forwards it through to configureDevServer, which already handles it correctly.
1 parent 7a3dda2 commit c1a4b7a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

e2e/fixtures/recipe.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {test, configureDevServer} from './index';
2+
import type {MswScenario} from './msw/scenarios';
23
import path from 'node:path';
34
import {
45
stat,
@@ -48,6 +49,14 @@ export type RecipeFixtureOptions = {
4849
* These override any defaults but don't override the test store env file.
4950
*/
5051
envOverrides?: Record<string, string>;
52+
/**
53+
* MSW mock scenario to enable session injection and API interception.
54+
* When set, the dev server starts with the MSW entry point and writes
55+
* the scenario name to the env file for runtime use.
56+
*/
57+
mock?: {
58+
scenario: MswScenario;
59+
};
5160
};
5261

5362
export const setRecipeFixture = (options: RecipeFixtureOptions) => {
@@ -56,6 +65,7 @@ export const setRecipeFixture = (options: RecipeFixtureOptions) => {
5665
storeKey = 'hydrogenPreviewStorefront',
5766
useCache = true,
5867
envOverrides = {},
68+
mock,
5969
} = options;
6070

6171
const isLocal = !storeKey.startsWith('https://');
@@ -87,6 +97,7 @@ export const setRecipeFixture = (options: RecipeFixtureOptions) => {
8797
configureDevServer({
8898
storeKey,
8999
projectPath: isLocal ? recipeFixturePath : undefined,
100+
mock,
90101
});
91102
};
92103

0 commit comments

Comments
 (0)