diff --git a/support-frontend/app/admin/settings/LandingPageTest.scala b/support-frontend/app/admin/settings/LandingPageTest.scala index c8cacc7ab8..6d0d32a52b 100644 --- a/support-frontend/app/admin/settings/LandingPageTest.scala +++ b/support-frontend/app/admin/settings/LandingPageTest.scala @@ -15,8 +15,16 @@ object Status { implicit val statusDecoder = deriveEnumerationDecoder[Status] } +case class RegionTargeting( + targetedCountryGroups: List[String] = Nil, +) + +object RegionTargeting { + implicit val codec: Codec[RegionTargeting] = deriveCodec +} + case class LandingPageTestTargeting( - countryGroups: List[String], + regionTargeting: RegionTargeting, ) object LandingPageTestTargeting { diff --git a/support-frontend/assets/helpers/abTests/landingPageAbTests.ts b/support-frontend/assets/helpers/abTests/landingPageAbTests.ts index 94343f92c3..c444836b4b 100644 --- a/support-frontend/assets/helpers/abTests/landingPageAbTests.ts +++ b/support-frontend/assets/helpers/abTests/landingPageAbTests.ts @@ -44,8 +44,8 @@ export function getLandingPageParticipations( const test = tests .filter((test) => test.status == 'Live') .find((test) => { - const { countryGroups } = test.targeting; - return countryGroups.includes(countryGroupId); + const { targetedCountryGroups } = test.targeting.regionTargeting; + return targetedCountryGroups.includes(countryGroupId); }); if (test) { diff --git a/support-frontend/assets/helpers/globalsAndSwitches/landingPageSettings.ts b/support-frontend/assets/helpers/globalsAndSwitches/landingPageSettings.ts index 3789bbfef8..a882ebfdc7 100644 --- a/support-frontend/assets/helpers/globalsAndSwitches/landingPageSettings.ts +++ b/support-frontend/assets/helpers/globalsAndSwitches/landingPageSettings.ts @@ -10,6 +10,14 @@ export interface LandingPageVariant { copy: LandingPageCopy; } +interface RegionTargeting { + targetedCountryGroups: CountryGroupId[]; +} + +interface LandingPageTestTargeting { + regionTargeting: RegionTargeting; +} + interface LandingPageTestTargeting { countryGroups: CountryGroupId[]; } diff --git a/support-frontend/test/services/LandingPageTestServiceSpec.scala b/support-frontend/test/services/LandingPageTestServiceSpec.scala index bec9bb76be..e68faff050 100644 --- a/support-frontend/test/services/LandingPageTestServiceSpec.scala +++ b/support-frontend/test/services/LandingPageTestServiceSpec.scala @@ -1,6 +1,13 @@ package services -import admin.settings.{LandingPageCopy, LandingPageTest, LandingPageTestTargeting, LandingPageVariant, Status} +import admin.settings.{ + LandingPageCopy, + LandingPageTest, + LandingPageTestTargeting, + LandingPageVariant, + RegionTargeting, + Status, +} import org.scalatest.flatspec.AsyncFlatSpec import org.scalatest.matchers.should.Matchers import software.amazon.awssdk.services.dynamodb.model.AttributeValue @@ -18,10 +25,17 @@ class LandingPageTestServiceSpec extends AsyncFlatSpec with Matchers { .builder() .m( Map( - "countryGroups" -> AttributeValue + "regionTargeting" -> AttributeValue .builder() - .l( - AttributeValue.builder().s("GBPCountries").build(), + .m( + Map( + "targetedCountryGroups" -> AttributeValue + .builder() + .l( + AttributeValue.builder().s("GBPCountries").build(), + ) + .build(), + ).asJava, ) .build(), ).asJava, @@ -58,7 +72,9 @@ class LandingPageTestServiceSpec extends AsyncFlatSpec with Matchers { priority = 3, status = Status.Live, targeting = LandingPageTestTargeting( - countryGroups = List("GBPCountries"), + regionTargeting = RegionTargeting( + targetedCountryGroups = List("GBPCountries"), + ), ), variants = List( LandingPageVariant(