@@ -22,11 +22,14 @@ import {
2222 useOnboardingContext ,
2323} from 'sentry/components/onboarding/onboardingContext' ;
2424import * as useRecentCreatedProjectHook from 'sentry/components/onboarding/useRecentCreatedProject' ;
25+ import { HookStore } from 'sentry/stores/hookStore' ;
2526import { OnboardingDrawerStore } from 'sentry/stores/onboardingDrawerStore' ;
2627import { ProjectsStore } from 'sentry/stores/projectsStore' ;
2728import { TeamStore } from 'sentry/stores/teamStore' ;
2829import type { PlatformKey } from 'sentry/types/project' ;
2930import { trackAnalytics } from 'sentry/utils/analytics' ;
31+ import type { UseExperimentOptions } from 'sentry/utils/useExperiment' ;
32+ import { useOrganization } from 'sentry/utils/useOrganization' ;
3033import { OnboardingWithoutContext } from 'sentry/views/onboarding/onboarding' ;
3134
3235jest . mock ( 'sentry/utils/analytics' ) ;
@@ -630,7 +633,7 @@ describe('Onboarding', () => {
630633
631634 describe ( 'SCM onboarding flow' , ( ) => {
632635 const scmOrganization = OrganizationFixture ( {
633- features : [ 'onboarding-scm' ] ,
636+ experiments : { 'onboarding-scm-experiment' : 'active' } ,
634637 } ) ;
635638
636639 const githubProvider = GitHubIntegrationProviderFixture ( {
@@ -646,7 +649,19 @@ describe('Onboarding', () => {
646649 link : 'https://docs.sentry.io/platforms/javascript/guides/nextjs/' ,
647650 } ;
648651
652+ // In production, gsApp's registerHooks() registers the real useExperiment
653+ // hook into HookStore. That doesn't run in tests, so useExperiment falls
654+ // back to a noop that always returns inExperiment: false. We register a
655+ // minimal implementation here (can't import the real one due to boundary
656+ // lint rules).
657+ function useTestExperiment ( options : UseExperimentOptions ) {
658+ const organization = useOrganization ( ) ;
659+ const assignment = organization . experiments ?. [ options . feature ] ?? 'control' ;
660+ return { inExperiment : assignment === 'active' , experimentAssignment : assignment } ;
661+ }
662+
649663 beforeEach ( ( ) => {
664+ HookStore . add ( 'react-hook:use-experiment' , useTestExperiment ) ;
650665 MockApiClient . addMockResponse ( {
651666 url : `/organizations/${ scmOrganization . slug } /config/integrations/` ,
652667 body : { providers : [ githubProvider ] } ,
@@ -661,6 +676,10 @@ describe('Onboarding', () => {
661676 } ) ;
662677 } ) ;
663678
679+ afterEach ( ( ) => {
680+ HookStore . remove ( 'react-hook:use-experiment' , useTestExperiment ) ;
681+ } ) ;
682+
664683 function renderOnboarding (
665684 step : string ,
666685 options ?: {
0 commit comments