From 6bab8c24342b5d4e001bdee6fdfd569136369a74 Mon Sep 17 00:00:00 2001 From: Paul Gain Date: Wed, 6 Nov 2024 15:33:10 +0000 Subject: [PATCH 1/3] Export projects - filter out export experience disabled options --- .../modules/ExportPipeline/ExportForm/ExportFormFields.jsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/client/modules/ExportPipeline/ExportForm/ExportFormFields.jsx b/src/client/modules/ExportPipeline/ExportForm/ExportFormFields.jsx index e6672f63fc0..b9a5e4bbe9f 100644 --- a/src/client/modules/ExportPipeline/ExportForm/ExportFormFields.jsx +++ b/src/client/modules/ExportPipeline/ExportForm/ExportFormFields.jsx @@ -38,6 +38,7 @@ import { validateTeamMembers } from './validation' import { STATUS_OPTIONS, EXPORT_POTENTIAL_OPTIONS } from '../constants' import { ERROR_MESSAGES, POSITIVE_INT_REGEX } from './constants' import { FORM_LAYOUT } from '../../../../common/constants' +import { idNamesToValueLabels } from '../../../utils' export const isPositiveInteger = (value) => POSITIVE_INT_REGEX.test(value) @@ -205,6 +206,11 @@ const ExportFormFields = ({ field={FieldRadios} name="exporter_experience" label="Exporter experience (optional)" + resultToOptions={(result) => + idNamesToValueLabels( + result.filter((option) => !option.disabledOn) + ) + } /> Date: Wed, 6 Nov 2024 15:33:33 +0000 Subject: [PATCH 2/3] Export wins - filter out export experience disabled options --- src/client/modules/ExportWins/Form/CustomerDetailsStep.jsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client/modules/ExportWins/Form/CustomerDetailsStep.jsx b/src/client/modules/ExportWins/Form/CustomerDetailsStep.jsx index ec04c337143..dce5b5c0d6f 100644 --- a/src/client/modules/ExportWins/Form/CustomerDetailsStep.jsx +++ b/src/client/modules/ExportWins/Form/CustomerDetailsStep.jsx @@ -70,6 +70,9 @@ const CustomerDetailsStep = ({ companyId, isEditing }) => ( label="Export experience" required="Select export experience" hint="Your customer will be asked to confirm this information." + resultToOptions={(result) => + idNamesToValueLabels(result.filter((option) => !option.disabledOn)) + } /> )} From f28fb1b3343b0479c3cd2631168651aa13e63950 Mon Sep 17 00:00:00 2001 From: Paul Gain Date: Thu, 7 Nov 2024 12:02:00 +0000 Subject: [PATCH 3/3] Export projects - update functional tests --- test/functional/cypress/fakers/constants.js | 12 ++++++++++ .../specs/export-pipeline/edit-export-spec.js | 24 +++++++++++++------ .../fixtures/v4/export/export-experience.json | 12 ++++++++++ 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/test/functional/cypress/fakers/constants.js b/test/functional/cypress/fakers/constants.js index 5aedfdda5b1..b479c75fb9b 100644 --- a/test/functional/cypress/fakers/constants.js +++ b/test/functional/cypress/fakers/constants.js @@ -94,6 +94,18 @@ export const EXPORTER_EXPERIENCE = [ order: 40, name: 'An exporter that DBT are helping maintain and grow their exports', }, + { + id: 'd23012c5-c1a6-459d-9e05-b3d1b8539025', + order: 1040, + disabled_on: '2018-06-20T10:19:43Z', + name: 'Is an exporter but exports currently account for less than 10% of its overall turnover', + }, + { + id: '9390cc45-6ebb-4005-866c-c87fd6d6dec0', + order: 1080, + disabled_on: '2018-06-20T10:19:43Z', + name: 'Is an exporter but has only won export orders in three countries or fewer', + }, ] export const HEADQUARTER_TYPE = [ diff --git a/test/functional/cypress/specs/export-pipeline/edit-export-spec.js b/test/functional/cypress/specs/export-pipeline/edit-export-spec.js index 318448bc84b..32738e01223 100644 --- a/test/functional/cypress/specs/export-pipeline/edit-export-spec.js +++ b/test/functional/cypress/specs/export-pipeline/edit-export-spec.js @@ -26,6 +26,7 @@ const { assertTypeaheadValues, assertFieldDateShort, assertPayload, + assertFieldRadiosStrict, assertTypeaheadOptionSelected, } = require('../../support/assertions') const { @@ -72,6 +73,11 @@ describe('Export pipeline edit', () => { const exportItem = exportFaker({ sector: sectors[0], destination_country: countries[0], + exporter_experience: { + id: '8937c359-157e-41dd-8520-679383847ea0', + order: 20, + name: 'Exported in the last 12 months, but has not won an export order by having an export plan', + }, }) const editPageUrl = urls.exportPipeline.edit(exportItem.id) @@ -200,13 +206,17 @@ describe('Export pipeline edit', () => { '[data-test="field-contacts"]', exportItem.contacts.map((t) => t.name) ) - cy.get('[data-test="field-exporter_experience"]').then((element) => { - assertFieldRadios({ - element, - label: 'Exporter experience (optional)', - optionsCount: 5, - value: exportItem.exporter_experience.name, - }) + assertFieldRadiosStrict({ + inputName: 'exporter_experience', + legend: 'Exporter experience (optional)', + options: [ + 'Never exported', + 'Exported before, but no exports in the last 12 months', + 'Exported in the last 12 months, but has not won an export order by having an export plan', + 'An exporter with a new export win, but has not exported to this country within the last 3 years', + 'An exporter that DBT are helping maintain and grow their exports', + ], + selectedIndex: 2, }) cy.get('[data-test="field-notes"]').then((element) => { assertFieldTextarea({ diff --git a/test/sandbox/fixtures/v4/export/export-experience.json b/test/sandbox/fixtures/v4/export/export-experience.json index 880870e617c..c0154ddebc8 100644 --- a/test/sandbox/fixtures/v4/export/export-experience.json +++ b/test/sandbox/fixtures/v4/export/export-experience.json @@ -23,5 +23,17 @@ "id": "02a063e3-dab8-40ca-92d3-8e9c2d9f812d", "order": 40, "name": "An exporter that DBT are helping maintain and grow their exports" + }, + { + "id": "d23012c5-c1a6-459d-9e05-b3d1b8539025", + "order": 1040, + "disabled_on": "2018-06-20T10:19:43Z", + "name": "Is an exporter but exports currently account for less than 10% of its overall turnover" + }, + { + "id": "9390cc45-6ebb-4005-866c-c87fd6d6dec0", + "order": 1080, + "disabled_on": "2018-06-20T10:19:43Z", + "name": "Is an exporter but has only won export orders in three countries or fewer" } ]