Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2974a94
Moved agent test to the agent section (PR #516)
gianick Aug 22, 2025
f649ebb
Replaced "must include()" with "mustBe"
gianick Aug 22, 2025
cd1e9bf
Fixed views.repayments.RepaymentsConfirmationViewSpec
gianick Aug 22, 2025
12b8b2c
Added `lazy` to vals in Specs
gianick Aug 22, 2025
8a5b797
Removed duplicate title tests. Added check for H1 uniqueness
gianick Aug 22, 2025
625c549
Removed duplicate title tests. Added check for H1 uniqueness
gianick Aug 22, 2025
ed0cc62
Minor fixes to NfmContactNameViewSpec and NfmNameRegistrationViewSpec…
gianick Aug 22, 2025
31f6e7f
Removed duplicate title tests. Added check for H1 uniqueness. Fixed r…
gianick Aug 22, 2025
722ad0a
Minor improvements to NominateFilingMemberYesNoViewSpec
gianick Aug 22, 2025
06e918a
Minor improvements to IsNFMUKBasedViewSpec
gianick Aug 22, 2025
8a94b97
Fixed title tests. Added check for H1 uniqueness
gianick Aug 22, 2025
a21fde8
Fixed title tests. Added check for H1 uniqueness
gianick Aug 22, 2025
b85d39b
Used method to create pageTitle for title/h1 tests
gianick Aug 22, 2025
d718034
Linting
gianick Sep 5, 2025
078ce35
Fixed failing test that was using "must include" (SubCheckYourAnswers…
gianick Sep 5, 2025
d61f99c
Removed redundant tests from BankAccountDetailsViewSpec
gianick Sep 5, 2025
470a9b4
Fixed failing test RfmSecondaryPhonePreferenceViewSpec
gianick Sep 5, 2025
ad88386
Fixed failing RfmContactByPhoneViewSpec
gianick Sep 5, 2025
61a645b
Fixed tests in SecondaryContactEmailViewSpec
gianick Sep 5, 2025
596ddb8
Removed redundant tests from ReasonForRequestingRepaymentControllerSpec
gianick Sep 5, 2025
de4c4d1
Fixed wrong HTTP methods in ReasonForRequestingRepaymentControllerSpec
gianick Sep 5, 2025
0553d78
Removed redundant tests and tidied up ReasonForRequestingRepaymentCon…
gianick Sep 5, 2025
a9c0bad
Removing redundant tests
gianick Sep 9, 2025
9059611
Fixed Print Page link tests
gianick Oct 9, 2025
1a8a791
Fixing test with errors - Inconsistent title/heading
gianick Oct 9, 2025
476873c
Minor fixes
gianick Oct 9, 2025
37c870b
Linting
gianick Oct 16, 2025
ca0dc01
Removed fixes for RegistrationInViewProgress false-positive tests
gianick Oct 17, 2025
2f52dec
Fixed page title/h1 on RegistrationFailedNfmView
gianick Oct 17, 2025
e6c279e
Added PrintPage test to RepaymentsConfirmationViewSpec
gianick Oct 17, 2025
87abe46
Minor fixes to Print this Page link tests
gianick Oct 17, 2025
7a8fd39
Minor fixes to test titles
gianick Oct 17, 2025
8378ad5
Fixed PR review comments
gianick Oct 17, 2025
2bac8eb
Made tests more consistent by using mustBe
gianick Oct 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@()(implicit request: Request[_], appConfig: FrontendAppConfig, messages: Messages)

@layout(
pageTitle = titleNoForm(messages("task-list.title")),
pageTitle = titleNoForm(messages("grs.registration.error.title")),
showBackLink = false
) {
<h1 class="govuk-heading-l">@messages("grs.registration.error.header")</h1>
Expand Down
1 change: 1 addition & 0 deletions conf/messages.en
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ grs.registration.failed.line2 = Your company details could not be confirmed.
grs.registration.failed.line3-hyperlink = Go back to select the entity type
grs.registration.failed.line3-cont = to try again.

grs.registration.error.title = The details you entered did not match our records
grs.registration.error.header = The details you entered did not match our records
grs.registration.error.line1 = We could not match the details you entered with records held by HMRC.
grs.registration.error.line2 = How to confirm your details
Expand Down
28 changes: 14 additions & 14 deletions test/base/TestData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -348,20 +348,20 @@ trait TestData {

val validRepaymentDetails: String =
s"""{
| "nonUKBank": {
| "bankName": "Bank of UAE",
| "bic": "HBUKGB4B",
| "iban": "GB29NWBK60161331926819",
| "nameOnBankAccount": "Bank Account Name"
| },
| "reasonForRequestingRefund": "Reason for refund",
| "refundAmount": 100.99,
| "repaymentsContactByPhone": true,
| "repaymentsContactEmail": "[email protected]",
| "repaymentsContactName": "Contact name",
| "repaymentsPhoneDetails": "01234567890",
| "ukOrAbroadBankAccount": "nonUkBankAccount"
| }
| "nonUKBank": {
| "bankName": "Bank of UAE",
| "bic": "HBUKGB4B",
| "iban": "GB29NWBK60161331926819",
| "nameOnBankAccount": "Bank Account Name"
| },
| "reasonForRequestingRefund": "Reason for refund",
| "refundAmount": 100.99,
| "repaymentsContactByPhone": true,
| "repaymentsContactEmail": "[email protected]",
| "repaymentsContactName": "Contact name",
| "repaymentsPhoneDetails": "01234567890",
| "ukOrAbroadBankAccount": "nonUkBankAccount"
|}
""".stripMargin

}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class UpeRegisteredAddressControllerSpec extends SpecBase {

"a non-UK address" in {

val ua = defaultUa.set(UpeRegisteredAddressPage, postcodedNonUkAddress).success.value
val ua = defaultUa.set(UpeRegisteredAddressPage, postcodeNonUkAddress).success.value
val application: Application = applicationBuilder(Some(ua)).build()

running(application) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,40 +35,34 @@ import scala.concurrent.Future

class ReasonForRequestingRepaymentControllerSpec extends SpecBase {

val formProvider = new ReasonForRequestingRepaymentFormProvider()
lazy val formProvider: ReasonForRequestingRepaymentFormProvider = new ReasonForRequestingRepaymentFormProvider()

"ReasonForRequestingRefund Controller" when {
def getRouteUrl: String = controllers.repayments.routes.ReasonForRequestingRepaymentController.onPageLoad(NormalMode).url
def postRouteUrl: String = controllers.repayments.routes.ReasonForRequestingRepaymentController.onSubmit(NormalMode).url

"must return OK and the correct view for a GET" in {
"ReasonForRequestingRepaymentController" should {

"return OK and the correct view for a GET" in {
val application = applicationBuilder(userAnswers = Some(emptyUserAnswers)).build()

running(application) {
val request =
FakeRequest(GET, controllers.repayments.routes.ReasonForRequestingRepaymentController.onPageLoad(NormalMode).url)

val result = route(application, request).value

val view = application.injector.instanceOf[ReasonForRequestingRefundView]
val request = FakeRequest(GET, getRouteUrl)
val result = route(application, request).value
val view = application.injector.instanceOf[ReasonForRequestingRefundView]

status(result) mustEqual OK
contentAsString(result) mustEqual view(formProvider(), NormalMode)(request, applicationConfig, messages(application)).toString
}
}

"must populate the view correctly on a GET when the question has previously been answered" in {

"populate the view correctly on a GET when the question has previously been answered" in {
val userAnswers = UserAnswers(userAnswersId).set(ReasonForRequestingRefundPage, "answer").success.value

val application = applicationBuilder(userAnswers = Some(userAnswers)).build()

running(application) {
val request =
FakeRequest(GET, controllers.repayments.routes.ReasonForRequestingRepaymentController.onPageLoad(NormalMode).url)

val view = application.injector.instanceOf[ReasonForRequestingRefundView]

val result = route(application, request).value
val request = FakeRequest(GET, getRouteUrl)
val view = application.injector.instanceOf[ReasonForRequestingRefundView]
val result = route(application, request).value

status(result) mustEqual OK
contentAsString(result) mustEqual view(formProvider().fill("answer"), NormalMode)(
Expand All @@ -79,34 +73,27 @@ class ReasonForRequestingRepaymentControllerSpec extends SpecBase {
}
}

"must return a Bad Request and errors when invalid data is submitted" in {

"return a Bad Request and errors when invalid data is submitted" in {
val application = applicationBuilder(userAnswers = Some(emptyUserAnswers)).build()

running(application) {
val request =
FakeRequest(POST, controllers.repayments.routes.ReasonForRequestingRepaymentController.onPageLoad(NormalMode).url)
.withFormUrlEncodedBody(("value", ""))

val request = FakeRequest(POST, postRouteUrl).withFormUrlEncodedBody(("value", ""))
val boundForm = formProvider().bind(Map("value" -> ""))

val view = application.injector.instanceOf[ReasonForRequestingRefundView]

val result = route(application, request).value
val view = application.injector.instanceOf[ReasonForRequestingRefundView]
val result = route(application, request).value

status(result) mustEqual BAD_REQUEST
contentAsString(result) mustEqual view(boundForm, NormalMode)(request, applicationConfig, messages(application)).toString
}
}
"must update the user answers and redirect to the next page when the user answers has provided a valid answer" in {

"update the user answers and redirect to the next page when the user answers has provided a valid answer" in {
val expectedNextPage = Call(GET, "/")
val mockNavigator = mock[RepaymentNavigator]
when(mockNavigator.nextPage(any(), any(), any())).thenReturn(expectedNextPage)
when(mockSessionRepository.set(any())).thenReturn(Future.successful(true))

val userAnswers = emptyUserAnswers
.setOrException(ReasonForRequestingRefundPage, "valid reason")
val userAnswers = emptyUserAnswers.setOrException(ReasonForRequestingRefundPage, "valid reason")

val application = applicationBuilder(userAnswers = Some(userAnswers))
.overrides(
Expand All @@ -116,11 +103,8 @@ class ReasonForRequestingRepaymentControllerSpec extends SpecBase {
.build()

running(application) {
val request =
FakeRequest(POST, controllers.repayments.routes.ReasonForRequestingRepaymentController.onPageLoad(NormalMode).url)
.withFormUrlEncodedBody(("value", "valid reason"))

val result = route(application, request).value
val request = FakeRequest(POST, postRouteUrl).withFormUrlEncodedBody(("value", "valid reason"))
val result = route(application, request).value

status(result) mustEqual SEE_OTHER
redirectLocation(result).value mustEqual expectedNextPage.url
Expand All @@ -129,95 +113,5 @@ class ReasonForRequestingRepaymentControllerSpec extends SpecBase {
}
}

"must display character limit text when long text is entered" in {
val application = applicationBuilder(userAnswers = Some(emptyUserAnswers)).build()
running(application) {

val request =
FakeRequest(GET, controllers.repayments.routes.ReasonForRequestingRepaymentController.onPageLoad(NormalMode).url)

val result = route(application, request).value

status(result) mustEqual OK
contentAsString(result) must include("250 characters")
}
}

"must display field pre-populated with 242 characters that would result in 8 characters remaining" in {
val textWith242Chars =
"A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content."
val userAnswers = UserAnswers(userAnswersId).set(ReasonForRequestingRefundPage, textWith242Chars).success.value
val application = applicationBuilder(userAnswers = Some(userAnswers)).build()

running(application) {
val request =
FakeRequest(GET, controllers.repayments.routes.ReasonForRequestingRepaymentController.onPageLoad(NormalMode).url)

val result = route(application, request).value
val responseString = contentAsString(result)

status(result) mustEqual OK
textWith242Chars.length mustBe 242
val characterLimit = 250
val remainingChars = characterLimit - textWith242Chars.length
remainingChars mustBe 8
responseString must include(s">$textWith242Chars</textarea>")
responseString must include("data-maxlength=\"250\"")
}
}

"must display pre-populated repayment reason field when previously answered" in {
val longText =
"A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content."
val userAnswers = UserAnswers(userAnswersId).set(ReasonForRequestingRefundPage, longText).success.value
val application = applicationBuilder(userAnswers = Some(userAnswers)).build()

running(application) {
val request =
FakeRequest(GET, controllers.repayments.routes.ReasonForRequestingRepaymentController.onPageLoad(NormalMode).url)

val result = route(application, request).value

status(result) mustEqual OK
contentAsString(result) must include(longText)
}
}

"must display character count message when 8 characters remaining from acceptance test scenario" in {
val testText242Chars = "A" * 242
val userAnswers = UserAnswers(userAnswersId).set(ReasonForRequestingRefundPage, testText242Chars).success.value
val application = applicationBuilder(userAnswers = Some(userAnswers)).build()

running(application) {
val request =
FakeRequest(GET, controllers.repayments.routes.ReasonForRequestingRepaymentController.onPageLoad(NormalMode).url)

val result = route(application, request).value
val responseContent = contentAsString(result)

status(result) mustEqual OK
testText242Chars.length mustBe 242
responseContent must include(testText242Chars)
}
}

"must display Repayment reason field pre-populated with Test Refund from acceptance test scenario" in {
val testRefundReason = "Test Refund"
val userAnswers = UserAnswers(userAnswersId).set(ReasonForRequestingRefundPage, testRefundReason).success.value
val application = applicationBuilder(userAnswers = Some(userAnswers)).build()

running(application) {
val request =
FakeRequest(GET, controllers.repayments.routes.ReasonForRequestingRepaymentController.onPageLoad(NormalMode).url)

val result = route(application, request).value
val responseContent = contentAsString(result)

status(result) mustEqual OK
testRefundReason mustBe "Test Refund"
responseContent must include(">Test Refund</textarea>")
}
}

}
}
2 changes: 1 addition & 1 deletion test/helpers/UserAnswersFixture.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ trait UserAnswersFixture extends TryValues {
countryCode = "US"
)

val postcodedNonUkAddress: UKAddress = UKAddress(
val postcodeNonUkAddress: UKAddress = UKAddress(
addressLine1 = "132 My Street",
addressLine2 = None,
addressLine3 = "Kingston",
Expand Down
2 changes: 1 addition & 1 deletion test/pages/EntityTypePageSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package pages
import models.grs.EntityType
import pages.behaviours.PageBehaviours

class EntityTypeSpec extends PageBehaviours {
class EntityTypePageSpec extends PageBehaviours {

"EntityTypePage" - {

Expand Down
2 changes: 1 addition & 1 deletion test/views/CannotReturnAfterSubscriptionViewSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CannotReturnAfterSubscriptionViewSpec extends ViewSpecBase {

"display link section correctly" in {
val linkSection = view.getElementsByClass("govuk-body").last()
linkSection.text() mustEqual "You can now report and manage your Pillar 2 Top-up Taxes."
linkSection.text() mustBe "You can now report and manage your Pillar 2 Top-up Taxes."

val link = linkSection.getElementsByClass("govuk-link").first()
link.text() mustBe "report and manage your Pillar 2 Top-up Taxes."
Expand Down
10 changes: 4 additions & 6 deletions test/views/CheckYourAnswersViewSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import models.grs.EntityType
import models.subscription.AccountingPeriod
import models.{NonUKAddress, UKAddress, UserAnswers}
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.{Document, Element}
import org.jsoup.select.Elements
import org.mockito.Mockito.when
import pages._
Expand Down Expand Up @@ -278,11 +278,9 @@ class CheckYourAnswersViewSpec extends ViewSpecBase {
"new filing member for your group and the information is correct and complete to the best of your knowledge."
}

// FIXME:
"display print this page link" in {
val printLink = view.select("a:contains(Print this page)")
printLink.size() must be >= 1
printLink.first().text() must include("Print this page")
"have a 'Print this page' link" in {
val printPageElement: Element = view.getElementById("print-this-page")
printPageElement.getElementsByTag("a").text() mustBe "Print this page"
}

"have a button" in {
Expand Down
6 changes: 5 additions & 1 deletion test/views/HomepageViewSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class HomepageViewSpec extends ViewSpecBase {
"have a banner with a link to the Homepage" in {
val className: String = "govuk-header__link govuk-header__service-name"
organisationView.getElementsByClass(className).attr("href") mustBe routes.DashboardController.onPageLoad.url
agentView.getElementsByClass(className).attr("href") mustBe routes.DashboardController.onPageLoad.url
}

"display organisation information correctly" in {
Expand Down Expand Up @@ -523,6 +522,11 @@ class HomepageViewSpec extends ViewSpecBase {
h1Elements.text() mustBe pageHeading
}

"have a banner with a link to the Homepage" in {
val className: String = "govuk-header__link govuk-header__service-name"
agentView.getElementsByClass(className).attr("href") mustBe routes.DashboardController.onPageLoad.url
}

"display organisation information correctly" in {
val infoText: String = agentView.getElementsByClass("govuk-body").first().text()
infoText mustBe s"Group: $organisationName ID: $plrRef"
Expand Down
9 changes: 3 additions & 6 deletions test/views/MakeAPaymentDashboardViewSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ class MakeAPaymentDashboardViewSpec extends ViewSpecBase {
val elements = makePaymentDashboardView.getElementsByTag("a").listIterator().asScala.toList.filter(_.hasClass("govuk-button"))
elements must have size 1
val button = elements.head
button.attr("href") must equal(
"/report-pillar2-top-up-taxes/payment/redirect"
)
button.text() mustEqual "Pay Now"
button.attr("href") mustBe "/report-pillar2-top-up-taxes/payment/redirect"
button.text() mustBe "Pay Now"
}

"have the correct link to payment guidance" in {
Expand All @@ -70,9 +68,8 @@ class MakeAPaymentDashboardViewSpec extends ViewSpecBase {
.filter(_.text == "read more about other payment methods. (opens in a new tab)")
elements must have size 1
val guidancePageLink = elements.head
guidancePageLink.attr("href") must equal(
guidancePageLink.attr("href") mustBe
"https://www.gov.uk/guidance/pay-pillar-2-top-up-taxes-domestic-top-up-tax-and-multinational-top-up-tax"
)
}
}
}
Loading