From c88723cc29329b047f06e3f317b1d87725571a00 Mon Sep 17 00:00:00 2001 From: Paul Gain Date: Wed, 21 Feb 2024 16:18:52 +0000 Subject: [PATCH 1/2] Refactor both export wins unconfirmed and confirmed Due to a design change we need to refactor the wins that are displayed within the two tabs: -Refactor unconfirmed to sent -Refactoring confirmed to won --- src/apps/routers.js | 4 +- .../modules/ExportWins/Form/ExportWinForm.jsx | 4 +- src/client/modules/ExportWins/Redirect.jsx | 4 +- .../ExportWins/Unconfirmed/unconfirmed.json | 155 ------------------ ...confirmedWinsList.jsx => WinsSentList.jsx} | 30 ++-- ...onfirmedWinsTable.jsx => WinsWonTable.jsx} | 32 ++-- src/client/modules/ExportWins/constants.js | 5 + src/client/modules/ExportWins/index.jsx | 16 +- src/client/routes.js | 4 +- src/lib/urls.js | 6 +- test/a11y/cypress/config/urlTestExclusions.js | 4 +- .../cypress/specs/ExportWins/TabNav.cy.jsx | 16 +- .../cypress/specs/ExportWins/Table.cy.jsx | 4 +- .../routes/v4/export-win/export-win.js | 8 +- 14 files changed, 75 insertions(+), 217 deletions(-) delete mode 100644 src/client/modules/ExportWins/Unconfirmed/unconfirmed.json rename src/client/modules/ExportWins/{Unconfirmed/UnconfirmedWinsList.jsx => WinsSentList.jsx} (55%) rename src/client/modules/ExportWins/{Confirmed/ConfirmedWinsTable.jsx => WinsWonTable.jsx} (63%) create mode 100644 src/client/modules/ExportWins/constants.js diff --git a/src/apps/routers.js b/src/apps/routers.js index a4dc7937608..dd8db19c373 100644 --- a/src/apps/routers.js +++ b/src/apps/routers.js @@ -28,8 +28,8 @@ const reactRoutes = [ '/exportwins', '/exportwins/create', '/exportwins/:winId/edit', - '/exportwins/confirmed', - '/exportwins/unconfirmed', + '/exportwins/won', + '/exportwins/sent', '/exportwins/:winId/details', '/companies/:companyId/dnb-hierarchy', '/companies/:companyId/company-tree', diff --git a/src/client/modules/ExportWins/Form/ExportWinForm.jsx b/src/client/modules/ExportWins/Form/ExportWinForm.jsx index 6f8cd391044..8f74386b28d 100644 --- a/src/client/modules/ExportWins/Form/ExportWinForm.jsx +++ b/src/client/modules/ExportWins/Form/ExportWinForm.jsx @@ -55,8 +55,8 @@ const ExportWinForm = ({
urls.companies.exportWins.unconfirmed()} - redirectTo={() => urls.companies.exportWins.unconfirmed()} + cancelRedirectTo={() => urls.companies.exportWins.sent()} + redirectTo={() => urls.companies.exportWins.sent()} analyticsFormName="exportWinForm" submissionTaskName={TASK_GET_EXPORT_WINS_SAVE_FORM} initialValuesTaskName={initialValuesTaskName} diff --git a/src/client/modules/ExportWins/Redirect.jsx b/src/client/modules/ExportWins/Redirect.jsx index 3ec497c1631..8cea5464abd 100644 --- a/src/client/modules/ExportWins/Redirect.jsx +++ b/src/client/modules/ExportWins/Redirect.jsx @@ -3,9 +3,9 @@ import { Redirect } from 'react-router-dom' import urls from '../../../lib/urls' -// Redirect from /exportwins to /exportwins/unconfirmed +// Redirect from /exportwins to /exportwins/sent const ExportsWinsRedirect = () => ( - + ) export default ExportsWinsRedirect diff --git a/src/client/modules/ExportWins/Unconfirmed/unconfirmed.json b/src/client/modules/ExportWins/Unconfirmed/unconfirmed.json deleted file mode 100644 index 0cf6553d57a..00000000000 --- a/src/client/modules/ExportWins/Unconfirmed/unconfirmed.json +++ /dev/null @@ -1,155 +0,0 @@ -[ - { - "id": "df35c164-7b60-41c5-babe-52570766907f", - "adviser": { - "id": "7a2a32e7-e9c2-4eda-953d-66c751a2849c", - "name": "Angela Unconfirmed" - }, - "company": { - "id": "5b6a6a83-888c-4136-9609-334ce698a5be", - "name": "Corporation" - }, - "customer_name": "John Doe", - "customer_job_title": "Director", - "customer_email_address": "john.doe@abcdef.ghi", - "customer_location": { - "id": "7b7a780f-ca7b-43b3-994e-9a288fb1f3f4" - }, - "business_type": "What kind of business deal was this win?", - "description": "Summarise the support provided to help achieve this win", - "name_of_customer": "Overseas customer", - "name_of_export": "What are the goods or services?", - "type": { - "id": "34159c9f-aac5-442b-8f1f-0e9d46634280" - }, - "date": "2023-10-10 00:00:00", - "country": { - "id": "7b143d64-65d9-4788-9ffd-32206bb0ca39", - "name": "United Kingdom" - }, - "total_expected_export_value": 1000000, - "goods_vs_services": { - "id": "c04786de-38d7-4960-97d0-833c34f66036", - "name": "Services" - }, - "total_expected_non_export_value": 10000, - "total_expected_odi_value": 0, - "sector": { - "id": "91a13b39-e9ee-428b-86ae-79453380494b", - "name": "Online gaming" - }, - "is_prosperity_fund_related": false, - "hvc": { - "id": "4975a9dc-f6e9-4c9b-8258-a8666df62170", - "campaign_id": "566e6945-a63e-4254-820d-5a20c4a9c6a8", - "financial_year": 2023, - "name": "HVC" - }, - "hvo_programme": { - "id": "5d121709-7c27-4bcf-9e9a-3889f0598b50", - "name": "Rail" - }, - "has_hvo_specialist_involvement": true, - "is_e_exported": false, - "type_of_support": [ - {"id": "08ac1fe0-3dd2-4a8a-abc5-d4c8dfc2f878", "name": "Briefing"}, - {"id": "744c7c8a-8228-40d0-a6f6-7ed4e9f138af", "name": "Other"} - ], - "associated_programme": [ - {"id": "526fd91b-1d82-4cd4-82fc-d59c637d329f", "name": "Programme 1"}, - {"id": "0fe70c28-a910-4668-93a7-60ed6af16c84", "name": "Programme 2"} - ], - "is_personally_confirmed": false, - "is_line_manager_confirmed": false, - "lead_officer": { - "id": "90895780-ada9-41fe-813b-e923a7ef5c15", - "name": "John Doe" - }, - "lead_officer_name": "John Doe", - "help_text": "This is the name that will be included in the email to the customer", - "lead_officer_email_address": "John.Doe@email", - "other_official_email_address": "", - "line_manager": { - "id": "90895780-ada9-41fe-813b-e923a7ef5c15", - "name": "John Doe" - }, - "line_manager_name": "John Doe", - "team_type": { - "id": "68c82eb8-ba96-40f3-9b25-7ef431ecaabc", - "name": "DSO" - }, - "hq_team": { - "id": "b557e5b7-82e2-4252-b7d8-58694297a37d", - "name": "DSO - RD 1C" - }, - "business_potential": { - "id": "40d9c017-6959-4357-baeb-846fe442a547", - "name": "The company is an exporter with High Export Potential" - }, - "export_experience": { - "id": "c7b95cd7-245f-4379-afa6-b07190b2f7a6", - "name": "Has never exported before" - }, - "location": "Brighton", - "complete": false, - "audit": "", - "match_id": 12345, - "company_name": "Corporation", - "cdms_reference": "UK12345", - "customer_response": { - "our_support": { - "id": "3ca4c1eb-0d86-401f-8c69-d9ceeabe7224", - "name": "N/A" - }, - "access_to_contacts": { - "id": "3ca4c1eb-0d86-401f-8c69-d9ceeabe7224", - "name": "N/A" - }, - "access_to_information": { - "id": "3ca4c1eb-0d86-401f-8c69-d9ceeabe7224", - "name": "N/A" - }, - "improved_profile": { - "id": "3ca4c1eb-0d86-401f-8c69-d9ceeabe7224", - "name": "N/A" - }, - "gained_confidence": { - "id": "3ca4c1eb-0d86-401f-8c69-d9ceeabe7224", - "name": "N/A" - }, - "developed_relationships": { - "id": "3ca4c1eb-0d86-401f-8c69-d9ceeabe7224", - "name": "N/A" - }, - "overcame_problem": { - "id": "3ca4c1eb-0d86-401f-8c69-d9ceeabe7224", - "name": "N/A" - }, - "involved_state_enterprise": true, - "interventions_were_prerequisite": true, - "support_improved_speed": true, - "expected_portion_without_help": { - "id": "fd9bcb81-61e3-4d13-bc27-96968a7d9489", - "name": "Up to 40%" - }, - "last_export": { - "id": "abcbcb82-31a3-4d13-bc27-46968a7d9153", - "name": "We had not started exporting before this win" - }, - "has_enabled_expansion_into_new_market": true, - "has_enabled_expansion_into_existing_market": true, - "has_increased_exports_as_percent_of_turnover": true, - "company_was_at_risk_of_not_exporting": true, - "has_explicit_export_plans": false, - "agree_with_win": false, - "case_study_willing": false, - "comments": "Lorem ipsum", - "name": "John Doe", - "created_on": "2020-03-23", - "marketing_source": { - "id": "b4fe471c-378d-4426-a2be-f185a85df21e", - "name": "Business / professional contacts in the private sector" - } - } - } -] diff --git a/src/client/modules/ExportWins/Unconfirmed/UnconfirmedWinsList.jsx b/src/client/modules/ExportWins/WinsSentList.jsx similarity index 55% rename from src/client/modules/ExportWins/Unconfirmed/UnconfirmedWinsList.jsx rename to src/client/modules/ExportWins/WinsSentList.jsx index 37d823dfce6..a5a2630d442 100644 --- a/src/client/modules/ExportWins/Unconfirmed/UnconfirmedWinsList.jsx +++ b/src/client/modules/ExportWins/WinsSentList.jsx @@ -1,17 +1,18 @@ import React from 'react' +import { Link as ReactRouterLink } from 'react-router-dom' import { Button } from 'govuk-react' -import { CollectionItem } from '../../../components' -import { formatMediumDate } from '../../../utils/date' -import { currencyGBP } from '../../../utils/number-utils' -import ExportWinsResource from '../../../components/Resource/ExportWins' - -import urls from '../../../../lib/urls' +import ExportWinsResource from '../../components/Resource/ExportWins' +import { currencyGBP } from '../../utils/number-utils' +import { formatMediumDate } from '../../utils/date' +import { CollectionItem } from '../../components' +import { WIN_FILTERS } from './constants' +import urls from '../../../lib/urls' export default () => ( {(page) => (
    @@ -19,7 +20,7 @@ export default () => (
  • ( { label: 'Date modified', value: '???' }, ]} buttons={ -
    - -
    + } />
  • diff --git a/src/client/modules/ExportWins/Confirmed/ConfirmedWinsTable.jsx b/src/client/modules/ExportWins/WinsWonTable.jsx similarity index 63% rename from src/client/modules/ExportWins/Confirmed/ConfirmedWinsTable.jsx rename to src/client/modules/ExportWins/WinsWonTable.jsx index 8bcfd901bd9..16b46373ecd 100644 --- a/src/client/modules/ExportWins/Confirmed/ConfirmedWinsTable.jsx +++ b/src/client/modules/ExportWins/WinsWonTable.jsx @@ -1,18 +1,19 @@ import React from 'react' +import { Link as ReactRouterLink } from 'react-router-dom' import { Table, Link } from 'govuk-react' import styled from 'styled-components' -import { Link as ReactRouterLink } from 'react-router-dom/cjs/react-router-dom' -import { currencyGBP } from '../../../utils/number-utils' -import { formatMediumDate } from '../../../utils/date' -import ExportWinsResource from '../../../components/Resource/ExportWins' -import urls from '../../../../lib/urls' +import ExportWinsResource from '../../components/Resource/ExportWins' +import { currencyGBP } from '../../utils/number-utils' +import { formatMediumDate } from '../../utils/date' +import { WIN_FILTERS } from './constants' +import urls from '../../../lib/urls' const NoWrapCell = styled(Table.Cell)` white-space: nowrap; ` -export const ExportWinsTable = ({ exportWins }) => ( +export const WinsWonTable = ({ exportWins }) => ( @@ -36,7 +37,10 @@ export const ExportWinsTable = ({ exportWins }) => ( }) => ( - + {company.name} @@ -47,8 +51,12 @@ export const ExportWinsTable = ({ exportWins }) => ( {formatMediumDate(customer_response?.created_on)} - {/* TODO: Add target to the link once the path is decided */} - View details + + View details + ) @@ -58,9 +66,9 @@ export const ExportWinsTable = ({ exportWins }) => ( export default () => ( - {(page) => } + {(page) => } ) diff --git a/src/client/modules/ExportWins/constants.js b/src/client/modules/ExportWins/constants.js new file mode 100644 index 00000000000..81e6013558e --- /dev/null +++ b/src/client/modules/ExportWins/constants.js @@ -0,0 +1,5 @@ +export const WIN_FILTERS = { + SENT: 'null', + REJECTED: false, + WON: true, +} diff --git a/src/client/modules/ExportWins/index.jsx b/src/client/modules/ExportWins/index.jsx index 686b4ed063d..a884d890697 100644 --- a/src/client/modules/ExportWins/index.jsx +++ b/src/client/modules/ExportWins/index.jsx @@ -3,8 +3,8 @@ import { capitalize } from 'lodash' import { DefaultLayout } from '../../components' import TabNav from '../../components/TabNav' -import UnconfirmedWinsList from './Unconfirmed/UnconfirmedWinsList' -import ConfirmedWinsTable from './Confirmed/ConfirmedWinsTable' +import WinsSentList from './WinsSentList' +import WinsWonTable from './WinsWonTable' import urls from '../../../lib/urls' const TITLE = /([^\/]+$)/ @@ -25,13 +25,13 @@ const ExportWins = ({ location }) => { label="Export wins tab nav" routed={true} tabs={{ - [urls.companies.exportWins.unconfirmed()]: { - label: 'Unconfirmed', - content: , + [urls.companies.exportWins.sent()]: { + label: 'Sent', + content: , }, - [urls.companies.exportWins.confirmed()]: { - label: 'Confirmed', - content: , + [urls.companies.exportWins.won()]: { + label: 'Won', + content: , }, }} /> diff --git a/src/client/routes.js b/src/client/routes.js index 474391d8d81..fc1fce9e966 100644 --- a/src/client/routes.js +++ b/src/client/routes.js @@ -465,12 +465,12 @@ const routes = { ], exportWins: [ { - path: '/exportwins/unconfirmed', + path: '/exportwins/sent', module: 'datahub:companies', component: ExportWins, }, { - path: '/exportwins/confirmed', + path: '/exportwins/won', module: 'datahub:companies', component: ExportWins, }, diff --git a/src/lib/urls.js b/src/lib/urls.js index a8b361483c7..30e72b399d9 100644 --- a/src/lib/urls.js +++ b/src/lib/urls.js @@ -221,9 +221,9 @@ module.exports = { exportWins: { index: url('/exportwins'), create: url('/exportwins/create'), - details: url('/exportwins/:winId/details'), - confirmed: url('/exportwins/confirmed'), - unconfirmed: url('/exportwins/unconfirmed'), + details: url('/exportwins', '/:winId/details'), + won: url('/exportwins/won'), + sent: url('/exportwins/sent'), }, overview: { index: url('/companies', '/:companyId/overview'), diff --git a/test/a11y/cypress/config/urlTestExclusions.js b/test/a11y/cypress/config/urlTestExclusions.js index 67e36fc3e77..e34029f3918 100644 --- a/test/a11y/cypress/config/urlTestExclusions.js +++ b/test/a11y/cypress/config/urlTestExclusions.js @@ -7,7 +7,7 @@ export const urlTestExclusions = [ { url: '/companies/:companyId/edit-history' }, { url: '/companies/:companyId/exports' }, { url: '/exportwins/' }, - { url: '/exportwins/unconfirmed/' }, + { url: '/exportwins/sent/' }, { url: '/companies/:companyId/investments/large-capital-profile' }, { url: '/companies/:companyId/account-management' }, { url: '/company-lists/' }, @@ -142,7 +142,7 @@ export const urlTestExclusions = [ { url: '/oauth/callback/' }, { url: '/oauth/sign-out/' }, { url: '/exportwins/1/details' }, - { url: '/exportwins/unconfirmed/' }, + { url: '/exportwins/sent/' }, { url: '/companies/e59a2b0f-7d84-4de7-bc1e-f70339f4255f/overview' }, // Exclude all metadata { url: '/api-proxy/v4/metadata/likelihood-to-land' }, diff --git a/test/component/cypress/specs/ExportWins/TabNav.cy.jsx b/test/component/cypress/specs/ExportWins/TabNav.cy.jsx index b5425b85eda..972c554c35a 100644 --- a/test/component/cypress/specs/ExportWins/TabNav.cy.jsx +++ b/test/component/cypress/specs/ExportWins/TabNav.cy.jsx @@ -11,7 +11,7 @@ describe('Export wins tab navigation', () => { @@ -19,24 +19,24 @@ describe('Export wins tab navigation', () => { ) context('when rendering the breadcrumbs', () => { - it('should render both Home and Unconfirmed', () => { + it('should render both Home and Sent', () => { cy.mount() assertBreadcrumbs({ Home: urls.dashboard.index(), - Unconfirmed: null, + Sent: null, }) }) - it('should render both Home and Confirmed', () => { + it('should render both Home and Won', () => { cy.mount( ) assertBreadcrumbs({ Home: urls.dashboard.index(), - Confirmed: null, + Won: null, }) }) }) @@ -49,11 +49,11 @@ describe('Export wins tab navigation', () => { }) context('When rendering the TabNav component', () => { - it('should display both Unconfirmed and Confirmed tabs', () => { + it('should display both Sent and Won tabs', () => { cy.mount() cy.get('[data-test="tablist"]').should('exist') cy.get('[data-test="tab-item"]').as('tabItems') - assertLocalNav('@tabItems', ['Unconfirmed', 'Confirmed']) + assertLocalNav('@tabItems', ['Sent', 'Won']) }) }) }) diff --git a/test/component/cypress/specs/ExportWins/Table.cy.jsx b/test/component/cypress/specs/ExportWins/Table.cy.jsx index 0421a7a46ef..5563e3f4193 100644 --- a/test/component/cypress/specs/ExportWins/Table.cy.jsx +++ b/test/component/cypress/specs/ExportWins/Table.cy.jsx @@ -1,7 +1,7 @@ import React from 'react' import DataHubProvider from '../provider' -import { ExportWinsTable } from '../../../../../src/client/modules/ExportWins/Confirmed/ConfirmedWinsTable' +import { WinsWonTable } from '../../../../../src/client/modules/ExportWins/WinsWonTable' import { exportWinsFaker } from '../../../../functional/cypress/fakers/export-wins' import { currencyGBP } from '../../../../../src/client/utils/number-utils' import { formatMediumDate } from '../../../../../src/client/utils/date' @@ -53,7 +53,7 @@ describe('Export wins table', () => { cy.mount( - + ) diff --git a/test/sandbox/routes/v4/export-win/export-win.js b/test/sandbox/routes/v4/export-win/export-win.js index 294a2c06feb..48e58e1a1f5 100644 --- a/test/sandbox/routes/v4/export-win/export-win.js +++ b/test/sandbox/routes/v4/export-win/export-win.js @@ -27,14 +27,12 @@ const fakeExportWin = (_, i) => ({ }, }) -const CONFIRMED_EXPORT_WINS = Array(123).fill().map(fakeExportWin) -const UNCONFIRMED_EXPORT_WINS = Array(123).fill().map(fakeExportWin) +const WON_EXPORT_WINS = Array(123).fill().map(fakeExportWin) +const SENT_EXPORT_WINS = Array(123).fill().map(fakeExportWin) export const getExportWinCollection = (req, res) => { const exportWins = - req.query.filter === 'unconfirmed' - ? UNCONFIRMED_EXPORT_WINS - : CONFIRMED_EXPORT_WINS + req.query.filter === 'sent' ? SENT_EXPORT_WINS : WON_EXPORT_WINS const limit = parseInt(req.query.limit, 10) const offset = parseInt(req.query.offset, 10) From 734e0a3dff9904808a6708af9368391c03ab4d5a Mon Sep 17 00:00:00 2001 From: Paul Gain Date: Wed, 21 Feb 2024 17:06:59 +0000 Subject: [PATCH 2/2] Fix broken component test --- test/component/cypress/specs/ExportWins/Table.cy.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/component/cypress/specs/ExportWins/Table.cy.jsx b/test/component/cypress/specs/ExportWins/Table.cy.jsx index 5563e3f4193..2f150aab607 100644 --- a/test/component/cypress/specs/ExportWins/Table.cy.jsx +++ b/test/component/cypress/specs/ExportWins/Table.cy.jsx @@ -78,7 +78,7 @@ describe('Export wins table', () => { .should( 'have.attr', 'href', - urls.companies.detail(exportWin.company.id) + urls.companies.overview.index(exportWin.company.id) ) )