Skip to content

Commit

Permalink
Display linked company name if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
swenban committed Dec 17, 2024
1 parent 621d147 commit 210a86a
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ export const transformEYBLeadToListItem = (activity) => {
},
].filter(({ text }) => Boolean(text)),
headingUrl: urls.investments.eybLeads.details(activity.eyb_lead.id),
headingText: activity.eyb_lead.company_name,
headingText: activity.company.name
? activity.company.name

Check warning on line 236 in src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js

View check run for this annotation

Codecov / codecov/patch

src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js#L236

Added line #L236 was not covered by tests
: activity.eyb_lead.company_name,
summary: `${getEYBValue(activity)}-value EYB lead associated with this company has been added to Data Hub`,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ import {

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 EYB_COMPANY_NAME = 'EYB Company Name'
const LINKED_COMPANY_NAME = 'Linked Company Name'

const buildAndMountActivity = (value = null) => {
const buildAndMountActivity = (value = null, linked_company_name = null) => {
const activity = {
company: {
name: linked_company_name,
},
eyb_lead: {
is_high_value: value,
created_on: '2024-12-02T09:59:03.911296+00:00',
company_name: COMPANY_NAME,
company_name: EYB_COMPANY_NAME,
triage_created: '2024-12-01T09:59:03+00:00',
id: EYB_LEAD_ID,
},
Expand All @@ -34,54 +38,147 @@ const buildAndMountActivity = (value = null) => {
}

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-date"]').should('have.text', '02 Dec 2024')
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-date"]').should('have.text', '02 Dec 2024')
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-date"]').should('have.text', '02 Dec 2024')
cy.get('[data-test="activity-summary"]').should(
'have.text',
`A low-value EYB lead associated with this company has been added to Data Hub`
)
})
})
context(
'When the card is rendered with a lead of unknown value and linked company',
() => {
beforeEach(() => {
buildAndMountActivity(null, LINKED_COMPANY_NAME)
cy.get('[data-test="activity-card-wrapper"]').should('exist')
})

it('should render the labels and metadata', () => {
assertEYBLabel()
assertActivitySubject(
LINKED_COMPANY_NAME,
PROJECT_URL,
'activity-card-wrapper'
)
cy.get('[data-test="activity-date"]').should('have.text', '02 Dec 2024')
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 and linked company',
() => {
beforeEach(() => {
buildAndMountActivity(true, LINKED_COMPANY_NAME)
cy.get('[data-test="activity-card-wrapper"]').should('exist')
})

it('should render the labels and metadata', () => {
assertEYBLabel()
assertActivitySubject(
LINKED_COMPANY_NAME,
PROJECT_URL,
'activity-card-wrapper'
)
cy.get('[data-test="activity-date"]').should('have.text', '02 Dec 2024')
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 and linked company',
() => {
beforeEach(() => {
buildAndMountActivity(false, LINKED_COMPANY_NAME)
cy.get('[data-test="activity-card-wrapper"]').should('exist')
})

it('should render the labels and metadata', () => {
assertEYBLabel()
assertActivitySubject(
LINKED_COMPANY_NAME,
PROJECT_URL,
'activity-card-wrapper'
)
cy.get('[data-test="activity-date"]').should('have.text', '02 Dec 2024')
cy.get('[data-test="activity-summary"]').should(
'have.text',
`A low-value EYB lead associated with this company has been added to Data Hub`
)
})
}
)

context(
'When the card is rendered with a lead of unknown value and no linked company',
() => {
beforeEach(() => {
buildAndMountActivity()
cy.get('[data-test="activity-card-wrapper"]').should('exist')
})

it('should render the labels and metadata', () => {
assertEYBLabel()
assertActivitySubject(
EYB_COMPANY_NAME,
PROJECT_URL,
'activity-card-wrapper'
)
cy.get('[data-test="activity-date"]').should('have.text', '02 Dec 2024')
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 and no linked company',
() => {
beforeEach(() => {
buildAndMountActivity(true)
cy.get('[data-test="activity-card-wrapper"]').should('exist')
})

it('should render the labels and metadata', () => {
assertEYBLabel()
assertActivitySubject(
EYB_COMPANY_NAME,
PROJECT_URL,
'activity-card-wrapper'
)
cy.get('[data-test="activity-date"]').should('have.text', '02 Dec 2024')
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 and no linked company',
() => {
beforeEach(() => {
buildAndMountActivity(false)
cy.get('[data-test="activity-card-wrapper"]').should('exist')
})

it('should render the labels and metadata', () => {
assertEYBLabel()
assertActivitySubject(
EYB_COMPANY_NAME,
PROJECT_URL,
'activity-card-wrapper'
)
cy.get('[data-test="activity-date"]').should('have.text', '02 Dec 2024')
cy.get('[data-test="activity-summary"]').should(
'have.text',
`A low-value EYB lead associated with this company has been added to Data Hub`
)
})
}
)
})

0 comments on commit 210a86a

Please sign in to comment.