Skip to content

Commit

Permalink
Finish replacing Active and Previous Order with Summary Card/Lists. U…
Browse files Browse the repository at this point in the history
…pdate Cypruss tests for new format.
  • Loading branch information
KiraNamida committed Jan 15, 2025
1 parent ce91d2e commit d1bb66b
Show file tree
Hide file tree
Showing 26 changed files with 350 additions and 303 deletions.
122 changes: 97 additions & 25 deletions integration-tests/cypress/e2e/case-summary.feature
Original file line number Diff line number Diff line change
Expand Up @@ -316,22 +316,63 @@ Feature: Case summary
When I clear the filters
When I click the "Lenore Marquez" link
And I click the sub navigation with "Probation record" text
Then I should see a level 2 heading with text "Current orders (3)"
And I should see link "ORA Community Order (18 Months)" with href "record/1403337513"
And I should see the text "Curfew Arrangement" within element with class "qa-current-licence-conditions-1"
And I should see the text "Curfew Arrangement" within element with class "qa-current-pss-requirements-2"
And I should see the body text "Stealing mail bags or postal packets or unlawfully taking away or opening mail bag - 04200"
And I should see the hint text "Started on 20 May 2019"

And I should see a level 2 heading with text "Previous orders (11)"
And I should see link "CJA - Std Determinate Custody" with href "record/636401162"
And I should see the text "Burglary (dwelling) with intent to commit, or the commission of an offence triable only on indictment - 02801" within element with class "qa-previous-order-1-offence"
And I should see the text "Ended on 23 Jan 2018" within element with class "qa-previous-order-1-end-date"
And I should see a level 1 heading with text "Lenore Marquez"
Then I should see a level 1 heading with text "Lenore Marquez"
And I should see a "l" sized level 1 heading with text "Probation record"
And I should see the following "m" sized level 2 headings
| Pre-sentence report requested | Current orders | Previous orders | Offender manager | Last pre-sentence report | Last OASys assessment |

Then I should see a level 2 heading with text "Current orders (3)"
Then I should see a summary card with id "activeOrder0" and title "ORA Community Order (18 Months)"
And I should see a summary card with id "activeOrder0" and action
| View record | for ORA Community Order | record/1403337513 |
And I should see a summary card with id "activeOrder0" and summary list rows
| Description | Stealing mail bags or postal packets or unlawfully taking away or opening mail bag - 04200 | Started on 20 May 2019 | | |
| Requirements | Unpaid WorkRegular60 Hours | Rehabilitation Activity Requirement (RAR) – 20 Days | CourtAccredited ProgrammeASRO | CourtAccredited ProgrammeBuilding Better RelationshipsBBR |
Then I should see a summary card with id "activeOrder1" and title "ORA Adult Custody (inc PSS) (12 Months)"
And I should see a summary card with id "activeOrder1" and action
| View record | for ORA Adult Custody (inc PSS) | record/1309234876 |
And I should see a summary card with id "activeOrder1" and summary list rows
| Description | Dangerous driving/Aid, abet cause or permit reckless driving - 80200 | Started on {6 months ago} | |
| Status | On license | | |
| Licence conditions | Alcohol | Curfew Arrangement | Participate or co-op with Programme or Activities |
Then I should see a summary card with id "activeOrder2" and title "ORA Adult Custody (inc PSS) (18 Months)"
And I should see a summary card with id "activeOrder2" and action
| View record | for ORA Adult Custody (inc PSS) | record/2360414697 |
And I should see a summary card with id "activeOrder2" and summary list rows
| Description | Aggravated burglary in a building other than a dwelling (including attempts) - 03100 | Started on {6 months ago} | |
| Status | On license | | |
| Licence conditions | Alcohol | Curfew Arrangement | Participate or co-op with Programme or Activities |
| Status | On post-sentence supervision (PSS) | | |
| PSS requirements | Standard 7 conditions | Specified ActivityETEHigh intensity | Curfew Arrangement |

