Skip to content

Commit

Permalink
Banner for end of licence cards (#1822)
Browse files Browse the repository at this point in the history
* Banner for end of licence cards

https://eaflood.atlassian.net/browse/IWTF-3748

Banner displaying information that postal licences are changing

* edit notification banner with new content, change page it opens on, add/remove tests

* fix test

* remove it.only from test

* refactor naming shownotificationbanner and wording of test
  • Loading branch information
ScottDormand96 authored Nov 22, 2023
1 parent a42727d commit ff724fa
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 68 deletions.
7 changes: 3 additions & 4 deletions packages/gafl-webapp-service/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@
"newsletter_error_set_email": "Enter an email address in the correct format, like [email protected]",
"newsletter_subscribe": "Stay up to date with the latest news on angling, fisheries and how we spend your licence money. You can unsubscribe at any time.",
"newsletter_title": "Would you like to receive our email newsletter?",
"notification_heading": "Plastic-coated card licences will be replaced by a printed letter from 31 May 2024.",
"notification_label": "Important",
"notification_text": "Choosing to get a licence by email or text message helps reduce the paper we use and invests more licence income back into fishing.",
"no_licence_req_body": "How much will this cost?",
"no_licence_req_title": "You do not need a licence yet",
"no": "No",
Expand Down Expand Up @@ -504,10 +507,6 @@
"period": ".",
"phone_number": "phone number",
"pound": "£",
"price_increase_notification_heading": "Licence prices are changing",
"price_increase_notification_label": "Important",
"price_increase_notification_link_text": "See licence price increases (opens in new tab)",
"price_increase_notification_text": "Rod fishing licences starting on or after 1 April 2023 are increasing in price.",
"pricing_summary_heading": "You can go fishing without a rod licence because you’re under 13. You’ll need to get a licence to fish as soon as you turn 13.",
"privacy_dp_officer_body_1": "Our Data Protection Officer (DPO) is responsible for independent advice and monitoring of the Environment Agency’s use of personal data. You can read our ",
"privacy_dp_officer_body_2": " which explains how we deal with personal data in general. If you have any concerns or queries about how we process personal data, or if you would like to make a complaint or request relating to data protection, please contact our DPO using the following details:",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,17 @@ describe('licence-fulfilment > route', () => {
const result = await getData(getMockRequest())
expect(result.youOrOther).toEqual(returnedValue)
})

it.each([
[true, 'true'],
[false, 'false'],
[false, undefined]
])('showNotificationBanner is %s when process.env.SHOW_NOTIFICATION_BANNER is %s', async (expectedResult, notification) => {
process.env.SHOW_NOTIFICATION_BANNER = notification
const mockRequest = getMockRequest()
const result = await getData(mockRequest)

expect(result.showNotificationBanner).toEqual(expectedResult)
})
})
})
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends "standard-form.njk" %}
{% from "radios/macro.njk" import govukRadios %}
{% from "notification-banner.njk" import notificationBanner %}

{% set title = mssgs['licence_fulfilment_title_' + data.youOrOther] %}

Expand All @@ -10,6 +11,12 @@
}
%}

{% block notificationContent %}
{% if data.showNotificationBanner %}
{{ notificationBanner(mssgs) }}
{% endif%}
{% endblock %}

