Skip to content

Commit

Permalink
Merge pull request #7296 from uktrade/fix/filter-export-experience
Browse files Browse the repository at this point in the history
Filter out disabled export experience options
  • Loading branch information
paulgain authored Nov 7, 2024
2 parents c8661e2 + f28fb1b commit fd05abf
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -205,6 +206,11 @@ const ExportFormFields = ({
field={FieldRadios}
name="exporter_experience"
label="Exporter experience (optional)"
resultToOptions={(result) =>
idNamesToValueLabels(
result.filter((option) => !option.disabledOn)
)
}
/>
<FieldTextarea
name="notes"
Expand Down
3 changes: 3 additions & 0 deletions src/client/modules/ExportWins/Form/CustomerDetailsStep.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
/>
)}
</Step>
Expand Down
12 changes: 12 additions & 0 deletions test/functional/cypress/fakers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
24 changes: 17 additions & 7 deletions test/functional/cypress/specs/export-pipeline/edit-export-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const {
assertTypeaheadValues,
assertFieldDateShort,
assertPayload,
assertFieldRadiosStrict,
assertTypeaheadOptionSelected,
} = require('../../support/assertions')
const {
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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({
Expand Down
12 changes: 12 additions & 0 deletions test/sandbox/fixtures/v4/export/export-experience.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]

0 comments on commit fd05abf

Please sign in to comment.