Skip to content

Commit

Permalink
[MIBM-145][PH] add TravellerDetailsPageSpec (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulHodgson authored Nov 2, 2020
1 parent 0ee39c3 commit 5af0b5f
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@
isPageHeading = false
)

@button("site.continue")
@button("site.continue", name=Some("continue"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import com.softwaremill.macwire.wire
import org.openqa.selenium.htmlunit.HtmlUnitDriver
import org.scalatestplus.selenium.WebBrowser
import uk.gov.hmrc.merchandiseinbaggagefrontend.model.core.{DeclarationJourney, GoodsDestination, GoodsVatRate, YesNo}
import uk.gov.hmrc.merchandiseinbaggagefrontend.pagespecs.pages.{RadioButtonPage, _}
import uk.gov.hmrc.merchandiseinbaggagefrontend.pagespecs.pages.{RadioButtonPage, TravellerDetailsPage, _}
import uk.gov.hmrc.merchandiseinbaggagefrontend.{BaseSpecWithApplication, CoreTestData, WireMockSupport}

trait BasePageSpec[P <: BasePage] extends BaseSpecWithApplication with WireMockSupport with CoreTestData {
Expand Down Expand Up @@ -55,6 +55,7 @@ trait BasePageSpec[P <: BasePage] extends BaseSpecWithApplication with WireMockS
lazy val agentDetailsPage: AgentDetailsPage = wire[AgentDetailsPage]
lazy val paymentCalculationPage: PaymentCalculationPage = wire[PaymentCalculationPage]
lazy val eoriNumberPage: EoriNumberPage = wire[EoriNumberPage]
lazy val travellerDetailsPage: TravellerDetailsPage = wire[TravellerDetailsPage]
lazy val journeyDetailsPage: JourneyDetailsPage = wire[JourneyDetailsPage]
lazy val vehicleRegistrationNumberPage: VehicleRegistrationNumberPage = wire[VehicleRegistrationNumberPage]
lazy val checkYourAnswersPage: CheckYourAnswersPage = wire[CheckYourAnswersPage]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class CustomsAgentPageSpec extends DeclarationDataCapturePageSpec[YesNo, RadioBu

"the page" should {
behave like aPageWhichRequiresADeclarationJourney(path)
behave like aDataCapturePageWithConditionalRouting(path, setup, Yes, AgentDetailsPage.path)
behave like aDataCapturePageWithConditionalRouting(path, setup, No, EoriNumberPage.path)
behave like aDataCapturePageWithConditionalRouting(path, setup(), Yes, AgentDetailsPage.path)
behave like aDataCapturePageWithConditionalRouting(path, setup(), No, EoriNumberPage.path)

"render correctly" when {
"the declaration has missing customs agent answer" in {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2020 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 uk.gov.hmrc.merchandiseinbaggagefrontend.pagespecs

import org.scalatest.concurrent.ScalaFutures
import uk.gov.hmrc.merchandiseinbaggagefrontend.model.core.{DeclarationJourney, Name}
import uk.gov.hmrc.merchandiseinbaggagefrontend.pagespecs.pages.{JourneyDetailsPage, TravellerDetailsPage}
import uk.gov.hmrc.merchandiseinbaggagefrontend.pagespecs.pages.TravellerDetailsPage._

class TravellerDetailsPageSpec extends DeclarationDataCapturePageSpec[Name, TravellerDetailsPage] with ScalaFutures {
override lazy val page: TravellerDetailsPage = travellerDetailsPage

"the traveller details page" should {
behave like aPageWhichRequiresADeclarationJourney(path)
behave like aPageWhichRenders(path, givenAnImportJourneyIsStarted(), title)
behave like aPageWhichDisplaysPreviouslyEnteredAnswers(path)
behave like aDataCapturePageWithSimpleRouting(path, givenAnImportJourneyIsStarted(), Seq(Name("Terry", "Test")), JourneyDetailsPage.path)
}

override def extractFormDataFrom(declarationJourney: DeclarationJourney): Option[Name] =
declarationJourney.maybeNameOfPersonCarryingTheGoods
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,38 @@
package uk.gov.hmrc.merchandiseinbaggagefrontend.pagespecs.pages

import org.openqa.selenium.WebDriver
import org.scalatest.Assertion
import org.scalatestplus.selenium.WebBrowser
import uk.gov.hmrc.merchandiseinbaggagefrontend.forms.TravellerDetailsForm
import uk.gov.hmrc.merchandiseinbaggagefrontend.model.core.Name

class TravellerDetailsPage(implicit webDriver: WebDriver) extends BasePage
class TravellerDetailsPage(implicit webDriver: WebDriver) extends DeclarationDataCapturePage[Name]{

import WebBrowser._

def firstNameInput: Element = find(NameQuery(TravellerDetailsForm.firstName)).get
def lastNameInput: Element = find(NameQuery(TravellerDetailsForm.lastName)).get

override def fillOutForm(formData: Name): Unit = {
def fill(input: Element, value: String): Unit = {
input.underlying.clear()
input.underlying.sendKeys(value)
}

fill(firstNameInput, formData.firstName)
fill(lastNameInput, formData.lastName)
}

override def previouslyEnteredValuesAreDisplayed(formData: Name): Assertion = {
def valueMustEqual(element: Element, value: String) =
element.underlying.getAttribute("value") mustBe value

valueMustEqual(firstNameInput, formData.firstName)
valueMustEqual(lastNameInput, formData.lastName)
}
}

object TravellerDetailsPage {
val path: String = "/merchandise-in-baggage/traveller-details"
val title: String = "Enter the name of the person carrying the goods"
}

0 comments on commit 5af0b5f

Please sign in to comment.