Skip to content

Commit

Permalink
Merge pull request #476 from hmrc/ceds-6193-move-back-link-before-mai…
Browse files Browse the repository at this point in the history
…n-content

CEDS-6193 Place the 'Back' link before the <main> Html tag
  • Loading branch information
dhanist-gadhiraju authored Nov 22, 2024
2 parents 08dbfcd + dfe181f commit a547f99
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 8 deletions.
15 changes: 7 additions & 8 deletions app/views/components/gds/gds_main_template.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,19 @@
@if(betaBannerConfig.isBetaBannerEnabled) {
@phaseBanner("BETA")
}

@if(showLanguageSwitch && appConfig.languages.contains("cy")) {
@hmrcLanguageSelectHelper()
}
}

@content = {
<div class="govuk-back-link-div">
@backButton.map(back =>
govukBackLink(BackLink(
content = Text(back.title),
attributes = Map("id" -> "back-link"),
href = back.call.url
)))
@backButton.map(back =>
govukBackLink(BackLink(back.call.url, attributes = Map("id" -> "back-link"), content = Text(back.title)))
)
</div>
}

@content = {
@contentBlock
@hmrcReportTechnicalIssue()

Expand Down
49 changes: 49 additions & 0 deletions test/views/components/gds/GdsMainTemplateSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright 2024 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package views.components.gds

import base.Injector
import forms.{Choice, UcrType}
import models.UcrBlock
import models.requests.AuthenticatedRequest
import play.api.mvc.AnyContentAsEmpty
import play.api.test.FakeRequest
import testdata.CommonTestData.validEori
import testdata.MovementsTestData.newUser
import views.ViewSpec
import views.html.choice_on_consignment
import views.tags.ViewTest

@ViewTest
class GdsMainTemplateSpec extends ViewSpec with Injector {

private val choicePage = instanceOf[choice_on_consignment]

private implicit val request: AuthenticatedRequest[AnyContentAsEmpty.type] =
AuthenticatedRequest(FakeRequest().withCSRFToken, newUser(validEori))

"The Main template" should {

"have the 'Back' link placed before the main page content" in {
val view = choicePage(Choice.form, UcrBlock("ucr", UcrType.Ducr))

val backLink = "govuk-back-link"
view.getElementsByClass(backLink).size mustBe 1
view.getElementsByTag("main").first.getElementsByClass(backLink).size mustBe 0
}
}
}

0 comments on commit a547f99

Please sign in to comment.