@@ -32,6 +32,9 @@ const canShowProps: CanShowSignInGateProps = {
3232describe ( 'SignInGatePortal' , ( ) => {
3333 beforeEach ( ( ) => {
3434 jest . clearAllMocks ( ) ;
35+
36+ // Enable the switch for all tests
37+ window . guardian . config . switches . signInGate = true ;
3538 } ) ;
3639
3740 describe ( 'canShowSignInGatePortal' , ( ) => {
@@ -80,6 +83,39 @@ describe('SignInGatePortal', () => {
8083 expect ( result ) . toEqual ( { show : false } ) ;
8184 } ) ;
8285
86+ it ( 'should return false when signInGate is false' , async ( ) => {
87+ const mockElement = document . createElement ( 'div' ) ;
88+ mockGetElementById . mockReturnValue ( mockElement ) ;
89+
90+ window . guardian . config . switches . signInGate = false ;
91+
92+ // Mock buildAuxiaGateDisplayData to return auxiaData with userTreatment
93+ const auxiaReturn : AuxiaGateDisplayData = {
94+ browserId : 'browser-1' ,
95+ auxiaData : {
96+ responseId : 'resp1' ,
97+ userTreatment : {
98+ treatmentId : 't1' ,
99+ treatmentTrackingId : 'tt1' ,
100+ rank : '1' ,
101+ contentLanguageCode : 'en' ,
102+ treatmentContent : 'content' ,
103+ treatmentType : 'DISMISSABLE_SIGN_IN_GATE' ,
104+ surface : 'surface' ,
105+ } ,
106+ } ,
107+ } ;
108+ (
109+ buildAuxiaGateDisplayData as jest . MockedFunction <
110+ typeof buildAuxiaGateDisplayData
111+ >
112+ ) . mockResolvedValue ( auxiaReturn ) ;
113+
114+ const result = await canShowSignInGatePortal ( canShowProps ) ;
115+
116+ expect ( result ) . toEqual ( { show : false } ) ;
117+ } ) ;
118+
83119 it ( 'should return true when conditions are met for showing gate' , async ( ) => {
84120 const mockElement = document . createElement ( 'div' ) ;
85121 mockGetElementById . mockReturnValue ( mockElement ) ;
0 commit comments