Skip to content

Commit

Permalink
MAN-317 update rar details (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
achimber-moj authored Jan 21, 2025
1 parent 156a7c4 commit 9517d34
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions integration_tests/e2e/requirement-note.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ context('Sentence', () => {
cy.get('[data-qa=pageHeading]').eq(0).should('contain.text', 'Sentence')

cy.get(`[class=app-summary-card__header]`).within(() =>
cy.get('h2').should('contain.text', '1 of 12 RAR days completed'),
cy.get('h2').should('contain.text', '3 of 12 RAR days completed'),
)

cy.get(`[class=app-summary-card__body]`).within(() => cy.get('dt').should('have.length', 6))
Expand All @@ -21,7 +21,7 @@ context('Sentence', () => {
cy.get(`[class=app-summary-card__body]`).within(() => cy.get('dd').eq(0).should('contain.text', '12 days'))

cy.get(`[class=app-summary-card__body]`).within(() => cy.get('dt').eq(1).should('contain.text', 'Completed RAR'))
cy.get(`[class=app-summary-card__body]`).within(() => cy.get('dd').eq(1).should('contain.text', '1 day'))
cy.get(`[class=app-summary-card__body]`).within(() => cy.get('dd').eq(1).should('contain.text', '3 days'))

cy.get(`[class=app-summary-card__body]`).within(() => cy.get('dt').eq(2).should('contain.text', 'Start date'))
cy.get(`[class=app-summary-card__body]`).within(() => cy.get('dd').eq(2).should('contain.text', '12 April 2024'))
Expand Down
6 changes: 3 additions & 3 deletions integration_tests/e2e/sentence.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ context('Sentence', () => {

cy.get(`[data-qa="sentenceCard"]`).within(() => cy.get('dt').eq(5).should('contain.text', 'Requirements'))
cy.get(`[data-qa="requirementsValue"]`).within(() =>
cy.get('details').eq(0).should('contain.text', '1 of 12 RAR days completed'),
cy.get('details').eq(0).should('contain.text', '3 of 12 RAR days completed'),
)
cy.get(`[data-qa="requirementsValue"]`).within(() =>
cy.get('details').eq(1).should('contain.text', 'Curfew (Electronic Monitored)'),
Expand Down Expand Up @@ -228,7 +228,7 @@ context('Sentence', () => {
page.getRequirementLabel(1, 1).should('contain.text', 'Length of RAR')
page.getRequirementValue(1, 1).should('contain.text', '12 days')
page.getRequirementLabel(1, 2).should('contain.text', 'Completed RAR')
page.getRequirementValue(1, 2).should('contain.text', '1 day')
page.getRequirementValue(1, 2).should('contain.text', '3 days')
page.getRequirementLabel(1, 3).should('contain.text', 'Start date')
page.getRequirementValue(1, 3).should('contain.text', '12 April 2024')
page.getRequirementLabel(1, 4).should('contain.text', 'Notes')
Expand All @@ -241,6 +241,6 @@ context('Sentence', () => {
.should('contain.text', 'Comment added by Jon Jones on 21 August 2024')
page.getRequirementValue(1, 4).find('a').click()
cy.get(`[data-qa="name"]`).should('contain.text', 'Caroline Wolff')
cy.get('.app-summary-card__header').should('contain.text', '1 of 12 RAR days completed')
cy.get('.app-summary-card__header').should('contain.text', '3 of 12 RAR days completed')
})
})
5 changes: 3 additions & 2 deletions server/views/pages/requirement-note.njk
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
{% endblock %}

{% block pageContent %}
{% set completedRar = requirementNoteDetails.requirement.rar.completed + requirementNoteDetails.requirement.rar.nsiCompleted %}
{% set requirementNote %}
{{ govukSummaryList({
rows: [
Expand All @@ -41,7 +42,7 @@
} if requirementNoteDetails.requirement.length and requirementNoteDetails.requirement.code !== 'F',
{
key: { text: 'Completed RAR'},
value: { text: requirementNoteDetails.requirement.rar.completed + " day" if requirementNoteDetails.requirement.rar.completed == 1 else requirementNoteDetails.requirement.rar.completed + " days" }
value: { text: completedRar + " day" if completedRar == 1 else completedRar + " days" }
} if requirementNoteDetails.requirement.rar.completed and requirementNoteDetails.requirement.code == 'F',
{
key: { text: 'Expected start date' },
Expand Down Expand Up @@ -80,7 +81,7 @@
{% endset %}

{% if requirementNoteDetails.requirement %}
{% set description = requirementNoteDetails.requirement.rar.completed + " of " + requirementNoteDetails.requirement.rar.totalDays + " RAR days completed" if requirementNoteDetails.requirement.code == 'F' else requirementNoteDetails.requirement.description %}
{% set description = requirementNoteDetails.requirement.description %}
{{ appSummaryCard({
titleText: description,
attributes: {'data-qa': 'requirementNoteCard'},
Expand Down
5 changes: 3 additions & 2 deletions server/views/pages/sentence.njk
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
{% set hasRequirements = sentence.requirements and sentence.requirements.length > 0 %}
{% set requirements %}
{% for requirement in sentence.requirements %}
{% set reqSummary = requirement.rar.completed + " of " + requirement.rar.totalDays + " RAR days completed" if requirement.code == 'F' else requirement.description %}
{% set reqSummary = requirement.description %}
{% set reqNotes = '' %}
{% for reqNote in requirement.requirementNotes %}
{% set note %}
Expand All @@ -211,6 +211,7 @@
{% endset %}
{% set reqNotes = reqNotes.concat(note) %}
{% endfor %}
{% set completedRar = requirement.rar.completed + requirement.rar.nsiCompleted %}
{% set requirementHtml %}
{{ govukSummaryList({
rows: [
Expand All @@ -224,7 +225,7 @@
} if requirement.length and requirement.code == 'F',
{
key: { text: 'Completed RAR' },
value: { text: requirement.rar.completed + ' day' if requirement.rar.completed == 1 else requirement.rar.completed + ' days' }
value: { text: requirement.rar.completed + ' day' if completedRar == 1 else completedRar + ' days' }
} if requirement.code == 'F',
{
key: { text: "Expected start date" },
Expand Down
5 changes: 3 additions & 2 deletions wiremock/mappings/X000001-requirement-note-0.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"requirement": {
"code": "F",
"actualStartDate": "2024-04-12",
"description": "1 of 12 RAR days",
"description": "3 of 12 RAR days completed",
"length": 12,
"lengthUnitValue": "Days",
"requirementNote": {
Expand All @@ -30,7 +30,8 @@
},
"rar": {
"completed": 1,
"scheduled": 11,
"nsiCompleted": 2,
"scheduled": 9,
"totalDays": 12
}
}
Expand Down
5 changes: 3 additions & 2 deletions wiremock/mappings/X000001-sentence.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
"id": 1,
"code": "F",
"actualStartDate": "2024-04-12",
"description": "1 of 12 RAR days",
"description": "3 of 12 RAR days completed",
"length": 12,
"lengthUnitValue": "Days",
"requirementNotes": [
Expand All @@ -252,7 +252,8 @@
],
"rar": {
"completed": 1,
"scheduled": 11,
"nsiCompleted": 2,
"scheduled": 9,
"totalDays": 12
}
},
Expand Down

0 comments on commit 9517d34

Please sign in to comment.