diff --git a/support-frontend/assets/helpers/abTests/__tests__/abtestTest.ts b/support-frontend/assets/helpers/abTests/__tests__/abtestTest.ts index 69abf3c1b2..f63779e954 100644 --- a/support-frontend/assets/helpers/abTests/__tests__/abtestTest.ts +++ b/support-frontend/assets/helpers/abTests/__tests__/abtestTest.ts @@ -472,6 +472,29 @@ describe('init', () => { }); expect(participations.t1).toBeUndefined(); }); + + it(`does not assign a user to a test if audiences is CONTRIBUTIONS_ONLY and selectedAmountsVariant is undefined`, () => { + const abTests = { + t1: buildTest({ + variants: [ + buildVariant({ id: 'control' }), + buildVariant({ id: 'variant' }), + ], + audiences: { + CONTRIBUTIONS_ONLY: { + offset: 0, + size: 1, + }, + }, + }), + }; + const participations: Participations = abInit({ + ...abtestInitalizerData, + abTests, + selectedAmountsVariant: undefined, + }); + expect(participations.t1).toBeUndefined(); + }); }); describe('path matching', () => { diff --git a/support-frontend/assets/helpers/abTests/abtest.ts b/support-frontend/assets/helpers/abTests/abtest.ts index 731ceb08dc..1bd98f664c 100644 --- a/support-frontend/assets/helpers/abTests/abtest.ts +++ b/support-frontend/assets/helpers/abTests/abtest.ts @@ -203,7 +203,7 @@ function getParticipations( !!test.audiences.CONTRIBUTIONS_ONLY; /** - * We only exclude users assigned to the contributions only amounts test + * Exclude any users assigned to the contributions only amounts test * from an ab test if the ab test definition has excludeContributionsOnlyCountries as true * AND includeOnlyContributionsOnlyCountries is not true */ @@ -216,7 +216,7 @@ function getParticipations( } /** - * Exclude users NOT assigned to the contributions only amounts test + * Exclude defined users NOT assigned to the contributions only amounts test * if the the ab test definition has includeOnlyContributionsOnlyCountries as true */ if ( @@ -347,7 +347,7 @@ function getAmountsTestVariant( // Check if we actually want to track this test const pathMatches = targetPageMatches( path, - '/??/contribute|thankyou(/.*)?$', + '/??/checkout|one-time-checkout|contribute|thankyou(/.*)?$', ); if (pathMatches && test.variants.length > 1 && test.isLive) { diff --git a/support-frontend/assets/helpers/abTests/abtestDefinitions.ts b/support-frontend/assets/helpers/abTests/abtestDefinitions.ts index 6e672d9426..b911a2442a 100644 --- a/support-frontend/assets/helpers/abTests/abtestDefinitions.ts +++ b/support-frontend/assets/helpers/abTests/abtestDefinitions.ts @@ -152,7 +152,7 @@ export const tests: Tests = { size: 1, }, }, - isActive: false, + isActive: true, referrerControlled: false, // ab-test name not needed to be in paramURL seed: 9, targetPage: pageUrlRegexes.contributions.allLandingPagesAndThankyouPages, diff --git a/support-frontend/assets/helpers/page/page.ts b/support-frontend/assets/helpers/page/page.ts index 7b102f6ced..2beda9b452 100644 --- a/support-frontend/assets/helpers/page/page.ts +++ b/support-frontend/assets/helpers/page/page.ts @@ -27,17 +27,15 @@ function getAbParticipations(): Participations { const settings = getSettings(); const countryId: IsoCountry = Country.detect(); const countryGroupId: CountryGroupId = CountryGroup.detect(); + const { amountsParticipation, selectedAmountsVariant } = + getAmountsTestVariant(countryId, countryGroupId, settings); const abtestInitalizerData = { countryId, countryGroupId, + selectedAmountsVariant, }; - const participations: Participations = abTest.init(abtestInitalizerData); - const { amountsParticipation } = getAmountsTestVariant( - countryId, - countryGroupId, - settings, - ); + return { ...participations, ...amountsParticipation,