Skip to content

Commit 6ea6c95

Browse files
authored
Merge pull request #14447 from guardian/ph-20250823-1630-gate-upgrades
clarify and ensure sign-in gate specs
2 parents 5cf6c69 + 2be23b3 commit 6ea6c95

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

dotcom-rendering/src/components/SignInGate/displayRules.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ export const hasRequiredConsents = (): Promise<boolean> =>
5858
.then(({ canTarget }: ConsentState) => canTarget)
5959
.catch(() => false);
6060

61+
export const pageMetaDataMakesItEligibleForGateDisplay = (
62+
contentType: string,
63+
sectionId: string | undefined,
64+
tags: TagType[],
65+
): boolean => {
66+
return (
67+
isValidContentType(contentType) &&
68+
isValidSection(sectionId) &&
69+
isValidTag(tags)
70+
);
71+
};
72+
6173
export const canShowSignInGate = ({
6274
isSignedIn,
6375
currentTest,
@@ -66,23 +78,30 @@ export const canShowSignInGate = ({
6678
tags,
6779
isPaidContent,
6880
isPreview,
69-
}: CanShowGateProps): Promise<boolean> =>
70-
Promise.resolve(
81+
}: CanShowGateProps): Promise<boolean> => {
82+
// This check is functionally identical to the same check in SDC
83+
// This logically ensures that SDC will get a subset of the pages for which
84+
// pageMetaDataMakesItEligibleForGateDisplay return true
85+
if (
86+
!pageMetaDataMakesItEligibleForGateDisplay(contentType, sectionId, tags)
87+
) {
88+
return Promise.resolve(false);
89+
}
90+
91+
return Promise.resolve(
7192
!isSignedIn &&
7293
!hasUserDismissedGateMoreThanCount(
7394
currentTest.variant,
7495
currentTest.name,
7596
5,
7697
) &&
7798
isNPageOrHigherPageView(3) &&
78-
isValidContentType(contentType) &&
79-
isValidSection(sectionId) &&
80-
isValidTag(tags) &&
8199
// hide the sign in gate on isPaidContent
82100
!isPaidContent &&
83101
// hide the sign in gate on internal tools preview &&
84102
!isPreview,
85103
);
104+
};
86105

87106
export const canShowSignInGateMandatory: ({
88107
isSignedIn,

0 commit comments

Comments
 (0)