From 62c25ff76afa5e813d8c22bbf2caef65708f2709 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <118168183+sharmrj@users.noreply.github.com> Date: Thu, 23 May 2024 06:10:07 +0530 Subject: [PATCH] MWPW-148609 [Project PEP] Optionally Bypass xLG for Testing (#2339) * Added a way to mock entitlements in non prod environments for testing purposes * Added the ability to debug pep in prod; added skipPepEntitlements option --- libs/features/webapp-prompt/webapp-prompt.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/features/webapp-prompt/webapp-prompt.js b/libs/features/webapp-prompt/webapp-prompt.js index 94181e390d..56d0a92584 100644 --- a/libs/features/webapp-prompt/webapp-prompt.js +++ b/libs/features/webapp-prompt/webapp-prompt.js @@ -50,7 +50,8 @@ class AppPrompt { init = async () => { if (this.isDismissedPrompt() || !this.parent) return; - const entMatch = await this.doesEntitlementMatch(); + const skipEntitlements = new URLSearchParams(window.location.search).get('skipPepEntitlements'); + const entMatch = skipEntitlements || await this.doesEntitlementMatch(); if (!entMatch) return; const content = await this.fetchContent(); @@ -84,7 +85,10 @@ class AppPrompt { }; doesEntitlementMatch = async () => { - const entitlements = await getConfig().entitlements(); + const config = getConfig(); + const entitlements = await config.entitlements(); + const extraEnts = new URLSearchParams(window.location.search).get('mockPepEnts'); + extraEnts?.split(',').forEach((ent) => entitlements.push(ent.trim())); return entitlements?.length && entitlements.includes(this.entName); };