Skip to content

Commit

Permalink
Fix message text in two-part tariff review screen (#1116)
Browse files Browse the repository at this point in the history
On the Review screen when there are licences in review we show a message letting users know how many there are. Currently, when there is only 1 licence in review the text displays as `1 licences` whereas it should be singular and display `1 licence`.

This PR corrects that text.
  • Loading branch information
Jozzey authored Jun 18, 2024
1 parent 3fce32c commit 64c76a1
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,25 @@ function _prepareBillRun (billRun, preparedLicences) {
financialYear: _financialYear(billRun.toFinancialYearEnding),
billRunType: 'two-part tariff',
numberOfLicencesDisplayed: preparedLicences.length,
numberOfLicencesToReview: billRun.reviewLicences[0].numberOfLicencesToReview,
reviewMessage: _prepareReviewMessage(billRun.reviewLicences[0].numberOfLicencesToReview),
totalNumberOfLicences: billRun.reviewLicences[0].totalNumberOfLicences
}
}

function _prepareReviewMessage (numberOfLicencesToReview) {
let numberOfLicences

if (numberOfLicencesToReview === 0) {
return 'You have resolved all returns data issues. Continue to generate bills.'
} else if (numberOfLicencesToReview === 1) {
numberOfLicences = '1 licence'
} else {
numberOfLicences = `${numberOfLicencesToReview} licences`
}

return `You need to review ${numberOfLicences} with returns data issues. You can then continue and send the bill run.`
}

function _financialYear (financialYearEnding) {
const startYear = financialYearEnding - 1
const endYear = financialYearEnding
Expand Down
20 changes: 6 additions & 14 deletions app/views/bill-runs/review.njk
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,12 @@
</div>
</div>

{# Dynamic message either telling the user they have issues to deal with or that they can generate bills #}
{% if numberOfLicencesToReview > 0 %}
<section class="govuk-!-margin-bottom-9">
{{ govukInsetText({
html: '<span data-test="licences-to-review">You need to review ' + numberOfLicencesToReview + ' licences with returns data issues. You can then continue and send the bill run.</span>'
}) }}
</section>
{% else %}
<section class="govuk-!-margin-bottom-9">
{{ govukInsetText({
html: '<span data-test="licences-to-review">You have resolved all returns data issues. Continue to generate bills.</span>'
}) }}
</section>
{% endif %}
{# Message either telling the user they have issues to deal with or that they can generate bills #}
<section class="govuk-!-margin-bottom-9">
{{ govukInsetText({
html: '<span data-test="licences-to-review">'+ reviewMessage +'</span>'
}) }}
</section>

{# Cancel bill run button #}
<section class="govuk-!-margin-bottom-9">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Review Bill Run presenter', () => {
financialYear: '2022 to 2023',
billRunType: 'two-part tariff',
numberOfLicencesDisplayed: 3,
numberOfLicencesToReview: 1,
reviewMessage: 'You need to review 1 licence with returns data issues. You can then continue and send the bill run.',
totalNumberOfLicences: 3,
preparedLicences: [
{
Expand Down Expand Up @@ -82,6 +82,46 @@ describe('Review Bill Run presenter', () => {
}
})
})

describe('and there are no licences in "review" status', () => {
beforeEach(() => {
testBillRun.reviewLicences[0].numberOfLicencesToReview = 0
})

it('correctly presents the data', () => {
const result = ReviewBillRunPresenter.go(
testBillRun,
filterIssues,
filterLicenceHolderNumber,
filterLicenceStatus,
testLicences
)

expect(result.reviewMessage).to.equal(
'You have resolved all returns data issues. Continue to generate bills.'
)
})
})

describe('and there are 2 licences in "review" status', () => {
beforeEach(() => {
testBillRun.reviewLicences[0].numberOfLicencesToReview = 2
})

it('correctly presents the data', () => {
const result = ReviewBillRunPresenter.go(
testBillRun,
filterIssues,
filterLicenceHolderNumber,
filterLicenceStatus,
testLicences
)

expect(result.reviewMessage).to.equal(
'You need to review 2 licences with returns data issues. You can then continue and send the bill run.'
)
})
})
})

describe('and filters have been applied', () => {
Expand Down

0 comments on commit 64c76a1

Please sign in to comment.