Skip to content

Commit

Permalink
review: simplified to specify VariantId's needed
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-daniel-dempsey committed Oct 28, 2024
1 parent 133900c commit 5753c3d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
6 changes: 1 addition & 5 deletions support-frontend/assets/helpers/abTests/abtest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 _ = {
Expand Down
4 changes: 1 addition & 3 deletions support-frontend/assets/pages/[countryGroupId]/checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -204,9 +201,8 @@ export function ThankYouComponent({
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 thankYouModuleData = getThankYouModuleData(
Expand Down

0 comments on commit 5753c3d

Please sign in to comment.