Skip to content

Commit

Permalink
Merge pull request #520 from hmrc/TGP-2678/update-homepage
Browse files Browse the repository at this point in the history
TGP-2678: Amend messages to match ac
  • Loading branch information
Reece-Carruthers authored Oct 21, 2024
2 parents 4dfd12a + c2522fb commit 59f7297
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 17 deletions.
12 changes: 4 additions & 8 deletions app/controllers/HomePageController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,10 @@ class HomePageController @Inject() (
private def getDownloadLinkMessagesKey(opt: Option[DownloadDataSummary], doesGoodsRecordExist: Boolean): String =
if (doesGoodsRecordExist) {
opt.map(_.status) match {
case Some(FileInProgress) =>
"homepage.downloadLinkText.fileInProgress"
case Some(FileReadyUnseen) =>
"homepage.downloadLinkText.fileReady"
case Some(FileReadySeen) =>
"homepage.downloadLinkText.fileReady"
case _ =>
"homepage.downloadLinkText.requestFile"
case Some(FileInProgress) | Some(FileReadyUnseen) | Some(FileReadySeen) =>
"homepage.downloadLinkText.filesRequested"
case _ =>
"homepage.downloadLinkText.noFilesRequested"
}
} else {
"homepage.downloadLinkText.noGoodsRecords"
Expand Down
5 changes: 2 additions & 3 deletions conf/messages.en
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,9 @@ homepage.p6.linkText = Find additional support and contacts to help you
homepage.downloadBanner.important = Important
homepage.downloadBanner.content = The TGP records file you asked for is ready to download.
homepage.downloadBanner.linkText = Go to the TGP records file page to download the file
homepage.downloadLinkText.requestFile = Request a file of your TGP records
homepage.downloadLinkText.fileInProgress = Get an update on your TGP records file or request a new file
homepage.downloadLinkText.fileReady = Download your TGP records file or request a new file
homepage.downloadLinkText.noGoodsRecords = You do not have TGP goods records to download.
homepage.downloadLinkText.noFilesRequested = Get your TGP records file
homepage.downloadLinkText.filesRequested = Get or download your TGP records file

createRecordStart.title = Creating a goods record
createRecordStart.h1 = Creating a goods record
Expand Down
48 changes: 42 additions & 6 deletions test/controllers/HomePageControllerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class HomePageControllerSpec extends SpecBase {
status(result) mustEqual OK
contentAsString(result) mustEqual view(
downloadReady = true,
downloadLinkMessagesKey = "homepage.downloadLinkText.fileReady"
downloadLinkMessagesKey = "homepage.downloadLinkText.filesRequested"
)(request, messages(application)).toString
}
}
Expand Down Expand Up @@ -138,12 +138,48 @@ class HomePageControllerSpec extends SpecBase {
status(result) mustEqual OK
contentAsString(result) mustEqual view(
downloadReady = false,
downloadLinkMessagesKey = "homepage.downloadLinkText.fileReady"
downloadLinkMessagesKey = "homepage.downloadLinkText.filesRequested"
)(request, messages(application)).toString
}
}

"must return OK and the correct view for a GET with correct messageKey" - {
"when downloadDataSummary is None" in {
val mockTraderProfileConnector: TraderProfileConnector = mock[TraderProfileConnector]
when(mockTraderProfileConnector.checkTraderProfile(any())(any())) thenReturn Future.successful(true)

val mockDownloadDataConnector: DownloadDataConnector = mock[DownloadDataConnector]
when(mockDownloadDataConnector.getDownloadDataSummary(any())(any())) thenReturn Future.successful(
None
)

val mockGoodsRecordConnector: GoodsRecordConnector = mock[GoodsRecordConnector]
when(mockGoodsRecordConnector.getRecords(any(), any(), any())(any())) thenReturn Future
.successful(Some(goodsResponse))

val application = applicationBuilder(userAnswers = Some(emptyUserAnswers))
.overrides(
bind[TraderProfileConnector].toInstance(mockTraderProfileConnector),
bind[DownloadDataConnector].toInstance(mockDownloadDataConnector),
bind[GoodsRecordConnector].toInstance(mockGoodsRecordConnector)
)
.build()

running(application) {
val request = FakeRequest(GET, routes.HomePageController.onPageLoad().url)

val result = route(application, request).value

val view = application.injector.instanceOf[HomePageView]

status(result) mustEqual OK
contentAsString(result) mustEqual view(
downloadReady = false,
downloadLinkMessagesKey = "homepage.downloadLinkText.noFilesRequested"
)(request, messages(application)).toString
}
}

"when downloadDataSummary is RequestFile" in {
val downloadDataSummary = DownloadDataSummary(
testEori,
Expand Down Expand Up @@ -181,7 +217,7 @@ class HomePageControllerSpec extends SpecBase {
status(result) mustEqual OK
contentAsString(result) mustEqual view(
downloadReady = false,
downloadLinkMessagesKey = "homepage.downloadLinkText.requestFile"
downloadLinkMessagesKey = "homepage.downloadLinkText.noFilesRequested"
)(request, messages(application)).toString
}
}
Expand Down Expand Up @@ -223,7 +259,7 @@ class HomePageControllerSpec extends SpecBase {
status(result) mustEqual OK
contentAsString(result) mustEqual view(
downloadReady = false,
downloadLinkMessagesKey = "homepage.downloadLinkText.fileInProgress"
downloadLinkMessagesKey = "homepage.downloadLinkText.filesRequested"
)(request, messages(application)).toString
}
}
Expand Down Expand Up @@ -265,7 +301,7 @@ class HomePageControllerSpec extends SpecBase {
status(result) mustEqual OK
contentAsString(result) mustEqual view(
downloadReady = true,
downloadLinkMessagesKey = "homepage.downloadLinkText.fileReady"
downloadLinkMessagesKey = "homepage.downloadLinkText.filesRequested"
)(request, messages(application)).toString
}
}
Expand Down Expand Up @@ -307,7 +343,7 @@ class HomePageControllerSpec extends SpecBase {
status(result) mustEqual OK
contentAsString(result) mustEqual view(
downloadReady = false,
downloadLinkMessagesKey = "homepage.downloadLinkText.fileReady"
downloadLinkMessagesKey = "homepage.downloadLinkText.filesRequested"
)(request, messages(application)).toString
}
}
Expand Down

0 comments on commit 59f7297

Please sign in to comment.