From 11abbfa71718b9ffbe49bfb4bc9e180795265008 Mon Sep 17 00:00:00 2001 From: Alina Boghiu Date: Fri, 2 Feb 2024 16:32:07 +0000 Subject: [PATCH] Remove local image content tests because we will NEVER render locally --- .../controllers/ImageContentController.scala | 5 ++- .../test/ImageContentControllerTest.scala | 35 ------------------- .../test/ImageContentTemplateTest.scala | 22 ------------ applications/test/package.scala | 2 -- 4 files changed, 4 insertions(+), 60 deletions(-) delete mode 100644 applications/test/ImageContentControllerTest.scala delete mode 100644 applications/test/ImageContentTemplateTest.scala diff --git a/applications/app/controllers/ImageContentController.scala b/applications/app/controllers/ImageContentController.scala index d56d2ccc39ad..3c3539d3f84a 100644 --- a/applications/app/controllers/ImageContentController.scala +++ b/applications/app/controllers/ImageContentController.scala @@ -4,15 +4,18 @@ import com.gu.contentapi.client.model.v1.{Block, ItemResponse, Content => ApiCon import com.gu.contentapi.client.model.{Direction, FollowingSearchQuery, SearchQuery} import common._ import conf.Configuration.contentApi +import conf.switches.Switches import contentapi.ContentApiClient import implicits.{AppsFormat, JsonFormat} import model._ import model.dotcomrendering.{DotcomRenderingDataModel, PageType} +import pages.ContentHtmlPage import play.api.libs.json._ import play.api.libs.ws.WSClient import play.api.mvc._ import renderers.DotcomRenderingService import services.ImageQuery +import services.dotcomrendering.RemoteRender import views.support.RenderOtherStatus import scala.concurrent.Future @@ -36,7 +39,7 @@ class ImageContentController( override def renderItem(path: String)(implicit request: RequestHeader): Future[Result] = image(Edition(request), path).flatMap { case Right((content, mainBlock)) => remoteRender(content, mainBlock) - case Left(result) => Future.successful(RenderOtherStatus(result)) + case Left(result) => Future.successful(RenderOtherStatus(result)) } private def getDCRJson(content: ImageContentPage, pageType: PageType, mainBlock: Option[Block])(implicit diff --git a/applications/test/ImageContentControllerTest.scala b/applications/test/ImageContentControllerTest.scala deleted file mode 100644 index 3529a05237ed..000000000000 --- a/applications/test/ImageContentControllerTest.scala +++ /dev/null @@ -1,35 +0,0 @@ -package test - -import controllers.ImageContentController -import org.scalatest.flatspec.AnyFlatSpec -import org.scalatest.matchers.should.Matchers -import play.api.test.Helpers._ -import org.scalatest.{BeforeAndAfterAll, DoNotDiscover} - -@DoNotDiscover class ImageContentControllerTest - extends AnyFlatSpec - with Matchers - with ConfiguredTestSuite - with BeforeAndAfterAll - with WithMaterializer - with WithTestWsClient - with WithTestApplicationContext - with WithTestContentApiClient { - - val cartoonUrl = "commentisfree/cartoon/2013/jul/15/iain-duncan-smith-benefits-cap" - val pictureUrl = "artanddesign/picture/2013/oct/08/photography" - - lazy val imageContentController = - new ImageContentController(testContentApiClient, play.api.test.Helpers.stubControllerComponents(), wsClient) - - "Image Content Controller" should "200 when content type is picture" in { - val result = imageContentController.render(pictureUrl)(TestRequest(pictureUrl)) - status(result) should be(200) - } - - "Image Content Controller" should "200 when content type is cartoon" in { - val result = imageContentController.render(cartoonUrl)(TestRequest(cartoonUrl)) - status(result) should be(200) - } - -} diff --git a/applications/test/ImageContentTemplateTest.scala b/applications/test/ImageContentTemplateTest.scala deleted file mode 100644 index 92dcb293581a..000000000000 --- a/applications/test/ImageContentTemplateTest.scala +++ /dev/null @@ -1,22 +0,0 @@ -package test -import org.scalatest.flatspec.AnyFlatSpec -import org.scalatest.matchers.should.Matchers - -import org.scalatest.DoNotDiscover - -@DoNotDiscover class ImageContentTemplateTest extends AnyFlatSpec with Matchers with ConfiguredTestSuite { - - it should "render a cartoon" in goTo("/commentisfree/cartoon/2013/jul/15/iain-duncan-smith-benefits-cap") { browser => - import browser._ - el("[itemprop='headline']").html().toString.trim should be( - "Steve Bell on Iain Duncan Smith and the benefits cap – cartoon", - ) - el(".media-primary img").attribute("src") should include("Steve-Bell-cartoon") - } - - it should "render a picture" in goTo("/artanddesign/picture/2013/oct/08/photography") { browser => - import browser._ - $("[itemprop='headline']").first().text() should be("Early erotica - a picture from the past") - el(".media-primary img").attribute("src") should include("French-Nude-in-Body-Stock") - } -} diff --git a/applications/test/package.scala b/applications/test/package.scala index 05ae91bbee48..c832d2c276df 100644 --- a/applications/test/package.scala +++ b/applications/test/package.scala @@ -23,8 +23,6 @@ class ApplicationsTestSuite new AllIndexTemplateTestLite, new GalleryControllerTest, new GalleryTemplateTest, - new ImageContentControllerTest, - new ImageContentTemplateTest, new IndexControllerTest, new CrosswordPageMetaDataTest, new IndexMetaDataTest,