Skip to content

Commit

Permalink
Merge pull request #3939 from nationalarchives/TDRD-223-add-tna-user-…
Browse files Browse the repository at this point in the history
…holding-page

[TDRD 223] Add holding page for TNA user
  • Loading branch information
annielh authored Jun 11, 2024
2 parents 0bfe818 + 505e4c8 commit f4db120
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/controllers/HomepageController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class HomepageController @Inject() (
Redirect(routes.HomepageController.judgmentHomepage())
} else if (request.token.isStandardUser) {
Ok(views.html.standard.homepage(request.token.name))
} else if (request.token.isTNAUser) {
Ok(views.html.tna.homepage(request.token.name))
} else {
Ok(views.html.registrationComplete(request.token.name))
}
Expand Down
11 changes: 11 additions & 0 deletions app/views/tna/homepage.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@(name:String)(implicit messages: Messages, request: RequestHeader)
@defining("Welcome to the Transfer Digital Records service") { title =>
@main(title, name = name) {
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l govuk-!-margin-bottom-9">@title</h1>
<a href="#" role="button" draggable="false" class="govuk-button" data-module="govuk-button">Transfers for Review</a>
</div>
</div>
}
}
19 changes: 18 additions & 1 deletion test/controllers/HomepageControllerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class HomepageControllerSpec extends FrontEndTestHelper {
| View transfers
|</a>""".stripMargin

val transfersForReviewButton: String =
"""<a href="#" role="button" draggable="false" class="govuk-button" data-module="govuk-button">Transfers for Review</a>"""

"HomepageController GET" should {

"render the registration complete page with an authenticated user with no user type" in {
Expand Down Expand Up @@ -74,6 +77,7 @@ class HomepageControllerSpec extends FrontEndTestHelper {
checkPageForStaticElements.checkContentOfPagesThatUseMainScala(homepagePageAsString, userType = userType, consignmentExists = false)
checkForContentOnHomepagePage(homepagePageAsString, userType = userType)
homepagePageAsString must include(viewTransferButton)
homepagePageAsString must not include (transfersForReviewButton)
}

"render the judgment homepage page with an authenticated judgment user" in {
Expand All @@ -90,6 +94,20 @@ class HomepageControllerSpec extends FrontEndTestHelper {
checkPageForStaticElements.checkContentOfPagesThatUseMainScala(homepagePageAsString, userType = userType, consignmentExists = false)
checkForContentOnHomepagePage(homepagePageAsString, userType = userType)
homepagePageAsString must not include viewTransferButton
homepagePageAsString must not include (transfersForReviewButton)
}

"render the DTA review homepage page with an authenticated tna user" in {
val controller = new HomepageController(getAuthorisedSecurityComponents, getValidTNAUserKeycloakConfiguration, consignmentService)
val userType = "tna"
val homepagePage = controller.homepage().apply(FakeRequest(GET, "/homepage").withCSRFToken)
val homepagePageAsString = contentAsString(homepagePage)

status(homepagePage) mustBe OK
contentType(homepagePage) mustBe Some("text/html")

checkPageForStaticElements.checkContentOfPagesThatUseMainScala(homepagePageAsString, userType = userType, consignmentExists = false)
homepagePageAsString must include(transfersForReviewButton)
}

"return a redirect to the judgment homepage page with an authenticated judgment user" in {
Expand Down Expand Up @@ -199,6 +217,5 @@ class HomepageControllerSpec extends FrontEndTestHelper {
} else {
pageAsString must include("""<form action="/homepage" method="POST" novalidate="">""")
}

}
}
12 changes: 12 additions & 0 deletions test/testUtils/FrontEndTestHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,18 @@ trait FrontEndTestHelper extends PlaySpec with MockitoSugar with Injecting with
keycloakMock
}

def getValidTNAUserKeycloakConfiguration: KeycloakConfiguration = {
val keycloakMock = mock[KeycloakConfiguration]
val accessToken = new AccessToken()
accessToken.setOtherClaims("user_id", "c140d49c-93d0-4345-8d71-c97ff28b947e")
accessToken.setOtherClaims("tna_user", "true")
accessToken.setName("TNA Username")
accessToken.setEmail("[email protected]")
val token = Token(accessToken, new BearerAccessToken)
doAnswer(_ => Some(token)).when(keycloakMock).token(any[String])
keycloakMock
}

def getValidKeycloakConfigurationWithoutBody: KeycloakConfiguration = {
val keycloakMock = mock[KeycloakConfiguration]
val accessToken = new AccessToken()
Expand Down

0 comments on commit f4db120

Please sign in to comment.