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

FSR-867 Update related links #453

Merged
merged 5 commits into from
Jul 7, 2023
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
1 change: 1 addition & 0 deletions server/models/views/alerts-and-warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ViewModel {
placeCentre: place ? place.center : [],
timestamp: Date.now(),
error: error ? true : null,
getWarnings: 'Alerts-and-warnings:Related-content:Get-warnings',
isEngland: place ? place.isEngland.is_england : null,
isDummyData: floods ? floods.isDummyData : false
})
Expand Down
1 change: 1 addition & 0 deletions server/models/views/rainfall.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ViewModel {
stationId: rainfallStation[0].station_reference,
centroid: [rainfallStation[0].lon, rainfallStation[0].lat],
region: rainfallStation[0].region,
getWarnings: 'Rainfall:Related-content:Get-warnings',
planAhead: 'Rainfall:Related-content:Plan-ahead-for-flooding',
whatToDo: 'Rainfall:Related-content:What-to-do-in-a-flood',
recoverAfter: 'Rainfall:Related-content:Recover-after-a-flood',
Expand Down
8 changes: 8 additions & 0 deletions server/models/views/river-and-sea-levels.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ const { bingKeyMaps, floodRiskUrl } = require('../../config')
const pageTitle = 'Find river, sea, groundwater and rainfall levels'
const metaDescription = 'Find river, sea, groundwater and rainfall levels in England. Check the last updated height, trend and state recorded by the measuring station.'

const getWarningsString = 'Rivers-and-sea-levels:Related-content:Get-warnings'

function emptyResultsModel (q) {
return {
q,
metaDescription,
floodRiskUrl,
getWarnings: getWarningsString,
pageTitle: formatTitle(q),
clientModel: getClientModel()
}
Expand All @@ -23,6 +26,7 @@ function disambiguationModel (q, places, rivers) {
q,
metaDescription,
rivers,
getWarnings: getWarningsString,
pageTitle: `${q} - ${pageTitle}`,
place: places[0],
clientModel: getClientModel()
Expand All @@ -47,6 +51,7 @@ function riverViewModel (stations) {
queryGroup,
floodRiskUrl,
metaDescription,
getWarnings: getWarningsString,
pageTitle: `${qualifiedRiverName} - ${pageTitle}`,
q: qualifiedRiverName,
clientModel: getClientModel(bbox)
Expand All @@ -70,6 +75,7 @@ function areaViewModel (areaName, stations) {
floodRiskUrl,
pageTitle,
metaDescription,
getWarnings: getWarningsString,
clientModel: getClientModel(bbox),
distStatement: `Showing levels within 5 miles of ${areaName}.`
}
Expand All @@ -95,6 +101,7 @@ function referencedStationViewModel (referencePoint, stations) {
floodRiskUrl,
pageTitle,
metaDescription,
getWarnings: getWarningsString,
clientModel: getClientModel(bbox),
distStatement: referencePoint.distStatement
}
Expand Down Expand Up @@ -133,6 +140,7 @@ function placeViewModel ({ location, place, stations = [], queryGroup }) {
clientModel: getClientModel(isEngland ? place.bbox10k : []),
queryGroup: activeFilter,
placeAddress: place.address,
getWarnings: getWarningsString,
pageTitle: title,
metaDescription: description
}
Expand Down
17 changes: 0 additions & 17 deletions server/views/privacy-notice.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,6 @@ <h2 class="govuk-heading-m">Changes to this notice</h2>
<p>If these changes affect how your personal data is processed, we'll take reasonable steps to let you know.</p>
<p>This notice was last updated on 17 March 2022.</p>
</div>
<div class="govuk-grid-column-one-third">
<div class="defra-related-items">
<h2 class="govuk-heading-s" id="subsection-title">
Related content
</h2>
<nav role="navigation" aria-labelledby="subsection-title">
<ul class="govuk-list govuk-!-font-size-16">
<li>
<a href="/cookies">Cookies</a>
</li>
<li>
<a href="/terms-and-conditions">Terms and conditions</a>
</li>
</ul>
</nav>
</div>
</div>
</div>

{% endblock %}
18 changes: 0 additions & 18 deletions server/views/terms-and-conditions.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,6 @@ <h2 class="govuk-heading-m">Changes to these terms and conditions</h2>
<p>Please check these terms and conditions regularly. We can update them at any time without notice.</p>
<p>You’ll agree to any changes if you continue to use the service after the terms and conditions have been updated.</p>
</div>

<div class="govuk-grid-column-one-third">
<div class="defra-related-items">
<h2 class="govuk-heading-s" id="subsection-title">
Related content
</h2>
<nav role="navigation" aria-labelledby="subsection-title">
<ul class="govuk-list govuk-!-font-size-16">
<li>
<a href="/cookies">Cookies</a>
</li>
<li>
<a href="https://www.gov.uk/government/organisations/environment-agency/about/personal-information-charter">Personal information charter</a>
</li>
</ul>
</nav>
</div>
</div>
</div>

{% endblock %}
8 changes: 8 additions & 0 deletions test/models/alerts-and-warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,11 @@ lab.test('Test location sets page title', async () => {

Code.expect(Result.pageTitle).to.equal('Newcastle Upon Tyne - flood alerts and warnings')
})

lab.test('Test getWarnings has appropriate Value', async () => {
const options = {}

const Result = await new ViewModel(options)

Code.expect(Result.getWarnings).to.equal('Alerts-and-warnings:Related-content:Get-warnings')
})
8 changes: 8 additions & 0 deletions test/models/rainfall.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,12 @@ lab.experiment('Rainfall model test', () => {
Code.expect(Result.postTitle).to.equal('Latest rainfall information at Lavenham gauge')
Code.expect(Result.metaDescription).to.equal('Check the latest recorded rainfall at Lavenham gauge')
})
lab.test('Test getWarnings has appropriate Value', async () => {
const rainfallTelemetryData = data.rainfallStationTelemetry
const rainfallStationData = data.rainfallStation.filter((rainfallStation) => rainfallStation.station_reference === 'E24195')

const result = new ViewModel(rainfallTelemetryData, rainfallStationData)

Code.expect(result.getWarnings).to.equal('Rainfall:Related-content:Get-warnings')
})
})
103 changes: 64 additions & 39 deletions test/models/river-and-sea-levels.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,53 +16,64 @@ lab.experiment('river-and-sea-levels model test', () => {
lab.afterEach(async () => {
await sandbox.restore()
})
lab.test('Test river-and-sea-level placeViewModel returns stations', async () => {
const stationsData = data.riverAndSeaLevelData
lab.experiment('placeViewModel', () => {
lab.test('Test river-and-sea-level placeViewModel returns stations', async () => {
const stationsData = data.riverAndSeaLevelData

const model = placeViewModel(stationsData)
const model = placeViewModel(stationsData)

Code.expect(model.stations.length).to.equal(76)
Code.expect(model.stations[0].river_name).to.equal('Valley Brook')
Code.expect(model.stations[0].region).to.equal('North West')
})
lab.test('Test river-and-sea-level placeViewModel returns stations in distance order from place', async () => {
const stationsData = data.riverAndSeaLevelDataUnordered
const firstStation = data.riverAndSeaLevelDataUnordered.stations[0]
const model = placeViewModel(stationsData)

Code.expect(model.stations[2].distance).to.be.greaterThan(model.stations[1].distance)
Code.expect(model.stations[0].river_name).to.not.equal(firstStation.river_name)
Code.expect(model.stations[0].region).to.equal('North West')
})
lab.test('Test river-and-sea-level placeViewModel filters stations into groups', async () => {
const stationsData = data.riverAndSeaLevelData
const model = placeViewModel(stationsData)

Code.expect(model.filters[0].count).to.equal(74)
Code.expect(model.filters[1].count).to.equal(0)
Code.expect(model.filters[2].count).to.equal(2)
Code.expect(model.filters[3].count).to.equal(0)
})
lab.test('Test river-and-sea-level placeViewModel returns formatted date time for stations', async () => {
const stationsData = data.riverAndSeaLevelData
const model = placeViewModel(stationsData)
Code.expect(model.stations.length).to.equal(76)
Code.expect(model.stations[0].river_name).to.equal('Valley Brook')
Code.expect(model.stations[0].region).to.equal('North West')
})
lab.test('Test river-and-sea-level placeViewModel returns stations in distance order from place', async () => {
const stationsData = data.riverAndSeaLevelDataUnordered
const firstStation = data.riverAndSeaLevelDataUnordered.stations[0]
const model = placeViewModel(stationsData)

Code.expect(model.stations[0].latestDatetime).to.equal('Latest at 5:30am on 16 July ')
})
lab.test('Test river-and-sea-level placeViewModel returns formattedValue with correct number of decimal places', async () => {
const stationsData = data.riverAndSeaLevelData
const model = placeViewModel(stationsData)
Code.expect(model.stations[2].distance).to.be.greaterThan(model.stations[1].distance)
Code.expect(model.stations[0].river_name).to.not.equal(firstStation.river_name)
Code.expect(model.stations[0].region).to.equal('North West')
})
lab.test('Test river-and-sea-level placeViewModel filters stations into groups', async () => {
const stationsData = data.riverAndSeaLevelData
const model = placeViewModel(stationsData)

const station = model.stations.find(item => {
return item.station_type === 'S'
Code.expect(model.filters[0].count).to.equal(74)
Code.expect(model.filters[1].count).to.equal(0)
Code.expect(model.filters[2].count).to.equal(2)
Code.expect(model.filters[3].count).to.equal(0)
})
const rainfallStation = model.stations.find(item => {
return item.station_type === 'R'
lab.test('Test river-and-sea-level placeViewModel returns formatted date time for stations', async () => {
const stationsData = data.riverAndSeaLevelData
const model = placeViewModel(stationsData)

Code.expect(model.stations[0].latestDatetime).to.equal('Latest at 5:30am on 16 July ')
})
lab.test('Test river-and-sea-level placeViewModel returns formattedValue with correct number of decimal places', async () => {
const stationsData = data.riverAndSeaLevelData
const model = placeViewModel(stationsData)

const station = model.stations.find(item => {
return item.station_type === 'S'
})
const rainfallStation = model.stations.find(item => {
return item.station_type === 'R'
})

Code.expect(station.formattedValue).to.equal('0.22m')
Code.expect(rainfallStation.formattedValue).to.equal('0m')
})

lab.test('Test getWarnings has appropriate Value', async () => {
const stationsData = data.riverAndSeaLevelData

Code.expect(station.formattedValue).to.equal('0.22m')
Code.expect(rainfallStation.formattedValue).to.equal('0m')
const result = placeViewModel(stationsData)

Code.expect(result.getWarnings).to.equal('Rivers-and-sea-levels:Related-content:Get-warnings')
})
})

lab.experiment('referencedStationViewModel', () => {
lab.test('Test river-and-sea-level referencedStationViewModel sorts stations in distance order from rainfall station', async () => {
const stationsData = data.riverAndSeaLevelDataUnordered
Expand All @@ -80,5 +91,19 @@ lab.experiment('river-and-sea-levels model test', () => {
Code.expect(model.stations[1].distance).to.be.greaterThan(model.stations[0].distance)
Code.expect(model.stations[2].distance).to.be.greaterThan(model.stations[1].distance)
})
lab.test('Test getWarnings has appropriate Value', async () => {
const stationsData = data.riverAndSeaLevelDataUnordered
const [rainfallStation] = data.rainfallStation553564

const referencePoint = {
name: rainfallStation.station_name,
lat: rainfallStation.lat,
lon: rainfallStation.lon
}

const result = referencedStationViewModel(referencePoint, stationsData.stations)

Code.expect(result.getWarnings).to.equal('Rivers-and-sea-levels:Related-content:Get-warnings')
})
})
})