diff --git a/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js b/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js index c1274c9263..6fd3e95cf9 100644 --- a/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js +++ b/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js @@ -228,7 +228,7 @@ export const transformEYBLeadToListItem = (activity) => { { text: 'EYB', colour: 'grey', - dataTest: 'eyb-service-label', + dataTest: 'eyb-label', }, ].filter(({ text }) => Boolean(text)), headingUrl: urls.investments.eybLeads.details(activity.eyb_lead.id), diff --git a/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/EYBActivityCard.cy.jsx b/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/EYBActivityCard.cy.jsx new file mode 100644 index 0000000000..894c2f1292 --- /dev/null +++ b/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/EYBActivityCard.cy.jsx @@ -0,0 +1,84 @@ +import React from 'react' + +import urls from '../../../../../../../src/lib/urls' + +import { transformEYBLeadToListItem } from '../../../../../../../src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers' +import { ItemTemplate } from '../../../../../../../src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/ActivityCard' +import { CollectionList } from '../../../../../../../src/client/components' +import { + assertActivitySubject, + assertEYBLabel, +} from '../../../../support/activity-assertions' + +const EYB_LEAD_ID = 'e686c9d9-d7ba-444d-a85b-a64c477fc1ba' +const PROJECT_URL = urls.investments.eybLeads.details(EYB_LEAD_ID) +const COMPANY_NAME = 'Booth Sykes' + +const buildAndMountActivity = (value = null) => { + const activity = { + eyb_lead: { + is_high_value: value, + created_on: '2024-12-02T09:59:03.911296+00:00', + company_name: COMPANY_NAME, + triage_created: '2024-12-01T09:59:03+00:00', + id: EYB_LEAD_ID, + }, + } + + cy.mountWithProvider( + + ) +} + +describe('EYB lead activity card', () => { + context('When the card is rendered with a lead of unknown value', () => { + beforeEach(() => { + buildAndMountActivity() + cy.get('[data-test="activity-card-wrapper"]').should('exist') + }) + + it('should render the labels and metadata', () => { + assertEYBLabel() + assertActivitySubject(COMPANY_NAME, PROJECT_URL, 'activity-card-wrapper') + cy.get('[data-test="activity-summary"]').should( + 'have.text', + `An unknown-value EYB lead associated with this company has been added to Data Hub` + ) + }) + }) + + context('When the card is rendered with a lead of high value', () => { + beforeEach(() => { + buildAndMountActivity(true) + cy.get('[data-test="activity-card-wrapper"]').should('exist') + }) + + it('should render the labels and metadata', () => { + assertEYBLabel() + assertActivitySubject(COMPANY_NAME, PROJECT_URL, 'activity-card-wrapper') + cy.get('[data-test="activity-summary"]').should( + 'have.text', + `A high-value EYB lead associated with this company has been added to Data Hub` + ) + }) + }) + + context('When the card is rendered with a lead of low value', () => { + beforeEach(() => { + buildAndMountActivity(false) + cy.get('[data-test="activity-card-wrapper"]').should('exist') + }) + + it('should render the labels and metadata', () => { + assertEYBLabel() + assertActivitySubject(COMPANY_NAME, PROJECT_URL, 'activity-card-wrapper') + cy.get('[data-test="activity-summary"]').should( + 'have.text', + `A low-value EYB lead associated with this company has been added to Data Hub` + ) + }) + }) +}) diff --git a/test/component/cypress/support/activity-assertions.js b/test/component/cypress/support/activity-assertions.js index 92c14f4100..7fd1fd14c5 100644 --- a/test/component/cypress/support/activity-assertions.js +++ b/test/component/cypress/support/activity-assertions.js @@ -44,6 +44,10 @@ export const assertProjectKindLabel = () => { assertText('[data-test="investment-kind-label"]', 'New Investment Project') } +export const assertEYBLabel = () => { + assertText('[data-test="eyb-label"]', 'EYB') +} + export const assertOrderKindLabel = () => { assertText('[data-test="order-kind-label"]', 'New Order') }