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

Display msg for multiple abs amounts in view #1153

Merged
merged 6 commits into from
Jul 2, 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
3 changes: 2 additions & 1 deletion app/presenters/licences/view-licence-summary.presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function go (licence) {
licenceId: id,
monitoringStations: _monitoringStations(licenceGaugingStations),
purposes,
purposesCount: licenceVersionPurposes ? licenceVersionPurposes.length : 0,
region: region.displayName,
sourceOfSupply: points[0]?.point_source?.NAME ?? null,
startDate: formatLongDate(startDate)
Expand All @@ -58,7 +59,7 @@ function go (licence) {
function _abstractionAmounts (licenceVersionPurposes) {
const details = []

if (!licenceVersionPurposes) {
if (!licenceVersionPurposes || licenceVersionPurposes.length > 1) {
return details
}

Expand Down
17 changes: 11 additions & 6 deletions app/views/licences/tabs/summary.njk
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,20 @@
</div>
{% endif %}

{% if abstractionAmounts.length > 0 %}
{% if purposesCount > 0 %}
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">Abstraction amounts</dt>
<dd class="govuk-summary-list__value">
<ul class="govuk-list govuk-!-margin-bottom-0">
{% for quantity in abstractionAmounts %}
<li>{{ quantity }}</li>
{% endfor %}
</ul>
{% if purposesCount > 1 %}
<div>Multiple abstractions</div>
<a href="/licences/{{ documentId }}/purposes">View details of the amounts</a>
{% else %}
<ul class="govuk-list govuk-!-margin-bottom-0">
{% for quantity in abstractionAmounts %}
<li>{{ quantity }}</li>
{% endfor %}
</ul>
{% endif %}
</dd>
</div>
{% endif %}
Expand Down
18 changes: 11 additions & 7 deletions test/presenters/licences/view-licence-summary.presenter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ describe('View Licence Summary presenter', () => {
const result = ViewLicenceSummaryPresenter.go(licence)

expect(result).to.equal({
abstractionAmounts: [
'180000.00 cubic metres per year',
'720.00 cubic metres per day',
'144.00 cubic metres per hour',
'40.00 cubic metres per second'
],
abstractionAmounts: [],
abstractionConditions: ['Derogation clause', 'General conditions', 'Non standard quantities'],
abstractionPeriods: ['1 April to 31 October', '1 November to 31 March'],
abstractionPeriodsAndPurposesLinkText: 'View details of your purposes, periods and amounts',
Expand All @@ -51,6 +46,7 @@ describe('View Licence Summary presenter', () => {
caption: 'Purposes',
data: ['Spray Irrigation - Storage', 'Spray Irrigation - Direct']
},
purposesCount: 3,
region: 'Avalon',
sourceOfSupply: 'SURFACE WATER SOURCE OF SUPPLY',
startDate: '1 April 2019'
Expand All @@ -71,7 +67,7 @@ describe('View Licence Summary presenter', () => {
})
})

describe('when the there is at least one licence version purpose', () => {
describe('when the there is one licence version purpose', () => {
beforeEach(() => {
licence.licenceVersions[0].licenceVersionPurposes = [{
id: '7f5e0838-d87a-4c2e-8e9b-09d6814b9ec4',
Expand Down Expand Up @@ -152,6 +148,14 @@ describe('View Licence Summary presenter', () => {
})
})
})

describe('when the there are multiple licence version purposes', () => {
it('returns an empty array', () => {
const result = ViewLicenceSummaryPresenter.go(licence)

expect(result.abstractionAmounts).to.be.empty()
})
})
})

describe('the "abstractionConditions" property', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('View Licence Summary service', () => {
}],
licenceName: 'fake licence',
purposes: null,
purposesCount: 0,
region: 'Avalon',
sourceOfSupply: 'SURFACE WATER SOURCE OF SUPPLY',
startDate: '1 April 2019'
Expand Down
Loading