From 5a492d86004ae3a38550476842f86ee84e71cadb Mon Sep 17 00:00:00 2001 From: TomRafferty <86563641+TomRafferty@users.noreply.github.com> Date: Thu, 7 Nov 2024 14:39:27 +0000 Subject: [PATCH 1/3] MISUV-8500 - Re-implement dynamic inset text --- app/views/optOut/OptOutChooseTaxYear.scala.html | 8 ++++++++ conf/messages | 1 + conf/messages.cy | 1 + 3 files changed, 10 insertions(+) diff --git a/app/views/optOut/OptOutChooseTaxYear.scala.html b/app/views/optOut/OptOutChooseTaxYear.scala.html index ab6eb0ba9e..a8a6f82490 100644 --- a/app/views/optOut/OptOutChooseTaxYear.scala.html +++ b/app/views/optOut/OptOutChooseTaxYear.scala.html @@ -44,6 +44,10 @@ controllers.optOut.routes.OptOutChooseTaxYearController.submit(isAgent) } +@warningBlock = { + @govukInsetText(InsetText(id=Some("warning-inset"), content = HtmlContent(messages("optout.chooseOptOutTaxYear.submissions.deleted")))) +} + @formBlock = { @formWithCSRF(action = confirmOptOutPostUrl, Symbol("id") -> "confirm-multi-year-opt-out-form") { @govukRadios(Radios( @@ -98,6 +102,10 @@ @messages("optout.chooseOptOutTaxYear.desc") } + @if(submissionCounts.isQuarterlyUpdatesMade) { + @warningBlock + } + @formBlock } \ No newline at end of file diff --git a/conf/messages b/conf/messages index 3bc9b7f39f..2163153a39 100644 --- a/conf/messages +++ b/conf/messages @@ -2232,6 +2232,7 @@ optOut.confirmSingleYearOptOut.form.no-select.error = Select yes to opt optOut.ConfirmOptOutMultiTaxYearChoice.form.no-select.error = Select the tax year you want to report annually from # opt out choose tax year +optout.chooseOptOutTaxYear.submissions.deleted = Quarterly updates that you’ve submitted will be deleted from our records if you opt out from that tax year. You’ll need to include any income from these updates in your tax return. optout.chooseOptOutTaxYear.heading = Opting out of quarterly reporting optout.chooseOptOutTaxYear.desc = You can opt out from any of the tax years available and report annually from that year onwards. This means you’ll then report annually for all of your current businesses and any that you add in future. optout.chooseOptOutTaxYear.whichTaxYear = Which tax year do you want to opt out from? diff --git a/conf/messages.cy b/conf/messages.cy index d42282b7bc..351690a9f7 100644 --- a/conf/messages.cy +++ b/conf/messages.cy @@ -2172,6 +2172,7 @@ optOut.ConfirmOptOutMultiTaxYearChoice.form.no-select.error = Dewiswch y flwyddy # opt out choose tax year optout.chooseOptOutTaxYear.heading = Optio allan o adrodd yn chwarterol +optout.chooseOptOutTaxYear.submissions.deleted = Gallwch optio allan o unrhyw un o’r blynyddoedd treth sydd ar gael a chyflwyno adroddiadau yn flynyddol o’r flwyddyn dreth honno ymlaen. optout.chooseOptOutTaxYear.desc = Gallwch optio allan o unrhyw un o’r blynyddoedd treth sydd ar gael a chyflwyno adroddiadau yn flynyddol o’r flwyddyn honno ymlaen. Mae hyn yn golygu y byddwch yn adrodd yn flynyddol ar gyfer pob un o’ch busnesau cyfredol ac unrhyw fusnesau eraill y byddwch yn eu hychwanegu yn y dyfodol. optout.chooseOptOutTaxYear.whichTaxYear = eich cyfrif ar-lein CThEF meddalwedd cadw cofnodion sy’n cydweddu? optout.chooseOptOutTaxYear.taxYearOnwards = {0} i {1} ymlaen From 18bf0d21a827c6cfe2f65e9a3c56441dff9b44d1 Mon Sep 17 00:00:00 2001 From: TomRafferty <86563641+TomRafferty@users.noreply.github.com> Date: Fri, 8 Nov 2024 11:13:38 +0000 Subject: [PATCH 2/3] MISUV-8500 - added tests for optout warning insert (when should be shown) --- test/views/optOut/OptOutChooseTaxYearViewSpec.scala | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/views/optOut/OptOutChooseTaxYearViewSpec.scala b/test/views/optOut/OptOutChooseTaxYearViewSpec.scala index 42a82205c8..84b394b235 100644 --- a/test/views/optOut/OptOutChooseTaxYearViewSpec.scala +++ b/test/views/optOut/OptOutChooseTaxYearViewSpec.scala @@ -54,6 +54,8 @@ class OptOutChooseTaxYearViewSpec extends TestSupport { val cancelButtonHref: String = controllers.routes.NextUpdatesController.show().url val cancelButtonAgentHref: String = controllers.routes.NextUpdatesController.showAgent.url val continueButton: String = messages("optout.chooseOptOutTaxYear.continue") + val warningInsertMessage: String = messages("optout.chooseOptOutTaxYear.submissions.deleted") + val warningInsertClass: String = "govuk-inset-text" } "Opt-out confirm page" should { @@ -66,6 +68,16 @@ class OptOutChooseTaxYearViewSpec extends TestSupport { pageDocument.select("h1").text() shouldBe optOutChooseTaxYear.heading } + "show the warning block (for already having done submissions) user: non-agent" in new Setup(false) { + pageDocument.getElementById("warning-inset").text shouldBe optOutChooseTaxYear.warningInsertMessage + pageDocument.getElementById("warning-inset").className shouldBe optOutChooseTaxYear.warningInsertClass + } + + "show the warning block (for already having done submissions) user: agent" in new Setup(true) { + pageDocument.getElementById("warning-inset").text shouldBe optOutChooseTaxYear.warningInsertMessage + pageDocument.getElementById("warning-inset").className shouldBe optOutChooseTaxYear.warningInsertClass + } + "have the correct summary heading and page contents" in new Setup(false) { pageDocument.getElementById("description").text() shouldBe optOutChooseTaxYear.summary pageDocument.getElementById("whichTaxYear").child(0).text() shouldBe optOutChooseTaxYear.whichTaxYear From bd65b6cda5ae96ca5ab9930958dc1404b994fd14 Mon Sep 17 00:00:00 2001 From: TomRafferty <86563641+TomRafferty@users.noreply.github.com> Date: Fri, 8 Nov 2024 11:40:02 +0000 Subject: [PATCH 3/3] MISUV-8500 - added tests for optout warning insert (when shouldn't be shown) --- .../optOut/OptOutChooseTaxYearViewSpec.scala | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/views/optOut/OptOutChooseTaxYearViewSpec.scala b/test/views/optOut/OptOutChooseTaxYearViewSpec.scala index 84b394b235..f5dc943501 100644 --- a/test/views/optOut/OptOutChooseTaxYearViewSpec.scala +++ b/test/views/optOut/OptOutChooseTaxYearViewSpec.scala @@ -37,11 +37,17 @@ class OptOutChooseTaxYearViewSpec extends TestSupport { val availableOptOutTaxYearsList: List[String] = List(taxYear.toString) val submissionsCountForTaxYearModel: QuarterlyUpdatesCountForTaxYearModel = QuarterlyUpdatesCountForTaxYearModel(Seq(QuarterlyUpdatesCountForTaxYear(TaxYear.forYearEnd(2024), 6))) + val submissionsCountEmpty: QuarterlyUpdatesCountForTaxYearModel = + QuarterlyUpdatesCountForTaxYearModel(Seq()) class Setup(isAgent: Boolean = true) { val cancelURL = if (isAgent) controllers.routes.NextUpdatesController.showAgent.url else controllers.routes.NextUpdatesController.show().url val pageDocument: Document = Jsoup.parse(contentAsString(optOutChooseTaxYearView(ConfirmOptOutMultiTaxYearChoiceForm(availableOptOutTaxYearsList), availableOptOutTaxYear, submissionsCountForTaxYearModel, isAgent, cancelURL))) } + class SetupNoSubmissions(isAgent: Boolean = true) extends Setup{ + //This is for tests without previous tax submissions + override val pageDocument: Document = Jsoup.parse(contentAsString(optOutChooseTaxYearView(ConfirmOptOutMultiTaxYearChoiceForm(availableOptOutTaxYearsList), availableOptOutTaxYear, submissionsCountEmpty, isAgent, cancelURL))) + } object optOutChooseTaxYear { val heading: String = messages("optout.chooseOptOutTaxYear.heading") @@ -58,7 +64,7 @@ class OptOutChooseTaxYearViewSpec extends TestSupport { val warningInsertClass: String = "govuk-inset-text" } - "Opt-out confirm page" should { + "Opt-out confirm page (with submissions)" should { "have the correct title" in new Setup(false) { pageDocument.title() shouldBe optOutChooseTaxYear.title @@ -95,4 +101,16 @@ class OptOutChooseTaxYearViewSpec extends TestSupport { } } + + "Opt-out confirm page (with submissions)" should { + + "show the warning block (for no submissions) user: non-agent" in new SetupNoSubmissions(false) { + pageDocument.getElementById("warning-inset") shouldBe null + } + + "show the warning block (for no submissions) user: agent" in new SetupNoSubmissions(true) { + pageDocument.getElementById("warning-inset") shouldBe null + } + } } +