<commit_before>package controllers.s7_employment

import org.specs2.mutable.{Tags, Specification}
import play.api.test.WithBrowser
import controllers.{ClaimScenarioFactory, WithBrowserHelper, BrowserMatchers}
import utils.pageobjects._
import utils.pageobjects.s7_employment._
import utils.pageobjects.s8_self_employment.G1AboutSelfEmploymentPage
import scala.Some
import utils.pageobjects.s1_2_claim_date.G1ClaimDatePageContext

class G2BeenEmployedIntegrationSpec extends Specification with Tags {
  "Been Employed" should {
    "present, having indicated that the carer has been employed" in new WithBrowser with WithBrowserHelper with BrowserMatchers with EmployedSinceClaimDate {
    beginClaim()

      goTo("/employment/been-employed")
      back
      titleMustEqual("Employer Details - Employment History")
    }

    """be bypassed and go onto "other money" having indicated that "employment" is not required.""" in new WithBrowser with WithBrowserHelper with BrowserMatchers with NotEmployedSinceClaimDate {
      beginClaim()

      goTo("/employment/been-employed")

      titleMustEqual("Benefits and payments - About Other Money")
    }

    """progress to next section i.e. "self employed".""" in new WithBrowser with WithBrowserHelper with BrowserMatchers {
      goTo("/employment/been-employed")

      next
      titleMustEqual("Your job - About self-employment")
    }

    "start employment entry" in new WithBrowser with WithBrowserHelper with BrowserMatchers with EmployedSinceClaimDate {
      beginClaim()

      goTo("/employment/been-employed")
      click("#beenEmployed_yes")
      next
      titleMustEqual("Employer Details - Employment History")
    }

    "show 1 error upon submitting no mandatory data" in new WithBrowser with EmployedHistoryPage {
      val historyPage = goToHistoryPage
      historyPage must beAnInstanceOf[G2BeenEmployedPage]
      historyPage submitPage()

      historyPage.listErrors.size shouldEqual 1
    }

    """go back to "education".""" in new WithBrowser with WithBrowserHelper with BrowserMatchers with EducatedSinceClaimDate {
      beginClaim()

      goTo("/education/your-course-details")

      goTo("/employment/employment")
      back
      titleMustEqual("Your course details - About your education")
    }

    """remember "employment" upon stating "employment" and returning""" in new WithBrowser with EmployedHistoryPage {
      val employmentData = ClaimScenarioFactory.s7EmploymentMinimal()
      var historyPage = goToHistoryPage
      historyPage must beAnInstanceOf[G2BeenEmployedPage]
      employmentData.EmploymentHaveYouBeenEmployedAtAnyTime_1 = "No"
      historyPage fillPageWith employmentData
      val nextPage = historyPage submitPage()

      nextPage must beAnInstanceOf[G1AboutSelfEmploymentPage]
      historyPage = nextPage goBack()
      historyPage.readYesNo("#beenEmployed") mustEqual Some("no")
    }

    """have table data after filling a job""" in new WithBrowser with EmployedHistoryPage {
      val employmentData = ClaimScenarioFactory.s7EmploymentMinimal()
      var historyPage = goToHistoryPage
      historyPage must beAnInstanceOf[G2BeenEmployedPage]
      historyPage.readTableCell(0, 0) mustEqual Some("Tesco's")
      historyPage.readTableCell(0, 1) mustEqual Some("01/01/2013")
    }.pendingUntilFixed("Need to fix for the employment table US809")
    

  } section("integration", models.domain.Employed.id)
}

trait EmployedHistoryPage extends G1ClaimDatePageContext {
  this: WithBrowser[_] =>

  def goToHistoryPage = {
    val claim = new TestData
    claim.ClaimDateWhenDoYouWantYourCarersAllowanceClaimtoStart = "03/05/2014"
    page goToThePage()
    page fillPageWith claim
    page submitPage()

    val employmentData = ClaimScenarioFactory.s7EmploymentMinimal()
    employmentData.EmploymentHaveYouBeenEmployedAtAnyTime_0 = "Yes"
    employmentData.EmploymentHaveYouBeenSelfEmployedAtAnyTime = "Yes"
    val employmentPage = page goToPage new G1EmploymentPage(PageObjectsContext(browser))
    employmentPage fillPageWith employmentData
    val jobDetailsPage = employmentPage submitPage()
    jobDetailsPage fillPageWith employmentData
    val lastWage = jobDetailsPage submitPage()
    lastWage fillPageWith employmentData
    val pensionSchmesPage = lastWage submitPage()
    pensionSchmesPage fillPageWith employmentData
    val expensesPage = pensionSchmesPage submitPage()
    expensesPage fillPageWith employmentData
    val historyPage = expensesPage submitPage()
    historyPage
  }
}<commit_msg>US809 - Fixed failing test<commit_after>package controllers.s7_employment

