From 3de730a468a348c76b60efe302e6536ae7022122 Mon Sep 17 00:00:00 2001 From: Edmond De Los Reyes Date: Wed, 23 Oct 2024 13:45:59 +0100 Subject: [PATCH] Implement EW migration alert banner messages WIP --- .../modules/ExportWins/Form/ExportWinForm.jsx | 53 +++++++------- .../modules/ExportWins/Form/constants.js | 11 ++- .../ExportWins/Status/ExportWinsTabNav.jsx | 19 +++++ .../modules/ExportWins/Status/constants.js | 7 ++ .../edit-export-win-pending-spec.js.js | 70 ++++++++++++------- 5 files changed, 102 insertions(+), 58 deletions(-) diff --git a/src/client/modules/ExportWins/Form/ExportWinForm.jsx b/src/client/modules/ExportWins/Form/ExportWinForm.jsx index dc28c6c327e..79d775cfded 100644 --- a/src/client/modules/ExportWins/Form/ExportWinForm.jsx +++ b/src/client/modules/ExportWins/Form/ExportWinForm.jsx @@ -4,7 +4,6 @@ import { Link } from 'govuk-react' import { connect } from 'react-redux' import styled from 'styled-components' import pluralize from 'pluralize' -import { FONT_SIZE } from '@govuk-react/constants' import FlashMessages from '../../../components/LocalHeader/FlashMessages' import { steps, EMAIL, STEP_TO_EXCLUDED_FIELDS_MAP } from './constants' @@ -22,22 +21,11 @@ import { ExportWinSuccess } from './Success' import State from '../../../components/State' import urls from '../../../../lib/urls' import SummaryStep from './SummaryStep' -import { - Form, - FormLayout, - DefaultLayout, - StatusMessage, -} from '../../../components' +import { Form, FormLayout, DefaultLayout } from '../../../components' +import { WINS_HISTORIC_ALERT_BANNER } from '../Status/ExportWinsTabNav' const FORM_ID = 'export-win-form' -const StyledStatusMessage = styled(StatusMessage)({ - fontSize: FONT_SIZE.SIZE_20, - fontWeight: 700, - marginTop: 25, - marginBottom: 5, -}) - const StyledParagraph = styled('p')({ fontWeight: 'bold', }) @@ -93,6 +81,31 @@ const ExportWinForm = ({ heading={heading} subheading={subheading} breadcrumbs={breadcrumbs} + flashMessages={[ + [ + isEditing ? ( + <> + + {WINS_HISTORIC_ALERT_BANNER} + + {currentStepName === steps.SUMMARY ? ( + <> + + To edit an export win + + + Edit each section that needs changing then return to + the summary page. When you are happy with all the + changes save the page. + + + ) : excludedStepFields ? ( + + ) : null} + + ) : null, + ], + ]} localHeaderChildren={ isEditing ? ( currentStepName === steps.SUMMARY ? ( @@ -104,24 +117,12 @@ const ExportWinForm = ({ }} /> )} - - To edit an export win - - Edit each section that needs changing then return to - the summary page. When you are happy with all the - changes save the page. - - {winStatus === WIN_STATUS.PENDING && ( )} - ) : excludedStepFields ? ( - - - ) : null ) : null } diff --git a/src/client/modules/ExportWins/Form/constants.js b/src/client/modules/ExportWins/Form/constants.js index 9155582980c..6c985970d8c 100644 --- a/src/client/modules/ExportWins/Form/constants.js +++ b/src/client/modules/ExportWins/Form/constants.js @@ -53,13 +53,12 @@ export const bothGoodsAndServices = { } export const STEP_TO_EXCLUDED_FIELDS_MAP = { - [steps.OFFICER_DETAILS]: ['Lead officer name'], - [steps.CUSTOMER_DETAILS]: ['Export experience'], + [steps.CUSTOMER_DETAILS]: ['export experience.'], [steps.WIN_DETAILS]: [ - 'Summary of the support given', - 'Destination country', - 'Date won', - 'Type of win and Value', + 'summary of the support given', + 'destination country', + 'date won', + 'type of win and value.', ], } diff --git a/src/client/modules/ExportWins/Status/ExportWinsTabNav.jsx b/src/client/modules/ExportWins/Status/ExportWinsTabNav.jsx index d73a771e21f..430983d4c06 100644 --- a/src/client/modules/ExportWins/Status/ExportWinsTabNav.jsx +++ b/src/client/modules/ExportWins/Status/ExportWinsTabNav.jsx @@ -1,6 +1,7 @@ import React from 'react' import { useLocation } from 'react-router-dom' import { capitalize } from 'lodash' +import { Link } from 'govuk-react' import { DefaultLayout } from '../../../components' import TabNav from '../../../components/TabNav' @@ -8,9 +9,26 @@ import WinsRejectedList from './WinsRejectedList' import WinsPendingList from './WinsPendingList' import WinsConfirmedList from './WinsConfirmedList' import urls from '../../../../lib/urls' +import { HISTORIC_ALERT_MESSAGE } from './constants' const LAST_WORD = /([^\/]+)$/ +export const WINS_HISTORIC_ALERT_BANNER = ( + <> + {[HISTORIC_ALERT_MESSAGE.ELEMENT].concat(' ')} + {[ + + {HISTORIC_ALERT_MESSAGE.URI_ELEMENT} + , + ].concat('.')} + +) + const ExportWinsTabNav = () => { const location = useLocation() const match = LAST_WORD.exec(location.pathname) @@ -28,6 +46,7 @@ const ExportWinsTabNav = () => { }, { text: capitalize(title) }, ]} + flashMessages={[[WINS_HISTORIC_ALERT_BANNER]]} > { + cy.get('[data-test="status-message"]') + .should('contain', HISTORIC_ALERT_MESSAGE.ELEMENT) + .should('contain.text', HISTORIC_ALERT_MESSAGE.URI_ELEMENT) + .find('a') + .should('have.attr', 'href', HISTORIC_ALERT_MESSAGE.URI_LINK) +} + +const assertCustomerDetailsMessage = () => { + cy.get('[data-test="status-message"]').should( + 'contain.text', + 'Contact exportwins@businessandtrade.gov.uk if you need to update the section: export experience.' + ) +} + +const assertWinDetailsMessage = () => { + cy.get('[data-test="status-message"]').should( + 'contain.text', + 'Contact exportwins@businessandtrade.gov.uk if you need to update the sections: ' + + 'summary of the support given, destination country, date won, type of win and value.' + ) +} + +const assertSummaryMessage = () => { + cy.get('[data-test="status-message"]').should( + 'contain.text', + 'To edit an export win' + + 'Edit each section that needs changing then return to the summary page. ' + + 'When you are happy with all the changes save the page.' + ) +} + describe('Editing a pending export win', () => { beforeEach(() => { cy.intercept('GET', '/api-proxy/v4/export-win/*', exportWin).as( @@ -41,10 +74,7 @@ describe('Editing a pending export win', () => { urls.companies.exportWins.editOfficerDetails(company.id, exportWin.id) ) cy.wait(['@apiGetExportWin', '@apiTeamType', '@apiHqTeam']) - cy.get('[data-test="status-message"]').should( - 'have.text', - 'Contact exportwins@businessandtrade.gov.uk if you need to update the section: Lead officer name' - ) + assertHistoricExportWinsMessage() }) }) @@ -54,7 +84,7 @@ describe('Editing a pending export win', () => { urls.companies.exportWins.editCreditForThisWin(company.id, exportWin.id) ) cy.wait(['@apiGetExportWin', '@apiTeamType', '@apiHqTeam']) - cy.get('[data-test="status-message"]').should('not.exist') + assertHistoricExportWinsMessage() }) }) @@ -67,12 +97,8 @@ describe('Editing a pending export win', () => { }) it('should render an edit status message', () => { - cy.get('[data-test="status-message"]') - .should('exist') - .should( - 'have.text', - 'Contact exportwins@businessandtrade.gov.uk if you need to update the section: Export experience' - ) + assertHistoricExportWinsMessage() + assertCustomerDetailsMessage() }) it('should not render Export experience', () => { @@ -91,13 +117,8 @@ describe('Editing a pending export win', () => { }) it('should render an edit status message', () => { - cy.get('[data-test="status-message"]') - .should('exist') - .should( - 'have.text', - 'Contact exportwins@businessandtrade.gov.uk if you need to update the sections: ' + - 'Summary of the support given, Destination country, Date won, Type of win and Value' - ) + assertHistoricExportWinsMessage() + assertWinDetailsMessage() }) it('should not render a hint', () => { @@ -137,7 +158,8 @@ describe('Editing a pending export win', () => { urls.companies.exportWins.editSupportProvided(company.id, exportWin.id) ) cy.wait(['@apiGetExportWin']) - cy.get('[data-test="status-message"]').should('not.exist') + cy.get('[data-test="status-message"]') + assertHistoricExportWinsMessage() }) }) @@ -145,12 +167,8 @@ describe('Editing a pending export win', () => { it('should render an edit status message', () => { cy.visit(urls.companies.exportWins.editSummary(company.id, exportWin.id)) cy.wait(['@apiGetExportWin']) - cy.get('[data-test="status-message"]').should( - 'contain', - 'To edit an export win' + - 'Edit each section that needs changing then return to the summary page. ' + - 'When you are happy with all the changes save the page.' - ) + assertHistoricExportWinsMessage() + assertSummaryMessage() }) it('should render a lead officer name contact link', () => { @@ -249,7 +267,7 @@ describe('Editing a pending export win', () => { cy.get('[data-test="resend-export-win"]').click() cy.wait('@apiResendExportWin') cy.get('[data-test="flash"]').should( - 'have.text', + 'contain.text', `The export win ${exportWin.name_of_export} to ${exportWin.country.name} has been sent to ${exportWin.company_contacts[0].email} for review and confirmation.` ) })