Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into jlk/remove-extend-swi…
Browse files Browse the repository at this point in the history
…tches
  • Loading branch information
Jakeii committed Feb 28, 2024
2 parents fb490c7 + 780f145 commit a8d3549
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 35 deletions.
10 changes: 0 additions & 10 deletions common/app/experiments/Experiments.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,13 @@ object ActiveExperiments extends ExperimentsDefinition {
override val allExperiments: Set[Experiment] =
Set(
AdaptiveSite,
DeeplyRead,
CrosswordMobileBanner,
OphanNext,
DCRTagPages,
)
implicit val canCheckExperiment: CanCheckExperiment = new CanCheckExperiment(this)
}

object DeeplyRead
extends Experiment(
name = "deeply-read",
description = "When ON, deeply read footer section is displayed",
owners = Seq(Owner.withEmail("dotcom.platform@theguardian.com")),
sellByDate = LocalDate.of(2024, 2, 27),
participationGroup = Perc50,
)

object AdaptiveSite
extends Experiment(
name = "adaptive-site",
Expand Down
38 changes: 15 additions & 23 deletions facia/app/controllers/FaciaController.scala
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
package controllers

import common._
import _root_.html.{BrazeEmailFormatter, HtmlTextExtractor}
import agents.{DeeplyReadAgent, MostViewedAgent}
import common.JsonComponent.Ok
import common._
import conf.Configuration
import conf.switches.Switches.InlineEmailStyles
import controllers.front._
import layout.{CollectionEssentials, ContentCard, FaciaCard, FaciaCardAndIndex, FaciaContainer, Front}
import http.HttpPreconnections
import implicits.GUHeaders
import layout.slices._
import layout._
import model.Cached.{CacheableResult, RevalidatableResult, WithoutRevalidationResult}
import model._
import model.dotcomrendering.{DotcomFrontsRenderingDataModel, PageType}
import model.facia.PressedCollection
import model.pressed.CollectionConfig
import pages.{FrontEmailHtmlPage, FrontHtmlPage}
import play.api.libs.json._
import play.api.libs.ws.WSClient
import play.api.mvc._
import play.twirl.api.Html
import services.{CollectionConfigWithId, ConfigAgent}
import layout.slices._
import views.html.fragments.containers.facia_cards.container
import views.support.FaciaToMicroFormat2Helpers.getCollection
import conf.switches.Switches.InlineEmailStyles
import implicits.GUHeaders
import pages.{FrontEmailHtmlPage, FrontHtmlPage}
import utils.TargetedCollections
import conf.Configuration
import conf.switches.Switches
import contentapi.ContentApiClient
import play.api.libs.ws.WSClient
import renderers.DotcomRenderingService
import model.dotcomrendering.{DotcomFrontsRenderingDataModel, PageType}
import experiments.{ActiveExperiments, DeeplyRead}
import play.api.http.ContentTypes.JSON
import http.HttpPreconnections
import services.dotcomrendering.{FaciaPicker, RemoteRender}
import services.fronts.{FrontJsonFapi, FrontJsonFapiLive}
import services.{CollectionConfigWithId, ConfigAgent}
import utils.TargetedCollections
import views.html.fragments.containers.facia_cards.container
import views.support.FaciaToMicroFormat2Helpers.getCollection

import scala.concurrent.Future
import scala.concurrent.Future.successful
Expand Down Expand Up @@ -236,10 +231,7 @@ trait FaciaController
}

val networkFrontEdition = Edition.allEditions.find(_.networkFrontId == path)
val participatingInDeeplyReadTest = ActiveExperiments.isParticipating(DeeplyRead)
val deeplyRead = if (participatingInDeeplyReadTest) {
networkFrontEdition.map(deeplyReadAgent.getTrails)
} else None
val deeplyRead = networkFrontEdition.map(deeplyReadAgent.getTrails)

val futureResult = futureFaciaPage.flatMap {
case Some((faciaPage, _)) if nonHtmlEmail(request) =>
Expand Down
14 changes: 12 additions & 2 deletions facia/test/FaciaControllerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.scalatest._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import org.scalatestplus.mockito.MockitoSugar
import play.api.libs.json.JsArray
import play.api.libs.json.{JsArray, JsValue, Json}
import play.api.libs.ws.{WSClient, WSRequest, WSResponse}
import play.api.test.Helpers._
import play.api.test._
Expand Down Expand Up @@ -52,6 +52,7 @@ import scala.concurrent.{Await, Future}
val frontJson = FrontJson(Nil, None, None, None, None, None, None, None, None, None, None, None, None, None)

val responsiveRequest = FakeRequest().withHeaders("host" -> "www.theguardian.com")
val deeplyReadResults = "{}"

def mockWsResponse(): WSClient = {
val wsClient = mock[WSClient]
Expand All @@ -60,10 +61,19 @@ import scala.concurrent.{Await, Future}

when(mockResponse.status).thenReturn(200)
when(mockResponse.body).thenReturn("")
when(mockResponse.json).thenReturn(Json.parse(deeplyReadResults))

when(mockRequest.withRequestTimeout(any())).thenReturn(mockRequest)
when(mockRequest.post(anyString())(any())).thenReturn(Future.successful(mockResponse))
when(mockRequest.addHttpHeaders("Content-Type" -> "application/json")).thenReturn(mockRequest)

when(mockRequest.post(anyString())(any())).thenReturn(Future.successful(mockResponse))
when(mockRequest.get()).thenReturn(Future.successful(mockResponse))

when(wsClient.url("http://localhost:3030/Front")).thenReturn(mockRequest)
when(wsClient.url("https://localhost/deeplyread?country=gb&api-key=none")).thenReturn(mockRequest)
when(wsClient.url("https://localhost/deeplyread?country=us&api-key=none")).thenReturn(mockRequest)
when(wsClient.url("https://localhost/deeplyread?country=au&api-key=none")).thenReturn(mockRequest)
when(wsClient.url("https://localhost/deeplyread?country=international&api-key=none")).thenReturn(mockRequest)

wsClient
}
Expand Down

0 comments on commit a8d3549

Please sign in to comment.