import org.specs2.mutable.{Tags, Specification}
import play.api.test.WithBrowser
import controllers.{ClaimScenarioFactory, WithBrowserHelper, BrowserMatchers}
import utils.pageobjects._
import utils.pageobjects.s7_employment._
import utils.pageobjects.s8_self_employment.G1AboutSelfEmploymentPage
import scala.Some
import utils.pageobjects.s1_2_claim_date.G1ClaimDatePageContext

class G2BeenEmployedIntegrationSpec extends Specification with Tags {
  "Been Employed" should {
    "present, having indicated that the carer has been employed" in new WithBrowser with WithBrowserHelper with BrowserMatchers with EmployedSinceClaimDate {
    beginClaim()

      goTo("/employment/been-employed")
      back
      titleMustEqual("Employer Details - Employment History")
    }

    """be bypassed and go onto "other money" having indicated that "employment" is not required.""" in new WithBrowser with WithBrowserHelper with BrowserMatchers with NotEmployedSinceClaimDate {
      beginClaim()

      goTo("/employment/been-employed")

      titleMustEqual("Benefits and payments - About Other Money")
    }

    """progress to next section i.e. "self employed".""" in new WithBrowser with WithBrowserHelper with BrowserMatchers {
      goTo("/employment/been-employed")

      next
      titleMustEqual("Your job - About self-employment")
    }

    "start employment entry" in new WithBrowser with WithBrowserHelper with BrowserMatchers with EmployedSinceClaimDate {
      beginClaim()

      goTo("/employment/been-employed")
      click("#beenEmployed_yes")
      next
      titleMustEqual("Employer Details - Employment History")
    }

    "show 1 error upon submitting no mandatory data" in new WithBrowser with EmployedHistoryPage {
      val historyPage = goToHistoryPage
      historyPage must beAnInstanceOf[G2BeenEmployedPage]
      historyPage submitPage()

      historyPage.listErrors.size shouldEqual 1
    }

    """go back to "education".""" in new WithBrowser with WithBrowserHelper with BrowserMatchers with EducatedSinceClaimDate {
      beginClaim()

      goTo("/education/your-course-details")

      goTo("/employment/employment")
      back
      titleMustEqual("Your course details - About your education")
    }

    """remember "employment" upon stating "employment" and returning""" in new WithBrowser with EmployedHistoryPage {
      val employmentData = ClaimScenarioFactory.s7EmploymentMinimal()
      var historyPage = goToHistoryPage
      historyPage must beAnInstanceOf[G2BeenEmployedPage]
      employmentData.EmploymentHaveYouBeenEmployedAtAnyTime_1 = "No"
      historyPage fillPageWith employmentData
      val nextPage = historyPage submitPage()

      nextPage must beAnInstanceOf[G1AboutSelfEmploymentPage]
      historyPage = nextPage goBack()
      historyPage.readYesNo("#beenEmployed") mustEqual Some("no")
    }

    """have job data after filling a job""" in new WithBrowser with EmployedHistoryPage {
      val employmentData = ClaimScenarioFactory.s7EmploymentMinimal()
      var historyPage = goToHistoryPage
      historyPage must beAnInstanceOf[G2BeenEmployedPage]
      historyPage.source().contains(("Tesco's")) mustEqual true
      historyPage.source().contains(("01/01/2013")) mustEqual true
    }

  } section("integration", models.domain.Employed.id)
}

trait EmployedHistoryPage extends G1ClaimDatePageContext {
  this: WithBrowser[_] =>

  def goToHistoryPage = {
    val claim = new TestData
    claim.ClaimDateWhenDoYouWantYourCarersAllowanceClaimtoStart = "03/05/2014"
    page goToThePage()
    page fillPageWith claim
    page submitPage()

    val employmentData = ClaimScenarioFactory.s7EmploymentMinimal()
    employmentData.EmploymentHaveYouBeenEmployedAtAnyTime_0 = "Yes"
    employmentData.EmploymentHaveYouBeenSelfEmployedAtAnyTime = "Yes"
    val employmentPage = page goToPage new G1EmploymentPage(PageObjectsContext(browser))
    employmentPage fillPageWith employmentData
    val jobDetailsPage = employmentPage submitPage()
    jobDetailsPage fillPageWith employmentData
    val lastWage = jobDetailsPage submitPage()
    lastWage fillPageWith employmentData
    val pensionSchmesPage = lastWage submitPage()
    pensionSchmesPage fillPageWith employmentData
    val expensesPage = pensionSchmesPage submitPage()
    expensesPage fillPageWith employmentData
    val historyPage = expensesPage submitPage()
    historyPage
  }
}
{'fraction_non_alphanumeric': 0.06992230854605994, 'fraction_numerical': 0.009544950055493896, 'mean_word_length': 4.354129530600119, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3021173', 'n_tokens_mistral': 2504, 'n_tokens_neox': 2356, 'n_words': 635}