And I should see a level 2 heading with text "Previous orders (11)"
Then I should see a summary card with id "previousOrder0" and title "CJA - Std Determinate Custody (18 Months)"
And I should see a summary card with id "previousOrder0" and action
| View record | CJA - Std Determinate Custody | record/636401162 |
And I should see a summary card with id "previousOrder0" and summary list rows
| Description | Burglary (dwelling) with intent to commit, or the commission of an offence triable only on indictment - 02801 | Started on 23 Jan 2018 |
Then I should see a summary card with id "previousOrder1" and title "Adult Custody < 12m (18 Months)"
And I should see a summary card with id "previousOrder1" and action
| View record | Adult Custody < 12m | record/7925250000 |
And I should see a summary card with id "previousOrder1" and summary list rows
| Description | Arson endangering life - 05601 | Started on 27 Aug 2019 |
Then I should see a summary card with id "previousOrder2" and title "CJA - Indeterminate Public Prot. (18 Months)"
And I should see a summary card with id "previousOrder2" and action
| View record | CJA - Indeterminate Public Prot. | record/1475462502 |
And I should see a summary card with id "previousOrder2" and summary list rows
| Description | Common and other types of assault - 10500 | Started on 9 Aug 2017 |
Then I should see a summary card with id "previousOrder3" and title "ORA Community Order (18 Months)"
And I should see a summary card with id "previousOrder3" and action
| View record | ORA Community Order | record/1906091609 |
And I should see a summary card with id "previousOrder3" and summary list rows
| Description | (Assault PC (Indictable/Either way) - 00807) | Started on 4 Sep 2019 |
Then I should see a summary card with id "previousOrder4" and title "Life imprisonment (Adult) (18 Months)"
And I should see a summary card with id "previousOrder4" and action
| View record | Life imprisonment (Adult) | record/943466740 |
And I should see a summary card with id "previousOrder4" and summary list rows
| Description | High treason - 06200 | Started on 23 Jan 2018 |

And I should see the body text "Angel Extravaganza"
And I should see the hint text "Allocated on 12 Aug 2017"
And I should see the body text "Email: [email protected]"
Expand All @@ -348,12 +389,41 @@ Feature: Case summary
And I should see the body text "OASys Assessment Layer 3"
And I should see the hint text "Completed on 20 Jun 2018"

And I should see the following level 3 headings
| Requirements | Status | Licence conditions | Status | Licence conditions | Status | PSS requirements |

And I should see 5 previous orders
When I click the "Show all previous orders" button
Then I should see 11 previous orders

Then I should see a summary card with id "previousOrder5" and title "ORA Suspended Sentence Order (18 Months)"
And I should see a summary card with id "previousOrder5" and action
| View record | ORA Suspended Sentence Order | record/1081636758 |
And I should see a summary card with id "previousOrder5" and summary list rows
| Description | Aiding suicide - 07600 | Started on 4 Sep 2019 |
Then I should see a summary card with id "previousOrder6" and title "ORA Adult Custody (Not PSS) (18 Months)"
And I should see a summary card with id "previousOrder6" and action
| View record | ORA Adult Custody (Not PSS) | record/636401231 |
And I should see a summary card with id "previousOrder6" and summary list rows
| Description | Aiding suicide - 07600 | Started on 25 Dec 2017 |
Then I should see a summary card with id "previousOrder7" and title "ORA Adult Custody (Not PSS) (18 Months)"
And I should see a summary card with id "previousOrder7" and action
| View record | ORA Adult Custody (Not PSS) | record/1999409258 |
And I should see a summary card with id "previousOrder7" and summary list rows
| Description | Burglary (dwelling) with intent to commit, or the commission of an offence triable only on indictment - 02801 | Started on 4 Aug 2018 |
Then I should see a summary card with id "previousOrder8" and title "Fine (18 Months)"
And I should see a summary card with id "previousOrder8" and action
| View record | Fine | record/2319221210 |
And I should see a summary card with id "previousOrder8" and summary list rows
| Description | Arson endangering life - 05601 | Started on 23 Jan 2018 |
Then I should see a summary card with id "previousOrder9" and title "ORA Adult Custody (Not PSS) (18 Months)"
And I should see a summary card with id "previousOrder9" and action
| View record | ORA Adult Custody (Not PSS) | record/754151578 |
And I should see a summary card with id "previousOrder9" and summary list rows
| Description | Acknowledging bail in false name - 08303 | Started on 21 Sep 2018 |
Then I should see a summary card with id "previousOrder10" and title "Fine"
And I should see a summary card with id "previousOrder10" and action
| View record | Fine | record/901046255 |
And I should see a summary card with id "previousOrder10" and summary list rows
| Description | Common and other types of assault - 10500 | Started on 23 Sep 2018 |

And There should be no a11y violations