{% block pageContent %}
<p class="govuk-body">{{ mssgs.licence_fulfilment_content_info }}</p>
{{ govukRadios({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export const getData = async request => {
throw new GetDataRedirect(CONTACT.uri)
}

return { youOrOther: youOrOther(permission) }
return {
showNotificationBanner: process.env.SHOW_NOTIFICATION_BANNER?.toLowerCase() === 'true',
youOrOther: youOrOther(permission)
}
}

const validator = Joi.object({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { getData } from '../route'
import { NEW_PRICES } from '../../../../uri.js'
import { addLanguageCodeToUri } from '../../../../processors/uri-helper.js'

jest.mock('../../../../processors/uri-helper.js')

Expand Down Expand Up @@ -29,22 +27,5 @@ describe('licence-to-start > route', () => {
const result = await getData(request)
expect(result.isLicenceForYou).toBeFalsy()
})

it.each([
['true', true],
['false', false],
[undefined, false]
])('SHOW_NOTIFICATION_BANNER is set to value of process.env.SHOW_NOTIFICATION_BANNER', async (notification, expectedResult) => {
process.env.SHOW_NOTIFICATION_BANNER = notification
const request = getMockRequest()
const result = await getData(request)
expect(result.SHOW_NOTIFICATION_BANNER).toEqual(expectedResult)
})

it('addLanguageCodeToUri is called with request and NEW_PRICES.uri', async () => {
const request = getMockRequest()
await getData(request)
expect(addLanguageCodeToUri).toHaveBeenCalledWith(request, NEW_PRICES.uri)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

{% from "radios/macro.njk" import govukRadios %}
{% from "date-input/macro.njk" import govukDateInput %}
{% from "notification-banner.njk" import notificationBanner %}
{% set title = mssgs.licence_start_title_you if data.isLicenceForYou else mssgs.licence_start_title_other %}

{%
Expand Down Expand Up @@ -59,12 +58,6 @@
}) }}
{% endset -%}

{% block notificationContent %}
{% if data.SHOW_NOTIFICATION_BANNER %}
{{ notificationBanner(data.uri.newPrices, mssgs) }}
{% endif %}
{% endblock %}

{% block pageContent %}

<p class="govuk-body-m"> {{ mssgs.licence_start_today_or_within + data.advancedPurchaseMaxDays + mssgs.licence_start_days }}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import moment from 'moment-timezone'

import JoiDate from '@hapi/joi-date'
import { START_AFTER_PAYMENT_MINUTES, ADVANCED_PURCHASE_MAX_DAYS, SERVICE_LOCAL_TIME } from '@defra-fish/business-rules-lib'
import { LICENCE_TO_START, NEW_PRICES } from '../../../uri.js'
import { LICENCE_TO_START } from '../../../uri.js'
import pageRoute from '../../../routes/page-route.js'
import { dateFormats } from '../../../constants.js'
import { nextPage } from '../../../routes/next-page.js'
import { addLanguageCodeToUri } from '../../../processors/uri-helper.js'

const JoiX = Joi.extend(JoiDate)

Expand Down Expand Up @@ -43,11 +42,7 @@ export const getData = async request => {
minStartDate: moment().tz(SERVICE_LOCAL_TIME).format(fmt),
maxStartDate: moment().tz(SERVICE_LOCAL_TIME).add(ADVANCED_PURCHASE_MAX_DAYS, 'days').format(fmt),
advancedPurchaseMaxDays: ADVANCED_PURCHASE_MAX_DAYS,
startAfterPaymentMinutes: START_AFTER_PAYMENT_MINUTES,
SHOW_NOTIFICATION_BANNER: process.env.SHOW_NOTIFICATION_BANNER?.toLowerCase() === 'true',
uri: {
newPrices: addLanguageCodeToUri(request, NEW_PRICES.uri)
}
startAfterPaymentMinutes: START_AFTER_PAYMENT_MINUTES
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{% from "notification-banner/macro.njk" import govukNotificationBanner %}

{% macro notificationBanner(newPricesUri, mssgs) %}
{% macro notificationBanner(mssgs) %}
{% set bannerHtml %}
<h3 class="govuk-notification-banner__heading">
{{ mssgs.price_increase_notification_heading }}
{{ mssgs.notification_heading }}
</h3>
<p class="govuk-body">
{{ mssgs.price_increase_notification_text }} <a class="govuk-notification-banner__link" target="_blank" href="{{ newPricesUri }}">{{ mssgs.price_increase_notification_link_text }}</a>
{{ mssgs.notification_text }}
</p>
{% endset %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getData } from '../route'
import { LICENCE_SUMMARY_SEEN } from '../../../../constants.js'
import { DATE_OF_BIRTH, LICENCE_LENGTH, LICENCE_TO_START, LICENCE_TYPE, NAME, NEW_TRANSACTION, NEW_PRICES } from '../../../../uri.js'
import { DATE_OF_BIRTH, LICENCE_LENGTH, LICENCE_TO_START, LICENCE_TYPE, NAME, NEW_TRANSACTION } from '../../../../uri.js'
import findPermit from '../../../../processors/find-permit.js'
import hashPermission from '../../../../processors/hash-permission.js'
import { licenceTypeDisplay } from '../../../../processors/licence-type-display.js'
Expand Down Expand Up @@ -302,10 +302,10 @@ describe('licence-summary > route', () => {
expect(transactionCacheSet).not.toHaveBeenCalled()
})

it.each([[NEW_TRANSACTION.uri], [NEW_PRICES.uri]])('addLanguageCodeToUri is called with request and %s', async uri => {
it('addLanguageCodeToUri is called with request and NEW_TRANSACTION.uri', async () => {
const mockRequest = getMockRequest()
await getData(mockRequest)
expect(addLanguageCodeToUri).toHaveBeenCalledWith(mockRequest, uri)
expect(addLanguageCodeToUri).toHaveBeenCalledWith(mockRequest, NEW_TRANSACTION.uri)
})

it('licenceTypeDisplay is called with the permission and i18n label catalog', async () => {
Expand All @@ -322,18 +322,6 @@ describe('licence-summary > route', () => {

expect(licenceTypeDisplay).toHaveBeenCalledWith(mockPermission, catalog)
})

it.each([
['true', true],
['false', false],
[undefined, false]
])('SHOW_NOTIFICATION_BANNER is set to value of process.env.SHOW_NOTIFICATION_BANNER', async (notification, expectedResult) => {
process.env.SHOW_NOTIFICATION_BANNER = notification
const mockRequest = getMockRequest()
const data = await getData(mockRequest)

expect(data.SHOW_NOTIFICATION_BANNER).toEqual(expectedResult)
})
})

describe('checkNavigation', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
{% from "fieldset/macro.njk" import govukFieldset %}
{% from "warning-text/macro.njk" import govukWarningText %}
{% from "button/macro.njk" import govukButton %}
{% from "notification-banner.njk" import notificationBanner %}

{% set title = mssgs.licence_summary_title %}
{% block pageTitle %}{{ title }}{{ mssgs.gov_uk }}{% endblock %}
Expand All @@ -27,11 +26,6 @@
{% block content %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
{% block notificationContent %}
{% if data.SHOW_NOTIFICATION_BANNER %}
{{ notificationBanner(data.uri.newPrices, mssgs) }}
{% endif%}
{% endblock %}
<form method="post">
{{ licenseDetailsSummary | trim | safe }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {
DISABILITY_CONCESSION,
DATE_OF_BIRTH,
RENEWAL_START_DATE,
NEW_TRANSACTION,
NEW_PRICES
NEW_TRANSACTION
} from '../../../uri.js'
import { START_AFTER_PAYMENT_MINUTES } from '@defra-fish/business-rules-lib'
import { LICENCE_SUMMARY_SEEN } from '../../../constants.js'
Expand Down Expand Up @@ -202,10 +201,8 @@ export const getData = async request => {
licenceSummaryRows: getLicenceSummaryRows(request, permission),
isRenewal: permission.isRenewal,
uri: {
clear: addLanguageCodeToUri(request, NEW_TRANSACTION.uri),
newPrices: addLanguageCodeToUri(request, NEW_PRICES.uri)
},
SHOW_NOTIFICATION_BANNER: process.env.SHOW_NOTIFICATION_BANNER?.toLowerCase() === 'true'
clear: addLanguageCodeToUri(request, NEW_TRANSACTION.uri)
}
}
}

Expand Down

0 comments on commit ff724fa

Please sign in to comment.