Skip to content

Commit 4e48b66

Browse files
authored
Use signInGate switch (#14932)
* Use signInGate switch * test name
1 parent 126a3fb commit 4e48b66

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

dotcom-rendering/src/components/StickyBottomBanner/SignInGatePortal.test.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ const canShowProps: CanShowSignInGateProps = {
3232
describe('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);

dotcom-rendering/src/components/StickyBottomBanner/SignInGatePortal.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ export const canShowSignInGatePortal = async ({
164164
sectionId,
165165
tags,
166166
}: CanShowSignInGateProps): Promise<CanShowResult<AuxiaGateDisplayData>> => {
167+
if (!window.guardian.config.switches.signInGate) {
168+
// Gates are disabled from the Frontend switchboard
169+
return Promise.resolve({ show: false });
170+
}
171+
167172
// Check if the sign-in gate placeholder exists in the DOM
168173
const targetElement = document.getElementById('sign-in-gate');
169174

0 commit comments

Comments
 (0)