Scenario: View the probation record section of the case summary for a current offender who is currently in custody
Expand All @@ -367,11 +437,13 @@ Feature: Case summary
When I click the "English Madden" link
And I click the sub navigation with "Probation record" text
Then I should see the level 2 heading "Current orders (1)"
And I should see link "CJA - Std Determinate Custody (18 Months)" with href "record/345464567"
And I should see the body text "Burglary (dwelling) with intent to commit, or the commission of an offence triable only on indictment - 02801"
And I should see the hint text "Started on 8 Mar 2017"
And I should see the text "Status" within element with class "govuk-heading-s"
And I should see the body text "In custody"
Then I should see a summary card with id "activeOrder0" and title "CJA - Std Determinate Custody (18 Months)"
And I should see a summary card with id "activeOrder0" and action
| View record | CJA - Std Determinate Custody | record/345464567 |
And I should see a summary card with id "activeOrder0" and summary list rows
| Description | Burglary (dwelling) with intent to commit, or the commission of an offence triable only on indictment - 02801 | Started on 8 Mar 2017 |
| Requirements | Rehabilitation Activity Requirement (RAR) – 20 Days | CourtAccredited ProgrammeBuilding Better RelationshipsBBR20 Days |
| Status | In custody | |

And There should be no a11y violations

Expand Down Expand Up @@ -407,7 +479,7 @@ Feature: Case summary
And I should see the following "m" sized level 2 headings
| Pre-sentence report requested | Current orders | Previous orders | Last OASys assessment |

When I click the "ORA Community Order (18 Months)" link
When I click the "View record" link with id "activeOrder0-view"
Then I should be on the "ORA Community Order (18 Months)" page
And I should see the heading "ORA Community Order (18 Months)"
And I should see the level 2 heading "Attendance"
Expand Down Expand Up @@ -543,9 +615,9 @@ Feature: Case summary
And I should see the body text "Pre-Sentence Report - Fast"
And I should see the hint text "Completed less than 1 month ago"

And I should see link "ORA Community Order (18 Months)" with href "record/1361422142"
And I should see link "View record" with href "record/1361422142"
And I should see the breach badge
When I click the "ORA Community Order (18 Months)" link
When I click the "View record" link with id "activeOrder0-view"
Then I should be on the "ORA Community Order (18 Months)" page
And I should see the heading "ORA Community Order (18 Months)"

Expand Down Expand Up @@ -642,7 +714,7 @@ Feature: Case summary
And I should see the following "m" sized level 2 headings
| Pre-sentence report requested | Current orders | Previous orders | Last OASys assessment |

When I click the "CJA - Std Determinate Custody" link
When I click the "View record" link with id "previousOrder0-view"
Then I should be on the "CJA - Std Determinate Custody (18 Months)" page
And I should see the heading "CJA - Std Determinate Custody"

Expand Down Expand Up @@ -683,7 +755,7 @@ Feature: Case summary
Then I should be on the "Probation record" page
And I should see a level 1 heading with text "Lenore Marquez"

When I click the "ORA Community Order (18 Months)" link
When I click the "View record" link with id "activeOrder0-view"
Then I should be on the "ORA Community Order (18 Months)" page
And I should see the heading "ORA Community Order (18 Months)"
And I should see the level 2 heading "Requirements"
Expand All @@ -697,7 +769,7 @@ Feature: Case summary
Then I should be on the "Probation record" page
And I should see a level 1 heading with text "Lenore Marquez"

When I click the "CJA - Std Determinate Custody" link
When I click the "View record" link with id "previousOrder0-view"
Then I should be on the "CJA - Std Determinate Custody (18 Months)" page
And I should see the heading "CJA - Std Determinate Custody"
And I should see the level 2 heading "Requirements"
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/cypress/e2e/case-summary/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Then, When } from '@badeball/cypress-cucumber-preprocessor'

Then('I should see {int} previous orders', $int => {
cy.get('#previousOrders').within(() => {
cy.get('tr').should('have.length', $int)
cy.get('.govuk-summary-card').should('have.length', $int)
})
})

Expand Down
4 changes: 4 additions & 0 deletions integration-tests/cypress/support/step_definitions/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ When('I click the {string} link', $string => {
cy.get($string === 'Back' ? '.govuk-back-link' : '.govuk-link').contains($string).click()
})

When('I click the {string} link with id {string}', ($string, $id) => {
cy.get(`#${$id}`).contains($string).click()
})

