diff --git a/server/models/views/alerts-and-warnings.js b/server/models/views/alerts-and-warnings.js index aa03914bc..a053bdf55 100644 --- a/server/models/views/alerts-and-warnings.js +++ b/server/models/views/alerts-and-warnings.js @@ -21,13 +21,15 @@ class ViewModel { floodRiskUrl: config.floodRiskUrl }) + const pageTitle = place?.name ?? location + if (error) { this.pageTitle = 'Sorry, there is currently a problem searching a location' } else { if (this.station && this.station.agency_name) { this.pageTitle = `${this.station.agency_name} - flood alerts and warnings` } else { - this.pageTitle = `${location ? location + ' - f' : 'F'}lood alerts and warnings` + this.pageTitle = `${pageTitle ? pageTitle + ' - f' : 'F'}lood alerts and warnings` } } this.countFloods = floods?.floods?.length ?? 0 diff --git a/test/models/alerts-and-warnings.js b/test/models/alerts-and-warnings.js index 3ace48a52..11b371960 100644 --- a/test/models/alerts-and-warnings.js +++ b/test/models/alerts-and-warnings.js @@ -27,7 +27,7 @@ lab.test('Test exposed data placeBox is blank if not a place in England', async const Result = await new ViewModel({ location, place, floods, station }) Code.expect(Result.expose.placeBbox.length).to.equal(0) - Code.expect(Result.pageTitle).to.equal('Flood alerts and warnings') + Code.expect(Result.pageTitle).to.equal('Kinghorn - flood alerts and warnings') }) lab.test('Test count floods function returns correct number of floods', async () => {