diff --git a/applications/app/services/TagPagePicker.scala b/applications/app/services/TagPagePicker.scala index 6d3c4db9099a..9da234f40b14 100644 --- a/applications/app/services/TagPagePicker.scala +++ b/applications/app/services/TagPagePicker.scala @@ -1,7 +1,7 @@ package services.dotcomrendering import common.GuLogging -import experiments.{ActiveExperiments, DCRTagPages} +import conf.switches.Switches.DCRTagPages import implicits.Requests._ import model.TagCombiner import play.api.mvc.RequestHeader @@ -10,7 +10,7 @@ import services.IndexPage object TagPagePicker extends GuLogging { def getTier(tagPage: IndexPage)(implicit request: RequestHeader): RenderType = { - lazy val participatingInTest = ActiveExperiments.isParticipating(DCRTagPages) + lazy val isSwitchedOn = DCRTagPages.isSwitchedOn; val checks = dcrChecks(tagPage) @@ -19,11 +19,11 @@ object TagPagePicker extends GuLogging { request.isJson, request.forceDCROff, request.forceDCR, - participatingInTest, + isSwitchedOn, dcrCouldRender(checks), ) - logTier(tagPage, participatingInTest, dcrCouldRender(checks), checks, tier) + logTier(tagPage, isSwitchedOn, dcrCouldRender(checks), checks, tier) tier } @@ -45,7 +45,7 @@ object TagPagePicker extends GuLogging { isJson: Boolean, forceDCROff: Boolean, forceDCR: Boolean, - participatingInTest: Boolean, + isSwitchedOn: Boolean, dcrCouldRender: Boolean, ): RenderType = { if (isRss) LocalRender @@ -55,13 +55,13 @@ object TagPagePicker extends GuLogging { else LocalRender } else if (forceDCROff) LocalRender else if (forceDCR) RemoteRender - else if (dcrCouldRender && participatingInTest) RemoteRender + else if (dcrCouldRender && isSwitchedOn) RemoteRender else LocalRender } private def logTier( tagPage: IndexPage, - participatingInTest: Boolean, + isSwitchedOn: Boolean, dcrCouldRender: Boolean, checks: Map[String, Boolean], tier: RenderType, @@ -73,8 +73,7 @@ object TagPagePicker extends GuLogging { } val properties = Map( - "participatingInTest" -> participatingInTest.toString, - "testPercentage" -> DCRTagPages.participationGroup.percentage, + "isSwitchedOn" -> isSwitchedOn.toString, "dcrCouldRender" -> dcrCouldRender.toString, "isTagPage" -> "true", "tier" -> tierReadable, diff --git a/applications/test/AllIndexControllerTest.scala b/applications/test/AllIndexControllerTest.scala index 8465e57a8ff1..eb489792cfcb 100644 --- a/applications/test/AllIndexControllerTest.scala +++ b/applications/test/AllIndexControllerTest.scala @@ -108,7 +108,9 @@ import play.api.test.Helpers._ it should "correctly serve all pages for `default editionalised sections` in the International edition" in { val result = - allIndexController.all("commentisfree")(TestRequest("/commentisfree/all").withHeaders("X-Gu-Edition" -> "INT")) + allIndexController.all("commentisfree")( + TestRequest("/commentisfree/all?dcr=false").withHeaders("X-Gu-Edition" -> "INT"), + ) status(result) should be(OK) } diff --git a/applications/test/IndexControllerTest.scala b/applications/test/IndexControllerTest.scala index c490d72570d2..91c7e1f786ed 100644 --- a/applications/test/IndexControllerTest.scala +++ b/applications/test/IndexControllerTest.scala @@ -36,7 +36,7 @@ import play.api.libs.ws.WSClient ) "Index Controller" should "200 when content type is front" in { - val result = indexController.render(section)(TestRequest(s"/$section")) + val result = indexController.render(section)(TestRequest(s"/$section?dcr=false")) status(result) should be(200) } @@ -112,14 +112,14 @@ import play.api.libs.ws.WSClient } it should "not accidentally truncate tags that contain valid strings that are also editions" in { - val request = FakeRequest(GET, "/uk/london?page=2") + val request = FakeRequest(GET, "/uk/london?page=2&dcr=false") val result = indexController.render("uk/london")(request) status(result) should be(200) } it should "not add editions to section tags" in { - val request = FakeRequest(GET, "/sport?page=2") + val request = FakeRequest(GET, "/sport?page=2&dcr=false") val result = indexController.render("sport")(request) status(result) should be(200) diff --git a/applications/test/IndexMetaDataTest.scala b/applications/test/IndexMetaDataTest.scala index 6fd215158274..89f0212cec65 100644 --- a/applications/test/IndexMetaDataTest.scala +++ b/applications/test/IndexMetaDataTest.scala @@ -35,32 +35,32 @@ import play.api.test.Helpers._ ) it should "Include organisation metadata" in { - val result = indexController.render(articleUrl)(TestRequest(articleUrl)) + val result = indexController.render(articleUrl)(TestRequest(s"$articleUrl?dcr=false")) MetaDataMatcher.ensureOrganisation(result) } it should "Include webpage metadata" in { - val result = indexController.render(articleUrl)(TestRequest(articleUrl)) + val result = indexController.render(articleUrl)(TestRequest(s"$articleUrl?dcr=false")) MetaDataMatcher.ensureWebPage(result, articleUrl) } it should "Include app deep link" in { - val result = indexController.render(articleUrl)(TestRequest(articleUrl)) + val result = indexController.render(articleUrl)(TestRequest(s"$articleUrl?dcr=false")) MetaDataMatcher.ensureDeepLink(result) } it should "Not include app deep link on the crosswords index" in { - val result = indexController.render(crosswordsUrl)(TestRequest(crosswordsUrl)) + val result = indexController.render(crosswordsUrl)(TestRequest(s"$crosswordsUrl?dcr=false")) MetaDataMatcher.ensureNoDeepLink(result) } it should "not include webpage metadata on the crossword index" in { - val result = indexController.render(crosswordsUrl)(TestRequest(crosswordsUrl)) + val result = indexController.render(crosswordsUrl)(TestRequest(s"$crosswordsUrl?dcr=false")) MetaDataMatcher.ensureNoIosUrl(result) } it should "Include item list metadata" in { - val result = indexController.render(articleUrl)(TestRequest(articleUrl)) + val result = indexController.render(articleUrl)(TestRequest(s"$articleUrl?dcr=false")) val body = Jsoup.parseBodyFragment(contentAsString(result)) status(result) should be(200) diff --git a/applications/test/SectionTemplateTest.scala b/applications/test/SectionTemplateTest.scala index c8238897c1f6..c969679eddb7 100644 --- a/applications/test/SectionTemplateTest.scala +++ b/applications/test/SectionTemplateTest.scala @@ -11,22 +11,23 @@ import scala.jdk.CollectionConverters._ @DoNotDiscover class SectionTemplateTest extends AnyFlatSpec with Matchers with ConfiguredTestSuite { - it should "render front title" in goTo("/uk-news") { browser => + it should "render front title" in goTo("/uk-news?dcr=false") { browser => browser.el("[data-test-id=header-title]").text should be("UK news") } - it should "add alternate pages to editionalised sections for /uk/culture" in goTo("/uk/culture") { browser => - val alternateLinks = getAlternateLinks(browser) - alternateLinks.size should be(3) - alternateLinks.exists(link => - toPath(link.attribute("href")) == "/us/culture" && link.attribute("hreflang") == "en-US", - ) should be(true) - alternateLinks.exists(link => - toPath(link.attribute("href")) == "/au/culture" && link.attribute("hreflang") == "en-AU", - ) should be(true) - alternateLinks.exists(link => - toPath(link.attribute("href")) == "/uk/culture" && link.attribute("hreflang") == "en-GB", - ) should be(true) + it should "add alternate pages to editionalised sections for /uk/culture" in goTo("/uk/culture?dcr=false") { + browser => + val alternateLinks = getAlternateLinks(browser) + alternateLinks.size should be(3) + alternateLinks.exists(link => + toPath(link.attribute("href")) == "/us/culture" && link.attribute("hreflang") == "en-US", + ) should be(true) + alternateLinks.exists(link => + toPath(link.attribute("href")) == "/au/culture" && link.attribute("hreflang") == "en-AU", + ) should be(true) + alternateLinks.exists(link => + toPath(link.attribute("href")) == "/uk/culture" && link.attribute("hreflang") == "en-GB", + ) should be(true) } @@ -40,7 +41,7 @@ import scala.jdk.CollectionConverters._ }) } - it should "not add alternate pages to non editionalised sections" in goTo("/books") { browser => + it should "not add alternate pages to non editionalised sections" in goTo("/books?dcr=false") { browser => val alternateLinks = getAlternateLinks(browser) alternateLinks should be(empty) } diff --git a/applications/test/TagFeatureTest.scala b/applications/test/TagFeatureTest.scala index 13372087d353..7809e4427b1e 100644 --- a/applications/test/TagFeatureTest.scala +++ b/applications/test/TagFeatureTest.scala @@ -17,7 +17,7 @@ import org.scalatest.matchers.should.Matchers Given("I visit a tag page") - goTo("/technology/askjack") { browser => + goTo("/technology/askjack?dcr=false") { browser => val trails = browser.$(".fc-item__container") trails.asScala.length should be(IndexPagePagination.pageSize) } @@ -31,7 +31,7 @@ import org.scalatest.matchers.should.Matchers Given("I visit the 'Jemima Kiss' contributor page") Switches.ImageServerSwitch.switchOn() - goTo("/profile/jemimakiss") { browser => + goTo("/profile/jemimakiss?dcr=false") { browser => Then("I should see her profile image") val profileImage = browser.el("[data-test-id=header-image]") profileImage.attribute("src") should include(s"42593747/Jemima-Kiss.jpg") @@ -41,7 +41,7 @@ import org.scalatest.matchers.should.Matchers Scenario("Should not not display profiles where they don't exist") { Given("I visit the 'Sam Jones' contributor page") - goTo("/profile/samjones") { browser => + goTo("/profile/samjones?dcr=false") { browser => Then("I should not see her profile image") val profileImages = browser.find(".profile__img img") profileImages.asScala.length should be(0) @@ -65,7 +65,7 @@ import org.scalatest.matchers.should.Matchers Given("I visit the 'Cycling' tag page") - goTo("/sport/cycling") { browser => + goTo("/sport/cycling?dcr=false") { browser => import browser._ val cardsOnFirstPage = browser.find("[data-test-id=facia-card]") @@ -96,7 +96,7 @@ import org.scalatest.matchers.should.Matchers Given("I visit page 2 of the 'Cycling' tag page") - goTo("/sport/cycling?page=2") { browser => + goTo("/sport/cycling?page=2&dcr=false") { browser => import browser._ val cardsOnNextPage = browser.find("[data-test-id=facia-card]") diff --git a/applications/test/TagTemplateTest.scala b/applications/test/TagTemplateTest.scala index 549fa051e8db..15dcee9bfdb1 100644 --- a/applications/test/TagTemplateTest.scala +++ b/applications/test/TagTemplateTest.scala @@ -6,7 +6,7 @@ import org.scalatest.matchers.should.Matchers @DoNotDiscover class TagTemplateTest extends AnyFlatSpec with Matchers with ConfiguredTestSuite { - it should "render tag headline" in goTo("/world/turkey") { browser => + it should "render tag headline" in goTo("/world/turkey?dcr=false") { browser => browser.el("[data-test-id=header-title]").text should be("Turkey") } } diff --git a/common/app/conf/switches/FeatureSwitches.scala b/common/app/conf/switches/FeatureSwitches.scala index 84075240ca74..182c5b7f63d3 100644 --- a/common/app/conf/switches/FeatureSwitches.scala +++ b/common/app/conf/switches/FeatureSwitches.scala @@ -524,4 +524,14 @@ trait FeatureSwitches { sellByDate = never, exposeClientSide = false, ) + + val DCRTagPages = Switch( + group = SwitchGroup.Feature, + name = "dcr-tag-pages", + description = "Render tag pages with DCR", + owners = Seq(Owner.withGithub("dotcom.platform@theguardian.com")), + safeState = On, + sellByDate = never, + exposeClientSide = false, + ) } diff --git a/common/app/experiments/Experiments.scala b/common/app/experiments/Experiments.scala index 15b6e8e0d6d8..d93ab442379f 100644 --- a/common/app/experiments/Experiments.scala +++ b/common/app/experiments/Experiments.scala @@ -12,7 +12,6 @@ object ActiveExperiments extends ExperimentsDefinition { override val allExperiments: Set[Experiment] = Set( DarkModeWeb, - DCRTagPages, UpdatedHeaderDesign, UpdateLogoAdPartner, MastheadWithHighlights, @@ -58,15 +57,6 @@ object UpdateLogoAdPartner participationGroup = Perc0A, ) -object DCRTagPages - extends Experiment( - name = "dcr-tag-pages", - description = "Render tag pages with DCR", - owners = Seq(Owner.withGithub("dotcom.platform@theguardian.com")), - sellByDate = LocalDate.of(2024, 5, 31), - participationGroup = Perc20A, - ) - object TagLinkDesign extends Experiment( name = "tag-link-design", diff --git a/facia/test/FaciaMetaDataTest.scala b/facia/test/FaciaMetaDataTest.scala index f338e7e2e77c..40f3700cdbcd 100644 --- a/facia/test/FaciaMetaDataTest.scala +++ b/facia/test/FaciaMetaDataTest.scala @@ -60,12 +60,12 @@ import scala.concurrent.duration._ } it should "Include webpage metadata" in { - val result = faciaController.renderFront(frontPath)(TestRequest(frontPath)) + val result = faciaController.renderFront(frontPath)(TestRequest(s"$frontPath?dcr=false")) MetaDataMatcher.ensureWebPage(result, frontPath) } it should "Include item list metadata" in { - val result = faciaController.renderFront(frontPath)(TestRequest(frontPath)) + val result = faciaController.renderFront(frontPath)(TestRequest(s"$frontPath?dcr=false")) val body = Jsoup.parseBodyFragment(contentAsString(result)) status(result) should be(200)