Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check return req. radio buttons using session data #968

Merged
merged 7 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

function go (session) {
const data = {
selectedOption: session.data.reason || null,
id: session.id,
licenceRef: session.data.licence.licenceRef
}
Expand Down
6 changes: 2 additions & 4 deletions app/presenters/return-requirements/start-date.presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,15 @@ function _transformSession (sessionData) {
anotherStartDateDay: null,
anotherStartDateMonth: null,
anotherStartDateYear: null,
anotherStartDateSelected: false,
licenceStartDateSelected: false
selectedOption: null
}
}

return {
anotherStartDateDay: sessionData.startDateDay,
anotherStartDateMonth: sessionData.startDateMonth,
anotherStartDateYear: sessionData.startDateYear,
anotherStartDateSelected: selectedOption === 'anotherStartDate',
licenceStartDateSelected: selectedOption === 'licenceStartDate'
selectedOption
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async function go (sessionId, payload) {
checkYourAnswersVisited: session.data.checkYourAnswersVisited,
error: validationResult,
pageTitle: 'Why are no returns required?',
selectedOption: null,
...formattedData
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/views/return-requirements/no-returns-required.njk
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@
{
text: 'Abstraction amount below 100 cubic metres per day',
value: 'abstraction-below-100-cubic-metres-per-day',
checked: false
checked: selectedOption == 'abstraction-below-100-cubic-metres-per-day'
},
{
text: 'Returns exception',
value: 'returns-exception',
checked: false
checked: selectedOption == 'returns-exception'
},
{
text: 'Transfer licence',
value: 'transfer-licence',
checked: false
checked: selectedOption == 'transfer-licence'
}
]
}) }}
Expand Down
4 changes: 2 additions & 2 deletions app/views/return-requirements/start-date.njk
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
hint: {
text: licenceVersionStartDate
},
checked: licenceStartDateSelected
checked: selectedOption == 'licenceStartDate'
},
{
id: 'another-start-date',
Expand All @@ -102,7 +102,7 @@
hint: {
text: 'For example, 27 3 2007'
},
checked: anotherStartDateSelected,
checked: selectedOption == 'anotherStartDate',
conditional: {
html: dateInputHTML
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ describe('No Returns Required presenter', () => {
id: 'ea53bfc6-740d-46c5-9558-fc8cabfc6c1f',
licenceRef: '01/123',
licenceHolder: 'Jane Doe'
}
},
reason: 'transfer-licence'
}
}
})
Expand All @@ -32,7 +33,9 @@ describe('No Returns Required presenter', () => {

expect(result).to.equal({
id: 'f1288f6c-8503-4dc1-b114-75c408a14bd0',
licenceRef: '01/123'
licenceRef: '01/123',
selectedOption: 'transfer-licence'

})
})
})
Expand Down
13 changes: 6 additions & 7 deletions test/presenters/return-requirements/start-date.presenter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ describe('Start Date presenter', () => {
licenceRef: '01/ABC',
licenceHolder: 'Turbo Kid',
startDate: '2023-11-126T00:00:00.000Z'
}
},
selectedOption: null
}
}
})
Expand All @@ -41,8 +42,7 @@ describe('Start Date presenter', () => {
anotherStartDateDay: null,
anotherStartDateMonth: null,
anotherStartDateYear: null,
anotherStartDateSelected: false,
licenceStartDateSelected: false
selectedOption: null
}, { skip: ['id'] })
})
})
Expand All @@ -64,8 +64,8 @@ describe('Start Date presenter', () => {
},
startDateDay: '26',
startDateMonth: '11',
startDateOptions: 'anotherStartDate',
startDateYear: '2023'
startDateYear: '2023',
startDateOptions: 'anotherStartDate'
}
}
})
Expand All @@ -81,8 +81,7 @@ describe('Start Date presenter', () => {
anotherStartDateDay: '26',
anotherStartDateMonth: '11',
anotherStartDateYear: '2023',
anotherStartDateSelected: true,
licenceStartDateSelected: false
selectedOption: 'anotherStartDate'
}, { skip: ['id'] })
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ describe('No Returns Required service', () => {
activeNavBar: 'search',
checkYourAnswersVisited: false,
pageTitle: 'Why are no returns required?',
licenceRef: '01/ABC'
licenceRef: '01/ABC',
selectedOption: null
}, { skip: ['id'] })
})
})
Expand Down
4 changes: 2 additions & 2 deletions test/services/return-requirements/start-date.service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const sessionData = {
endDate: null,
licenceRef: '01/ABC',
licenceHolder: 'Turbo Kid',
selectedOption: null,
startDate: '2022-04-01T00:00:00.000Z'
}
}
Expand Down Expand Up @@ -56,8 +57,7 @@ describe('Start Date service', () => {
anotherStartDateDay: null,
anotherStartDateMonth: null,
anotherStartDateYear: null,
anotherStartDateSelected: false,
licenceStartDateSelected: false
selectedOption: null
}, { skip: ['id'] })
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const sessionData = {
licenceHolder: 'Turbo Kid',
startDate: '2022-04-01T00:00:00.000Z'
},
journey: 'no-returns-required'
journey: 'no-returns-required',
selectedOption: null

}
}

Expand Down Expand Up @@ -78,7 +80,8 @@ describe('Submit No Returns Required service', () => {
activeNavBar: 'search',
checkYourAnswersVisited: false,
pageTitle: 'Why are no returns required?',
licenceRef: '01/ABC'
licenceRef: '01/ABC',
selectedOption: null
}, { skip: ['id', 'error'] })
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const sessionData = {
licenceHolder: 'Turbo Kid',
startDate: '2022-04-01T00:00:00.000Z'
},
journey: 'no-returns-required'
journey: 'no-returns-required',
selectedOption: null
}
}

Expand Down Expand Up @@ -134,14 +135,13 @@ describe('Submit Start Date service', () => {
checkYourAnswersVisited: false,
anotherStartDateDay: null,
anotherStartDateMonth: null,
anotherStartDateSelected: false,
anotherStartDateYear: null,
journey: 'no-returns-required',
licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d',
licenceRef: '01/ABC',
licenceStartDateSelected: false,
licenceVersionStartDate: '1 January 2023',
pageTitle: 'Select the start date for the requirements for returns'
pageTitle: 'Select the start date for the requirements for returns',
selectedOption: null
}, { skip: ['id', 'error'] })
})

Expand Down Expand Up @@ -187,8 +187,7 @@ describe('Submit Start Date service', () => {
anotherStartDateDay: 'a',
anotherStartDateMonth: 'b',
anotherStartDateYear: 'c',
anotherStartDateSelected: true,
licenceStartDateSelected: false
selectedOption: 'anotherStartDate'
}, { skip: ['id', 'error'] })
})

Expand Down
Loading