diff --git a/src/client/modules/Companies/CompanyExports/ExportsIndex.jsx b/src/client/modules/Companies/CompanyExports/ExportsIndex.jsx index 23375b68934..5a018652323 100644 --- a/src/client/modules/Companies/CompanyExports/ExportsIndex.jsx +++ b/src/client/modules/Companies/CompanyExports/ExportsIndex.jsx @@ -21,6 +21,7 @@ import { transformExportCountries, } from './transformers' import DefaultLayoutBase from '../../../components/Layout/DefaultLayoutBase' +import { HistoricWinsAlertBanner } from '../../ExportWins/Status/ExportWinsTabNav' const StyledSummaryTable = styled(SummaryTable)` margin-top: 0; @@ -41,6 +42,7 @@ const ExportsIndex = () => { company={company} breadcrumbs={[{ text: 'Exports' }]} pageTitle="Export" + flashMessages={[[HistoricWinsAlertBanner]]} > + + {HistoricWinsAlertBanner} + + {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 +114,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..d2d24611b5c 100644 --- a/src/client/modules/ExportWins/Form/constants.js +++ b/src/client/modules/ExportWins/Form/constants.js @@ -53,13 +53,13 @@ export const bothGoodsAndServices = { } export const STEP_TO_EXCLUDED_FIELDS_MAP = { - [steps.OFFICER_DETAILS]: ['Lead officer name'], - [steps.CUSTOMER_DETAILS]: ['Export experience'], + [steps.OFFICER_DETAILS]: ['lead officer name.'], + [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..e2f060b3b56 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_WINS_ALERT_MESSAGE } from './constants' const LAST_WORD = /([^\/]+)$/ +export const HistoricWinsAlertBanner = ( + <> + {[HISTORIC_WINS_ALERT_MESSAGE.ELEMENT].concat(' ')} + {[ + + {HISTORIC_WINS_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={[[HistoricWinsAlertBanner]]} > { function assertTable({ rows, caption, action }) { @@ -67,6 +70,10 @@ describe('Company Export tab', () => { }) }) + it('should render historic export win banner message', () => { + assertHistoricExportWinsMessage() + }) + it('should render the "Exports" table', () => { assertExportsTable(company.dnbCorp.id, [ { label: 'Export win category', value: 'None' }, diff --git a/test/functional/cypress/specs/export-win/edit-export-win-pending-spec.js.js b/test/functional/cypress/specs/export-win/edit-export-win-pending-spec.js.js index 287f3657db0..63deaac91a9 100644 --- a/test/functional/cypress/specs/export-win/edit-export-win-pending-spec.js.js +++ b/test/functional/cypress/specs/export-win/edit-export-win-pending-spec.js.js @@ -1,9 +1,48 @@ import { exportWinsFaker } from '../../fakers/export-wins' import urls from '../../../../../src/lib/urls' import { company, formFields } from './constants' +import { HISTORIC_WINS_ALERT_MESSAGE } from '../../../../../src/client/modules/ExportWins/Status/constants' const exportWin = exportWinsFaker() +export const assertHistoricExportWinsMessage = () => { + cy.get('[data-test="status-message"]') + .should('contain', HISTORIC_WINS_ALERT_MESSAGE.ELEMENT) + .should('contain.text', HISTORIC_WINS_ALERT_MESSAGE.URI_ELEMENT) + .find('a') + .should('have.attr', 'href', HISTORIC_WINS_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 assertLeadOfficerDetailsMessage = () => { + cy.get('[data-test="status-message"]').should( + 'contain.text', + 'Contact exportwins@businessandtrade.gov.uk if you need to update the section: lead officer name.' + ) +} + +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 +80,8 @@ 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() + assertLeadOfficerDetailsMessage() }) }) @@ -54,7 +91,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 +104,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 +124,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 +165,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 +174,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 +274,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.` ) })