Skip to content

Commit

Permalink
Resolve promise if E2E (#91407)
Browse files Browse the repository at this point in the history
  • Loading branch information
niranjan-uma-shankar authored Jun 4, 2024
1 parent 127f98a commit 40427c3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions client/lib/explat/internals/fetch-experiment-assignment.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isE2ETest } from 'calypso/lib/e2e';
import wpcom from 'calypso/lib/wp';

// SSR safety: Fail TypeScript compilation if `window` is used without an explicit undefined check
Expand All @@ -11,6 +12,17 @@ export default function fetchExperimentAssignment( {
experimentName: string;
anonId: string | null;
} ): Promise< unknown > {
if ( isE2ETest() ) {
return new Promise( ( resolve ) => {
resolve( {
variations: {
[ experimentName ]: null,
},
ttl: 60,
} );
} );
}

return wpcom.req.get(
{
path: '/experiments/0.1.0/assignments/calypso',
Expand Down

0 comments on commit 40427c3

Please sign in to comment.