Skip to content

Commit

Permalink
Merge branch 'main' into ahe/remove-amazon-pay
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewHEguardian authored Jan 17, 2025
2 parents f57ce25 + 33ba1f5 commit e657cca
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
23 changes: 23 additions & 0 deletions support-frontend/assets/helpers/abTests/__tests__/abtestTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
6 changes: 3 additions & 3 deletions support-frontend/assets/helpers/abTests/abtest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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 (
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 4 additions & 6 deletions support-frontend/assets/helpers/page/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e657cca

Please sign in to comment.