From 5753c3d661c0bd0b0a84a5af9698cd8224a76cdb Mon Sep 17 00:00:00 2001 From: Paul Dempsey <76729591+paul-daniel-dempsey@users.noreply.github.com> Date: Mon, 28 Oct 2024 12:33:20 +0000 Subject: [PATCH] review: simplified to specify VariantId's needed --- support-frontend/assets/helpers/abTests/abtest.ts | 6 +----- .../assets/pages/[countryGroupId]/checkout.tsx | 4 +--- .../assets/pages/[countryGroupId]/components/thankyou.tsx | 8 ++------ 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/support-frontend/assets/helpers/abTests/abtest.ts b/support-frontend/assets/helpers/abTests/abtest.ts index d051a1a1a2..7df326a844 100644 --- a/support-frontend/assets/helpers/abTests/abtest.ts +++ b/support-frontend/assets/helpers/abTests/abtest.ts @@ -654,11 +654,7 @@ function targetPageMatches( return locationPath.match(targetPage) != null; } -function IsVariantIdInAbTest(variantId: string, abTestName: string): boolean { - return tests[abTestName].variants.some(({ id }) => id === variantId); -} - -export { init, getAmountsTestVariant, IsVariantIdInAbTest }; +export { init, getAmountsTestVariant }; // Exported for testing only export const _ = { diff --git a/support-frontend/assets/pages/[countryGroupId]/checkout.tsx b/support-frontend/assets/pages/[countryGroupId]/checkout.tsx index 8e9ba57f49..3a710f7fd2 100644 --- a/support-frontend/assets/pages/[countryGroupId]/checkout.tsx +++ b/support-frontend/assets/pages/[countryGroupId]/checkout.tsx @@ -44,7 +44,6 @@ import { findAddressesForPostcode } from 'components/subscriptionCheckouts/addre import { init as abTestInit, getAmountsTestVariant, - IsVariantIdInAbTest, } from 'helpers/abTests/abtest'; import { isContributionsOnlyCountry } from 'helpers/contributions'; import { simpleFormatAmount } from 'helpers/forms/checkouts'; @@ -465,9 +464,8 @@ function CheckoutComponent({ url contains '#ab-newspaperArchiveBenefit=v1/v2/control' for testing purposes */ const abParticipations = abTestInit({ countryId, countryGroupId }); - const showNewspaperArchiveBenefit = IsVariantIdInAbTest( + const showNewspaperArchiveBenefit = ['v1', 'v2', 'control'].includes( abParticipations.newspaperArchiveBenefit ?? '', - 'newspaperArchiveBenefit', ); const productDescription = showNewspaperArchiveBenefit diff --git a/support-frontend/assets/pages/[countryGroupId]/components/thankyou.tsx b/support-frontend/assets/pages/[countryGroupId]/components/thankyou.tsx index 1beec9d07b..4e39303446 100644 --- a/support-frontend/assets/pages/[countryGroupId]/components/thankyou.tsx +++ b/support-frontend/assets/pages/[countryGroupId]/components/thankyou.tsx @@ -9,10 +9,7 @@ import { Header } from 'components/headers/simpleHeader/simpleHeader'; import { PageScaffold } from 'components/page/pageScaffold'; import type { ThankYouModuleType } from 'components/thankYou/thankYouModule'; import { getThankYouModuleData } from 'components/thankYou/thankYouModuleData'; -import { - init as abTestInit, - IsVariantIdInAbTest, -} from 'helpers/abTests/abtest'; +import { init as abTestInit } from 'helpers/abTests/abtest'; import type { ContributionType } from 'helpers/contributions'; import type { AppConfig } from 'helpers/globalsAndSwitches/window'; import CountryHelper from 'helpers/internationalisation/classes/country'; @@ -204,9 +201,8 @@ export function ThankYouComponent({ url contains '#ab-newspaperArchiveBenefit=' for testing purposes */ const abParticipations = abTestInit({ countryId, countryGroupId }); - const showNewspaperArchiveBenefit = IsVariantIdInAbTest( + const showNewspaperArchiveBenefit = ['v1', 'v2', 'control'].includes( abParticipations.newspaperArchiveBenefit ?? '', - 'newspaperArchiveBenefit', ); const thankYouModuleData = getThankYouModuleData(