Skip to content

Commit

Permalink
Test EYB activity card displays the correct data
Browse files Browse the repository at this point in the history
  • Loading branch information
swenban committed Dec 16, 2024
1 parent bf00eb0 commit c5083ba
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
<CollectionList
items={[transformEYBLeadToListItem(activity)]}
collectionItemTemplate={ItemTemplate}
/>
)
}

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`
)
})
})
})
4 changes: 4 additions & 0 deletions test/component/cypress/support/activity-assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}

0 comments on commit c5083ba

Please sign in to comment.