Skip to content

Commit

Permalink
RASS-296 overall conviction date page (#364)
Browse files Browse the repository at this point in the history
* RASS-296 overall conviction date page

* updated mapping to include overall conviction date

* content fix

* corrected variable name
  • Loading branch information
carloveo-moj authored Aug 16, 2024
1 parent 422d8bd commit 31289c5
Show file tree
Hide file tree
Showing 10 changed files with 821 additions and 60 deletions.
63 changes: 63 additions & 0 deletions integration_tests/e2e/courtOverallConvictionDate.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import dayjs from 'dayjs'
import CourtCaseOverallConvictionDatePage from '../pages/courtCaseOverallConvictionDatePage'
import Page from '../pages/page'

context('Court Case Overall Conviction Date Page', () => {
let courtCaseOverallConvictionDatePage: CourtCaseOverallConvictionDatePage
beforeEach(() => {
cy.task('happyPathStubs')
cy.signIn()
cy.visit('/person/A1234AB/add-court-case/0/add-court-appearance/0/overall-conviction-date')
courtCaseOverallConvictionDatePage = Page.verifyOnPage(CourtCaseOverallConvictionDatePage)
})

it('displays person details', () => {
courtCaseOverallConvictionDatePage
.prisonerBanner()
.should('contain.text', 'Haggler, Marvin')
.and('contain.text', 'A1234AB')
.and('contain.text', 'EstablishmentHMP Bedford')
.and('contain.text', 'Cell numberCELL-1')
})

it('button to continue is displayed', () => {
courtCaseOverallConvictionDatePage.button().should('contain.text', 'Continue')
})

it('submitting without entering anything in the inputs results in an error', () => {
courtCaseOverallConvictionDatePage.button().click()
courtCaseOverallConvictionDatePage = Page.verifyOnPage(CourtCaseOverallConvictionDatePage)
courtCaseOverallConvictionDatePage
.errorSummary()
.trimTextContent()
.should(
'equal',
'There is a problem Overall conviction date must include day Overall conviction date must include month Overall conviction date must include year',
)
})

it('submitting an invalid date results in an error', () => {
courtCaseOverallConvictionDatePage.dayDateInput('overallConvictionDate').type('35')
courtCaseOverallConvictionDatePage.monthDateInput('overallConvictionDate').type('1')
courtCaseOverallConvictionDatePage.yearDateInput('overallConvictionDate').type('2024')
courtCaseOverallConvictionDatePage.button().click()
courtCaseOverallConvictionDatePage = Page.verifyOnPage(CourtCaseOverallConvictionDatePage)
courtCaseOverallConvictionDatePage
.errorSummary()
.trimTextContent()
.should('equal', 'There is a problem This date does not exist.')
})

it('submitting a date in the future results in an error', () => {
const futureDate = dayjs().add(7, 'day')
courtCaseOverallConvictionDatePage.dayDateInput('overallConvictionDate').type(futureDate.date().toString())
courtCaseOverallConvictionDatePage.monthDateInput('overallConvictionDate').type((futureDate.month() + 1).toString())
courtCaseOverallConvictionDatePage.yearDateInput('overallConvictionDate').type(futureDate.year().toString())
courtCaseOverallConvictionDatePage.button().click()
courtCaseOverallConvictionDatePage = Page.verifyOnPage(CourtCaseOverallConvictionDatePage)
courtCaseOverallConvictionDatePage
.errorSummary()
.trimTextContent()
.should('equal', 'There is a problem Overall conviction date must be in the past')
})
})
7 changes: 7 additions & 0 deletions integration_tests/pages/courtCaseOverallConvictionDatePage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Page from './page'

export default class CourtCaseOverallConvictionDatePage extends Page {
constructor() {
super('Enter the conviction date')
}
}
6 changes: 6 additions & 0 deletions server/@types/forms/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,10 @@ declare module 'forms' {
export interface OffenceSentenceTypeForm {
sentenceType?: string
}

export interface CourtCaseOverallConvictionDateForm {
'overallConvictionDate-day'?: string
'overallConvictionDate-month'?: strin
'overallConvictionDate-year'?: string
}
}
1 change: 1 addition & 0 deletions server/@types/models/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ declare module 'models' {
appearanceInformationAccepted?: boolean
offenceSentenceAccepted?: boolean
nextCourtAppearanceAccepted?: boolean
overallConvictionDate?: Date
}

export interface Offence {
Expand Down
Loading

0 comments on commit 31289c5

Please sign in to comment.