<commit_before>/*
 * Copyright 2019 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.renewal

import models.status.{ReadyForRenewal, RenewalSubmitted}
import org.joda.time.LocalDate
import org.scalatest.MustMatchers
import play.api.i18n.Messages
import utils.Strings.TextHelpers
import utils.{DateHelper, AmlsSpec}
import views.Fixture

class renewal_progressSpec extends AmlsSpec with MustMatchers{

  trait ViewFixture extends Fixture {
    implicit val requestWithToken = addToken(request)

    val renewalDate = LocalDate.now().plusDays(15)

    val readyForRenewal = ReadyForRenewal(Some(renewalDate))
    val renewalSubmitted = RenewalSubmitted(Some(renewalDate))
  }

  "The renewal progress view" must {

    "Have the correct title and headings " in new ViewFixture {

      override def view = views.html.renewal.renewal_progress(Seq.empty, true, true, readyForRenewal)

      doc.title must startWith(Messages("renewal.progress.title"))

      doc.title must be(Messages("renewal.progress.title") +
        " - " + Messages("summary.status") +
        " - " + Messages("title.amls") +
        " - " + Messages("title.gov"))
      heading.html must be(Messages("renewal.progress.title"))
    }

    "enable the submit registration button when can submit and renewal section complete" in new ViewFixture {
      override def view = views.html.renewal.renewal_progress(Seq.empty, canSubmit = true, msbOrTcspExists = true, readyForRenewal, renewalSectionCompleted = true)

      doc.select("form button[name=submit]").hasAttr("disabled") mustBe false

      html must include (Messages("renewal.progress.ready.to.submit.intro"))

      doc.getElementsMatchingOwnText(Messages("renewal.progress.edit")).attr("href") must be(controllers.renewal.routes.SummaryController.get().url)
    }

    "not have the submit registration button when cannot submit because renewal section not complete" in new ViewFixture {
      override def view = views.html.renewal.renewal_progress(Seq.empty, canSubmit = false, msbOrTcspExists = true, readyForRenewal, renewalSectionCompleted = false)

      html must include (Messages("renewal.progress.submit.intro"))

      doc.select(".application-submit form button[name=submit]").isEmpty mustBe true

      doc.getElementsMatchingOwnText(Messages("renewal.progress.continue")).attr("href") must be(controllers.renewal.routes.WhatYouNeedController.get().url)
    }

    "not show the submit registration button when cannot submit and renewal section complete" in new ViewFixture {
      override def view = views.html.renewal.renewal_progress(Seq.empty, canSubmit = false, msbOrTcspExists = true, readyForRenewal, renewalSectionCompleted = true)

      doc.select("form button[name=submit]").isEmpty mustBe true

      doc.getElementsMatchingOwnText(Messages("renewal.progress.edit")).attr("href") must be(controllers.renewal.routes.SummaryController.get().url)
    }

    "show intro text" in new ViewFixture {

      override def view = views.html.renewal.renewal_progress(Seq.empty, false, true, readyForRenewal)

      html must include (Messages("renewal.progress.intro", DateHelper.formatDate(renewalDate)).convertLineBreaks)
    }

    "show ready to submit renewal when information are completed" in new ViewFixture {

      override def view = views.html.renewal.renewal_progress(Seq.empty, false, true, readyForRenewal, true)

      doc.select("#renewal-information-completed").get(0).text() must be(Messages("renewal.progress.information.completed.info"))
//      html must include (Messages("renewal.progress.ready.to.submit.intro"))
    }

    "show submit renewal link and text when information are not completed yet" in new ViewFixture {

      override def view = views.html.renewal.renewal_progress(Seq.empty, false, true, readyForRenewal, false)

      val space = " "
      val fullStop = "."

      val expectedText = s"${Messages("renewal.progress.information.not.completed.info.part1")}" +
                         s"$space" +
                         s"${Messages("renewal.progress.information.not.completed.info.part2")}" +
                         s"$fullStop"

      doc.select("#renewal-information-not-completed").get(0).text() must be(expectedText)
      doc.select("#renewal-information-not-completed a").attr("href") must be(controllers.renewal.routes.WhatYouNeedController.get().url)
//      html must include (Messages("renewal.progress.submit.intro"))
    }


  }

}<commit_msg>AMLS-4515 | enabled test again<commit_after>/*
 * Copyright 2019 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.renewal

import models.status.{ReadyForRenewal, RenewalSubmitted}
import org.joda.time.LocalDate
import org.scalatest.MustMatchers
import play.api.i18n.Messages
import utils.Strings.TextHelpers
import utils.{DateHelper, AmlsSpec}
import views.Fixture

class renewal_progressSpec extends AmlsSpec with MustMatchers{

  trait ViewFixture extends Fixture {
    implicit val requestWithToken = addToken(request)

    val renewalDate = LocalDate.now().plusDays(15)

    val readyForRenewal = ReadyForRenewal(Some(renewalDate))
    val renewalSubmitted = RenewalSubmitted(Some(renewalDate))
  }

  "The renewal progress view" must {

    "Have the correct title and headings " in new ViewFixture {

      override def view = views.html.renewal.renewal_progress(Seq.empty, true, true, readyForRenewal)

      doc.title must startWith(Messages("renewal.progress.title"))

      doc.title must be(Messages("renewal.progress.title") +
        " - " + Messages("summary.status") +
        " - " + Messages("title.amls") +
        " - " + Messages("title.gov"))
      heading.html must be(Messages("renewal.progress.title"))
    }

    "enable the submit registration button when can submit and renewal section complete" in new ViewFixture {
      override def view = views.html.renewal.renewal_progress(Seq.empty, canSubmit = true, msbOrTcspExists = true, readyForRenewal, renewalSectionCompleted = true)

      doc.select("form button[name=submit]").hasAttr("disabled") mustBe false

      html must include (Messages("renewal.progress.ready.to.submit.intro"))

      doc.getElementsMatchingOwnText(Messages("renewal.progress.edit")).attr("href") must be(controllers.renewal.routes.SummaryController.get().url)
    }

    "not have the submit registration button when cannot submit because renewal section not complete" in new ViewFixture {
      override def view = views.html.renewal.renewal_progress(Seq.empty, canSubmit = false, msbOrTcspExists = true, readyForRenewal, renewalSectionCompleted = false)

      html must include (Messages("renewal.progress.submit.intro"))

      doc.select(".application-submit form button[name=submit]").isEmpty mustBe true

      doc.getElementsMatchingOwnText(Messages("renewal.progress.continue")).attr("href") must be(controllers.renewal.routes.WhatYouNeedController.get().url)
    }

    "not show the submit registration button when cannot submit and renewal section complete" in new ViewFixture {
      override def view = views.html.renewal.renewal_progress(Seq.empty, canSubmit = false, msbOrTcspExists = true, readyForRenewal, renewalSectionCompleted = true)

      doc.select("form button[name=submit]").isEmpty mustBe true

      doc.getElementsMatchingOwnText(Messages("renewal.progress.edit")).attr("href") must be(controllers.renewal.routes.SummaryController.get().url)
    }

    "show intro text" in new ViewFixture {

      override def view = views.html.renewal.renewal_progress(Seq.empty, false, true, readyForRenewal)

      html must include (Messages("renewal.progress.intro", DateHelper.formatDate(renewalDate)).convertLineBreaks)
    }

    "show ready to submit renewal when information are completed" in new ViewFixture {

      override def view = views.html.renewal.renewal_progress(Seq.empty, false, true, readyForRenewal, true)

      doc.select("#renewal-information-completed").get(0).text() must be(Messages("renewal.progress.information.completed.info"))
//      html must include (Messages("renewal.progress.ready.to.submit.intro"))
    }

    "show submit renewal link and text when information are not completed yet" in new ViewFixture {

      override def view = views.html.renewal.renewal_progress(Seq.empty, false, true, readyForRenewal, false)

      val space = " "
      val fullStop = "."

      val expectedText = s"${Messages("renewal.progress.information.not.completed.info.part1")}" +
                         s"$space" +
                         s"${Messages("renewal.progress.information.not.completed.info.part2")}" +
                         s"$fullStop"

      doc.select("#renewal-information-not-completed").get(0).text() must be(expectedText)
      doc.select("#renewal-information-not-completed a").attr("href") must be(controllers.renewal.routes.WhatYouNeedController.get().url)
      html must include (Messages("renewal.progress.submit.intro"))
    }


  }

}
{'fraction_non_alphanumeric': 0.10650414626835848, 'fraction_numerical': 0.00359676291337796, 'mean_word_length': 3.985059760956175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5316514', 'n_tokens_mistral': 2996, 'n_tokens_neox': 2754, 'n_words': 723}