When('I clear the filters', () => {
cy.url().then((url) => {
cy.visit(url + '?clearFilters=true')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Then('I should see a {string} sized level {int} heading with text {string}', ($s
})

Then('I should see the following level {int} headings', ($level, $data) => {
cy.debug($level, $data)
$data.raw()[0].forEach((text) => {
cy.get(`h${$level}`).contains(text)
})
Expand Down
44 changes: 44 additions & 0 deletions integration-tests/cypress/support/step_definitions/summaries.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { Then } = require('@badeball/cypress-cucumber-preprocessor')
const { parseCypressDate } = require('../utils/time')

Then('I should see a summary card with id {string} and title {string}', ($id, $title) => {
cy.get(`#${$id}`).should('have.attr', 'class').and('include', 'govuk-summary-card')
cy.get(`#${$id}`).within(() => {
cy.get('h3').contains($title).should('have.attr', 'class').and('include', 'govuk-summary-card__title')
})
})

Then('I should see a summary card with id {string} and action', ($id, $data) => {
cy.get(`#${$id}`).within(() => {
$data.raw().forEach((row) => {
cy.get('.govuk-summary-card__action').within(() => {
const link = () => cy.get('.govuk-link')
link().contains(row[0]).should('have.attr', 'href').and('include', row[2])
link().within(() => {
cy.get('span').contains(row[1]).should('exist')
})
})
})
})
})

Then('I should see a summary card with id {string} and summary list rows', ($id, $data) => {
cy.get(`#${$id}`).within(() => {
const content = () => cy.get('.govuk-summary-card__content')
content().should('exist')
content().within(() => {
cy.get('.govuk-summary-list').should('exist')
$data.raw().forEach((row, index) => {
cy.get('.govuk-summary-list__row').eq(index).within(() => {
cy.get('dt').contains(row[0]).should('have.attr', 'class').and('include', 'govuk-summary-list__key')
const value = () => cy.get('dd')
row.slice(1).forEach((expected) => {
if(expected) {
value().contains(parseCypressDate(expected, 'D MMM YYYY'))
}
})
})
})
})
})
})
36 changes: 36 additions & 0 deletions integration-tests/cypress/support/utils/time.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const moment = require('moment')

/**
* Based on the format "{number, period, delta}", will replace the slug with
* the time from today using the provided format
* @param {*} input The input to parse
* @param {*} dateFormat The format to use on the resultant data
* @returns The orignal input if a match is found, else will replace the slug with the caluclated date
*/
const parseCypressDate = (input, dateFormat) => {
if(!input.match('.*{.+}')) {
return input
} else {
const timeString = input.substring(input.indexOf('{') + 1, input.indexOf('}'))
const timeParts = timeString.split(' ')
const number = timeParts[0]
const period = timeParts[1]
const delta = timeParts[2]
let moddedTime = moment();
// Expand these options as required
switch (delta) {
case 'ago':
moddedTime = moddedTime.add((-1 * number), period)
break;
case 'ahead':
moddedTime = moddedTime.add(number, period)
break;
}
const result = input.slice(0, input.indexOf('{')) + moddedTime.format(dateFormat)
return result
}
}

module.exports = {
parseCypressDate
}
2 changes: 1 addition & 1 deletion server/routes/handlers/caseSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const caseSummaryHandler = utils => async (req, res) => {
session.backLink = path
session.caseCommentBlankError = undefined

res.render('case-summary', templateValues)
res.render('case-summary/case-summary', templateValues)
}
const caseSummaryPostHandler = utils => async (req, res) => {
}
Expand Down
2 changes: 1 addition & 1 deletion server/routes/handlers/getProbationRecordRouteHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const getProbationRecordRouteHandler = (communityService, getCaseAndTemplateValu
templateValues.data.psrRequestedConvictions = getPsrRequestedConvictions(communityResponse)
templateValues.data.lastPsrWithSentence = getLastSentencedConvictionPSR(communityResponse)

res.render('case-summary-record', templateValues)
res.render('case-summary/case-summary-record', templateValues)
}

module.exports = getProbationRecordRouteHandler
8 changes: 4 additions & 4 deletions server/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ module.exports = function Index ({ authenticationMiddleware }) {

templateValues.title = getOrderTitle(communityResponse)

res.render('case-summary-record-order', templateValues)
res.render('case-summary/case-summary-record-order', templateValues)
})
)

Expand Down Expand Up @@ -574,7 +574,7 @@ module.exports = function Index ({ authenticationMiddleware }) {
...breachData,
...breachDetails
}
res.render('case-summary-record-order-breach', templateValues)
res.render('case-summary/case-summary-record-order-breach', templateValues)
})
)

Expand Down Expand Up @@ -604,7 +604,7 @@ module.exports = function Index ({ authenticationMiddleware }) {
const communityResponse = await getProbationRecord(crn)

templateValues.data.communityData = communityResponse || {}
res.render('case-summary-record-order-licence', templateValues)
res.render('case-summary/case-summary-record-order-licence', templateValues)
})
)

Expand All @@ -625,7 +625,7 @@ module.exports = function Index ({ authenticationMiddleware }) {
...templateValues.params
}

res.render('case-summary-risk', templateValues)
res.render('case-summary/case-summary-risk', templateValues)
})
)

Expand Down
File renamed without changes.
Loading

0 comments on commit d1bb66b

Please sign in to comment.