Skip to content

Commit

Permalink
Test EYB leads with unknown values on collection and detail pages
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverjwroberts committed Dec 12, 2024
1 parent 4b5047a commit cc3d044
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
19 changes: 19 additions & 0 deletions test/functional/cypress/specs/investments/eyb-lead-details-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import {
import { investments } from '../../../../../src/lib/urls'
import { eybLeadFaker } from '../../fakers/eyb-leads'
import { NOT_SET_TEXT } from '../../../../../src/apps/companies/constants'
import { VALUES_VALUE_TO_LABEL_MAP } from '../../../../../src/client/modules/Investments/EYBLeads/constants'

const selectors = require('../../../../selectors/index')
const urls = require('../../../../../src/lib/urls')

const setup = (eybLead) => {
Expand Down Expand Up @@ -264,4 +266,21 @@ describe('EYB lead details', () => {
})
}
)
context('When viewing an EYB lead with high, low, and unknown values', () => {
const testCases = [true, false, null]
testCases.forEach((value) => {
const eybLead = eybLeadFaker({ is_high_value: value })
it('should render the value field with the correct label', () => {
setup(eybLead)
cy.visit(investments.eybLeads.details(eybLead.id))
cy.wait('@getEYBLeadDetails')
cy.get(
selectors.keyValueTable('eyb-lead-details-table').keyCell(2)
).should('have.text', 'Value')
cy.get(
selectors.keyValueTable('eyb-lead-details-table').valueCell(2)
).should('have.text', VALUES_VALUE_TO_LABEL_MAP[eybLead.is_high_value])
})
})
})
})
19 changes: 13 additions & 6 deletions test/functional/cypress/specs/investments/eyb-leads-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { investments } from '../../../../../src/lib/urls'
import { format } from '../../../../../src/client/utils/date'
import { eybLeadFaker } from '../../fakers/eyb-leads'
import { VALUES_VALUE_TO_LABEL_MAP } from '../../../../../src/client/modules/Investments/EYBLeads/constants'

const EYB_RETRIEVE_API_ROUTE = '/api-proxy/v4/investment-lead/eyb'

Expand Down Expand Up @@ -54,6 +55,7 @@ const EYB_LEAD_LIST = Array(
is_high_value: false,
country: { name: COUNTRY_NAME_1, id: COUNTRY_ID_1 },
}),
eybLeadFaker({ triage_created: DATE_TIME_STRING, is_high_value: null }),
eybLeadFaker({ triage_created: DATE_TIME_STRING, is_high_value: false }),
eybLeadFaker({
triage_created: DATE_TIME_STRING,
Expand All @@ -70,6 +72,7 @@ const PAYLOADS = {
sectorFilter: { sector: SECTOR_ID },
highValueFilter: { value: HIGH_VALUE },
lowValueFilter: { value: LOW_VALUE },
unknownValueFilter: { value: UNKNOWN_VALUE },
countryFilter: { country: COUNTRY_ID_1 },
}

Expand All @@ -94,7 +97,8 @@ const getEYBLeadsBySectorId = (sectorId) => {
const convertValueStringToBoolean = (value) => {
if (value === 'high') return true
if (value === 'low') return false
throw new Error('Invalid value: must be either "high" or "low"')
if (value === 'unknown') return null
throw new Error('Invalid value: must be either "high", "low", or "unknown"')
}

const getEYBLeadsByValue = (valueOfLead) => {
Expand Down Expand Up @@ -176,11 +180,14 @@ describe('EYB leads collection page', () => {
'contain',
`Location ${eybLead.proposed_investment_region.name}`
)
.should('contain', eybLead.is_high_value ? 'HIGH VALUE' : 'LOW VALUE')
.should(
'contain',
VALUES_VALUE_TO_LABEL_MAP[eybLead.is_high_value].toUpperCase()
)
})
it('should display the other name when company is null for a collection item', () => {
cy.get('[data-test="collection-item"]')
.eq(3)
.eq(4)
.should('contain', COMPANY_NAME_DEFAULT)
})
})
Expand Down Expand Up @@ -292,7 +299,7 @@ describe('EYB leads collection page', () => {
})

context(
'When filtering the EYB leads collection by value of leads (repeats test case for "high" and "low")',
'When filtering the EYB leads collection by value of leads (repeats test case for "high", "low", and "unknown")',
() => {
const testCases = [
{
Expand All @@ -317,10 +324,10 @@ describe('EYB leads collection page', () => {
queryParamValue: UNKNOWN_VALUE,
expectedPayload: {
...PAYLOADS.minimum,
...PAYLOADS.lowValueFilter,
...PAYLOADS.unknownValueFilter,
},
chipsLabel: UNKNOWN_VALUE_LABEL,
expectedNumberOfResults: 3,
expectedNumberOfResults: 1,
},
]

Expand Down

0 comments on commit cc3d044

Please sign in to comment.