Skip to content

Commit

Permalink
How recieve licence update (1/8 day) (#1846)
Browse files Browse the repository at this point in the history
* How recieve licence update (1/8 day)

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

content for how people will recieve update for 1 or 8 day licences

* update content for adult 1/8 day licences on contact page

* fix lint

* fix code smell

* change so includes junior aswell

* remove unused code

* rename test

* factor in junior licences

* remove console logs, add junior and fix lint
  • Loading branch information
ScottDormand96 authored Jan 10, 2024
1 parent 112c897 commit 33dee9f
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 72 deletions.
7 changes: 3 additions & 4 deletions packages/gafl-webapp-service/src/locales/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@
"identify_subheading_confirm": "Cadarnhau eich manylion",
"identify_subheading_problem": "Problem gyda manylion y drwydded?",
"identify_title": "Adnewyddu eich trwydded bysgota?",
"important_info_contact_content_salmon": "Byddwn yn defnyddio’r cyfeiriad e-bost neu’r rhif symudol hwn i anfon nodyn atgoffa i anfon adroddiad daliad. Mae’n bosibl y byddwn hefyd yn anfon gwybodaeth bwysig arall, megis newidiadau sy’n effeithio ar y drwydded neu is-ddeddfau pysgota.",
"important_info_contact_content_not_salmon": "Mae’n bosibl y byddwn hefyd yn defnyddio’r cyfeiriad e-bost neu’r rhif symudol hwn i anfon gwybodaeth bwysig, megis newidiadau sy’n effeithio ar y drwydded neu’r is-ddeddfau pysgota.",
"important_info_contact_error_choose_short": "Dewiswch i ble y dylem anfon y drwydded bysgota",
"important_info_contact_error_choose": "Dewiswch sut y dylem gysylltu â deiliad y drwydded",
"important_info_contact_error_email": "Rhowch gyfeiriad e-bost yn y fformat cywir",
"important_info_contact_error_mobile": "Nodwch rif ffôn symudol yn y DU",
Expand All @@ -302,13 +305,9 @@
"important_info_contact_item_email_value": "E-bost ",
"important_info_contact_item_txt": "Neges destun",
"important_info_contact_item_txt_value": "Neges destun ",
"important_info_contact_licence_needed": "Bydd angen i ddeiliad y drwydded gadarnhau rhif y drwydded os bydd swyddog gorfodi yn gofyn.",
"important_info_contact_none_msg": "Byddwn yn dangos rhif y drwydded i chi ar ôl cadarnhau.",
"important_info_contact_note_tip": "Gwnewch nodyn o rif y drwydded",
"important_info_contact_post_hint_you": "Trwy ddewis derbyn diweddariadau drwy’r post, ni fyddwch yn derbyn dolen bersonol i adnewyddu eich trwydded ar-lein pan fydd yn dod i ben",
"important_info_contact_post_hint_other": "Trwy ddewis derbyn diweddariadau drwy’r post, ni fydd deiliad y drwydded yn derbyn dolen bersonol i adnewyddu’r dwydded ar-lein pan fydd yn dod i ben",
"important_info_contact_post_confirm_8d": "Nid ydym yn darparu cardiau ar gyfer trwyddedau 1 diwrnod neu wyth niwrnod.",
"important_info_contact_post_confirm_jr": "Nid ydym yn darparu cardiau ar gyfer trwyddedau iau.",
"important_info_contact_post_salmon_you": "Byddwn yn anfon nodyn atgoffa cyn i’ch trwydded ddod i ben, ynghyd â nodyn i’ch atgoffa i adrodd ar ddaliad. Byddwn hefyd yn anfon diweddariadau pwysig eraill, megis newidiadau i is-ddeddfau pysgota â gwialen.",
"important_info_contact_post_not_salmon_you": "Byddwn yn anfon nodyn atgoffa cyn i’ch trwydded ddod i ben. Byddwn hefyd yn anfon diweddariadau pwysig eraill, megis newidiadau i is-ddeddfau pysgota â gwialen.",
"important_info_contact_post_salmon_other": "Byddwn yn anfon nodyn atgoffa cyn i’ch trwydded ddod i ben, ynghyd â nodyn i’ch atgoffa i adrodd ar ddaliad. Byddwn hefyd yn anfon diweddariadau pwysig eraill, megis newidiadau i is-ddeddfau pysgota â gwialen.",
Expand Down
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 @@ -289,6 +289,9 @@
"identify_subheading_confirm": "Confirm your details",
"identify_subheading_problem": "Problem with the licence details?",
"identify_title": "Renew your rod fishing licence?",
"important_info_contact_content_salmon": "We will use this email or mobile number to send a reminder to report a catch return. We may also send other important information, such as changes affecting the licence or the fishing byelaws.",
"important_info_contact_content_not_salmon": "We may also use this email or mobile number to send important information, such as changes affecting the licence or the fishing byelaws.",
"important_info_contact_error_choose_short": "Choose where we should send the fishing licence",
"important_info_contact_error_choose": "Choose how we should contact the licence holder",
"important_info_contact_error_email": "Enter an email address in the correct format",
"important_info_contact_error_mobile": "Enter a UK mobile number",
Expand All @@ -301,13 +304,9 @@
"important_info_contact_item_email_value": "Email ",
"important_info_contact_item_txt": "Text message",
"important_info_contact_item_txt_value": "Text message to ",
"important_info_contact_licence_needed": "The rod licence holder will need to confirm the licence number if asked by an enforcement officer.",
"important_info_contact_none_msg": "We will show you the licence number on confirmation.",
"important_info_contact_note_tip": "Make a note of the licence number",
"important_info_contact_post_hint_you": "By choosing post, you will not get a personalised link to renew your licence online before it expires.",
"important_info_contact_post_hint_other": "By choosing post, the licence holder will not get a personalised link to renew their licence online before it expires.",
"important_info_contact_post_confirm_8d": "We don’t provide physical cards for 1 or 8 day licences.",
"important_info_contact_post_confirm_jr": "We don’t provide physical cards for junior licences.",
"important_info_contact_post_salmon_you": "We will send a renewal reminder before your licence expires and a reminder to report a catch return. We will also send other important updates, like rod fishing byelaw changes.",
"important_info_contact_post_not_salmon_you": "We will send a renewal reminder before your licence expires. We will also send other important updates, like rod fishing byelaw changes.",
"important_info_contact_post_salmon_other": "We will send a renewal reminder before the licence expires and a reminder to report a catch return. We will also send other important updates, like rod fishing byelaw changes.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ jest.mock('../../../../processors/licence-type-display.js')
jest.mock('../../../../processors/concession-helper.js')

describe('name > route', () => {
const getMockRequest = ({ isLicenceForYou, licenceType, licensee }) => ({
const getMockRequest = ({ isLicenceForYou, licenceType, licensee, licenceLength = 'length' }) => ({
cache: () => ({
helpers: {
transaction: {
getCurrentPermission: () => ({
licensee,
licenceLength: 'licenceLength',
licenceLength,
licenceStartDate: 'licenceStartDate',
isLicenceForYou,
licenceType
Expand All @@ -50,18 +50,34 @@ describe('name > route', () => {
important_info_contact_post_salmon_you: 'Salmon you',
important_info_contact_post_not_salmon_you: 'Not salmon you',
important_info_contact_post_salmon_other: 'Salmon other',
important_info_contact_post_not_salmon_other: 'Not salmon other'
important_info_contact_post_not_salmon_other: 'Not salmon other',
important_info_contact_error_choose_short: 'Short term adult error message',
important_info_contact_error_choose: 'Error message',
important_info_contact_content_salmon: 'Salmon content',
important_info_contact_content_not_salmon: 'Not salmon content',
licence_confirm_method_where_title_you: 'Where send you',
licence_confirm_method_where_title_other: 'Where send other'
})

describe('getData', () => {
it.each([
[true, 'You title'],
[false, 'Other title']
])('title return method is %s if isLicenceForYou is same', async (isLicenceForYou, expected) => {
const licensee = { birthDate: 'birthDate' }
const result = await getData(getMockRequest({ isLicenceForYou, licensee }))
expect(result.title).toBe(expected)
})
[true, '12M', false, 'You title'],
[false, '12M', false, 'Other title'],
[true, '12M', true, 'Where send you'],
[false, '12M', true, 'Where send other'],
[true, '8D', false, 'Where send you'],
[false, '8D', false, 'Where send other'],
[true, '1D', false, 'Where send you'],
[false, '1D', false, 'Where send other']
])(
'title return method is %s if isLicenceForYou is same, licenceLength is %s and junior is %s',
async (isLicenceForYou, licenceLength, junior, expected) => {
const licensee = { birthDate: 'birthDate' }
hasJunior.mockReturnValueOnce(junior)
const result = await getData(getMockRequest({ isLicenceForYou, licensee, licenceLength }))
expect(result.title).toBe(expected)
}
)

it('mobileText includes value of mobile phone when preferredMethodOfConfirmation is text', async () => {
const licensee = { birthDate: 'birthDate', preferredMethodOfConfirmation: 'Text' }
Expand Down Expand Up @@ -115,15 +131,24 @@ describe('name > route', () => {
})

it.each([
[true, 'Salmon and sea trout', 'Salmon you'],
[true, 'Trout and coarse', 'Not salmon you'],
[false, 'Salmon and sea trout', 'Salmon other'],
[false, 'Trout and coarse', 'Not salmon other']
[true, 'Salmon and sea trout', '12M', false, 'Salmon you'],
[true, 'Trout and coarse', '12M', false, 'Not salmon you'],
[false, 'Salmon and sea trout', '12M', false, 'Salmon other'],
[false, 'Trout and coarse', '12M', false, 'Not salmon other'],
[true, 'Salmon and sea trout', '8D', false, 'Salmon content'],
[true, 'Trout and coarse', '8D', false, 'Not salmon content'],
[false, 'Salmon and sea trout', '1D', false, 'Salmon content'],
[false, 'Trout and coarse', '1D', false, 'Not salmon content'],
[true, 'Salmon and sea trout', '12M', true, 'Salmon content'],
[true, 'Trout and coarse', '12M', true, 'Not salmon content'],
[false, 'Salmon and sea trout', '12M', true, 'Salmon content'],
[false, 'Trout and coarse', '12M', true, 'Not salmon content']
])(
'content has correct value depending on isLicenceForYou is %s and licenceType is %s',
async (isLicenceForYou, licenceType, expected) => {
'content has correct value depending on isLicenceForYou is %s, licenceType is %s, licenceLength is %s and junior is %s',
async (isLicenceForYou, licenceType, licenceLength, junior, expected) => {
const licensee = { birthDate: 'birthDate' }
const result = await getData(getMockRequest({ isLicenceForYou, licenceType, licensee }))
hasJunior.mockReturnValueOnce(junior)
const result = await getData(getMockRequest({ isLicenceForYou, licenceType, licensee, licenceLength }))
expect(result.content).toBe(expected)
}
)
Expand All @@ -139,13 +164,15 @@ describe('name > route', () => {
})

it.each([
[true, true],
[false, false]
])('isJunior matches return method of hasJunior', async (physical, expected) => {
['8D', false, 'Short term adult error message'],
['1D', false, 'Short term adult error message'],
['12M', false, 'Error message'],
['12M', true, 'Short term adult error message']
])('error message has correct value depending on licenceLength is %s and junior is %s', async (licenceLength, junior, expected) => {
const licensee = { birthDate: 'birthDate' }
hasJunior.mockReturnValueOnce(physical)
const result = await getData(getMockRequest({ licensee }))
expect(result.isJunior).toBe(expected)
hasJunior.mockReturnValueOnce(junior)
const result = await getData(getMockRequest({ licenceLength, licensee }))
expect(result.errorMessage).toBe(expected)
})
})

Expand Down
29 changes: 2 additions & 27 deletions packages/gafl-webapp-service/src/pages/contact/contact/contact.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% from "warning-text/macro.njk" import govukWarningText %}

{% set title = data.title %}
{% set errorMsg = mssgs.important_info_contact_error_choose %}
{% set errorMsg = data.errorMessage %}
{% set emailError = mssgs.important_info_contact_error_email %}
{% set mobileError = mssgs.important_info_contact_error_mobile %}

Expand Down Expand Up @@ -88,10 +88,6 @@
<p class="govuk-body-m">{{ mssgs.important_info_contact_post_msg }}</p>
{% endset -%}

{% set noneMessageHtml %}
<p class="govuk-body-m">{{ mssgs.important_info_contact_none_msg }}</p>
{% endset -%}

{% set itemsArray = [] %}
{% if data.emailConfirmation %}
{% set itemsArray = (itemsArray.push(
Expand Down Expand Up @@ -148,31 +144,10 @@
}), itemsArray)
%}
{% endif %}
{% else %}
{% set itemsArray = (itemsArray.push(
{
value: "none",
text: mssgs.important_info_contact_note_tip,
checked: payload['how-contacted'] === 'none',
conditional: {
html: noneMessageHtml
}
}), itemsArray)
%}
{% endif %}

{% block pageContent %}
{% if data.isPhysical %}
<p class="govuk-body-m">{{ data.content }}</p>
{% else %}
{% if data.isJunior %}
<p class="govuk-body-m">{{ mssgs.important_info_contact_post_confirm_jr }}</p>
<p class="govuk-body-m">{{ mssgs.important_info_contact_licence_needed }}</p>
{% else %}
<p class="govuk-body-m">{{ mssgs.important_info_contact_post_confirm_8d }}</p>
<p class="govuk-body-m">{{ mssgs.important_info_contact_licence_needed }}</p>
{% endif %}
{% endif %}
<p class="govuk-body-m">{{ data.content }}</p>

{{ govukRadios({
idPrefix: "how-contacted",
Expand Down
43 changes: 29 additions & 14 deletions packages/gafl-webapp-service/src/pages/contact/contact/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,45 @@ export const getData = async request => {
throw new GetDataRedirect(LICENCE_LENGTH.uri)
}

const junior = hasJunior(permission)

return {
title: getTitle(permission, mssgs),
title: getTitle(permission, mssgs, junior),
postHint: getPostHint(permission, mssgs),
content: getContent(permission, mssgs),
content: getContent(permission, mssgs, junior),
emailConfirmation: permission.licensee.preferredMethodOfConfirmation === HOW_CONTACTED.email,
emailText: getEmailText(permission, mssgs),
mobileConfirmation: permission.licensee.preferredMethodOfConfirmation === HOW_CONTACTED.text,
mobileText: getMobileText(permission, mssgs),
licensee: permission.licensee,
isPhysical: isPhysical(permission),
isJunior: hasJunior(permission)
errorMessage: getErrorText(permission, mssgs, junior)
}
}

const getTitle = (permission, messages) =>
permission.isLicenceForYou
? messages.important_info_contact_title_you
: messages.important_info_contact_title_other
const getTitle = (permission, messages, junior) => {
if (permission.licenceLength === '12M' && !junior) {
return permission.isLicenceForYou ? messages.important_info_contact_title_you : messages.important_info_contact_title_other
}
return permission.isLicenceForYou ? messages.licence_confirm_method_where_title_you : messages.licence_confirm_method_where_title_other
}

const getPostHint = (permission, messages) =>
permission.isLicenceForYou
? messages.important_info_contact_post_hint_you
: messages.important_info_contact_post_hint_other
permission.isLicenceForYou ? messages.important_info_contact_post_hint_you : messages.important_info_contact_post_hint_other

const getContent = (permission, messages) => {
if (permission.licenceType === 'Salmon and sea trout') {
return permission.isLicenceForYou ? messages.important_info_contact_post_salmon_you : messages.important_info_contact_post_salmon_other
const getContent = (permission, messages, junior) => {
const isSalmonLicense = permission.licenceType === 'Salmon and sea trout'
if (permission.licenceLength === '12M' && !junior) {
if (isSalmonLicense) {
return permission.isLicenceForYou
? messages.important_info_contact_post_salmon_you
: messages.important_info_contact_post_salmon_other
}
return permission.isLicenceForYou
? messages.important_info_contact_post_not_salmon_you
: messages.important_info_contact_post_not_salmon_other
}
return permission.isLicenceForYou ? messages.important_info_contact_post_not_salmon_you : messages.important_info_contact_post_not_salmon_other
return isSalmonLicense ? messages.important_info_contact_content_salmon : messages.important_info_contact_content_not_salmon
}

const getMobileText = (permission, messages) =>
Expand All @@ -68,6 +78,11 @@ const getEmailText = (permission, messages) =>
? `${messages.important_info_contact_item_email_value}${permission.licensee.email}`
: messages.important_info_contact_item_email

const getErrorText = (permission, messages, junior) =>
permission.licenceLength === '12M' && !junior
? messages.important_info_contact_error_choose
: messages.important_info_contact_error_choose_short

export const validator = Joi.object({
'how-contacted': Joi.string().valid('email', 'text', 'none').required(),
email: Joi.alternatives().conditional('how-contacted', {
Expand Down

0 comments on commit 33dee9f

Please sign in to comment.