import { expect } from 'chai'
import ParkingTicketsPage from '../parking-tickets.po'

describe('Parking Tickets Service', () => {
  describe('Method step', () => {
    let page

    beforeEach(() => {
      page = new ParkingTicketsPage()
      page.open()
    })

    it('should be able to re-select methods', () => {
      page.steps.method.payByTicketNumber()
      page.steps.method.waitContentCard()
      page.steps.method.close()
      expect(page.steps.method.isSelectingMethod()).to.equal(true)
      page.steps.method.payByTicketNumber()
      page.steps.method.waitContentCard()
      page.steps.method.back()
      expect(page.steps.method.isSelectingMethod()).to.equal(true)

      page.steps.method.payByLicensePlate()
      page.steps.method.waitContentCard()
      page.steps.method.close()
      expect(page.steps.method.isSelectingMethod()).to.equal(true)
      page.steps.method.payByLicensePlate()
      page.steps.method.waitContentCard()
      page.steps.method.back()
      expect(page.steps.method.isSelectingMethod()).to.equal(true)
    })

    it('should require license plate information to proceed', () => {
      page.steps.method.payByLicensePlate()
      page.steps.method.waitContentCard()
      page.steps.method.next()
      expect(page.steps.method.isContentCardExisting()).to.equal(true)
      page.steps.method.enterLisencePlateInformation()
      page.steps.method.next()
      expect(page.steps.infractions.check()).to.equal(true)
    })

    it('should require infracion ticket information to proceed', () => {
      page.steps.method.payByTicketNumber()
      page.steps.method.waitContentCard()
      page.steps.method.next()
      expect(page.steps.method.isContentCardExisting()).to.equal(true)
      page.steps.method.enterTicketInformation()
      page.steps.method.next()
      expect(page.steps.infractions.check()).to.equal(true)
    })

    it('should display more information for help', () => {
      page.steps.method.payByTicketNumber()
      page.steps.method.waitContentCard()
      page.steps.method.showMoreInformation()
      expect(page.steps.method.isMoreInformationExisting()).to.equal(true)
      page.steps.method.closeMoreInformation()
      expect(page.steps.method.isMoreInformationExisting()).to.equal(false)
      page.steps.method.back()

      page.steps.method.payByLicensePlate()
      page.steps.method.waitContentCard()
      page.steps.method.showMoreInformation()
      expect(page.steps.method.isMoreInformationExisting()).to.equal(true)
      page.steps.method.closeMoreInformation()
      expect(page.steps.method.isMoreInformationExisting()).to.equal(false)
    })
  })
})
