From cfb237e5fffb3b8a770062839b8a7f99c2ea3275 Mon Sep 17 00:00:00 2001 From: Sophie Wenban Date: Thu, 12 Dec 2024 14:14:04 +0000 Subject: [PATCH 01/10] Add EYB lead card and display relationship with EYB in Investment Project card summary --- .../TableCards/ActivityCards/transformers.js | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js b/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js index 0459e25083..c03de9c56b 100644 --- a/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js +++ b/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js @@ -81,6 +81,8 @@ export const transformActivity = (activities) => { return transformOrderToListItem(activity) case 'great_export_enquiry': return transformGreatExportEnquiryToListItem(activity) + case 'eyb_lead': + return transformEYBLeadToListItem(activity) default: return {} } @@ -145,6 +147,8 @@ export const transformInteractionToListItem = (activity) => { export const transformInvestmentToListItem = (activity) => { const investment = activity.investment + const from_eyb = + activity.investment.eyb_leads.length !== 0 ? 'from EYB lead' : '' return { id: investment.id, @@ -154,8 +158,8 @@ export const transformInvestmentToListItem = (activity) => { headingText: investment.name, summary: investment.number_new_jobs == null - ? `${investment.investment_type.name} investment added by ${investment.created_by.name}` - : `${investment.investment_type.name} investment for ${checkNewJobs(investment.number_new_jobs)} ${pluraliseLabel(investment.number_new_jobs, 'new job')} added by ${investment.created_by.name}`, + ? `${investment.investment_type.name} investment added by ${investment.created_by.name} ${from_eyb}` + : `${investment.investment_type.name} investment for ${checkNewJobs(investment.number_new_jobs)} ${pluraliseLabel(investment.number_new_jobs, 'new job')} added by ${investment.created_by.name} ${from_eyb}`, } } @@ -189,3 +193,33 @@ export const transformResponseToCollection = (activities) => ({ count: activities.count, results: transformActivity(activities), }) + +export const getEYBValue = (activity) => { + const eybValue = activity.eyb_lead.is_high_value + + switch (eybValue) { + case true: + return 'A high' + case false: + return 'A low' + default: + return 'An unknown' + } +} + +export const transformEYBLeadToListItem = (activity) => { + return { + id: activity.eyb_lead.id, + date: formatDate(activity.eyb_lead.created_on), + tags: [ + { + text: 'EYB', + colour: 'grey', + dataTest: 'eyb-service-label', + }, + ].filter(({ text }) => Boolean(text)), + headingUrl: urls.investments.eybLeads.details(activity.eyb_lead.id), + headingText: activity.eyb_lead.company_name, + summary: `${getEYBValue(activity)}-value EYB lead associated with this company has been added to Data Hub`, + } +} From e0f7104bf4fcec5f0d184b59d37393ada182445e Mon Sep 17 00:00:00 2001 From: Sophie Wenban Date: Thu, 12 Dec 2024 16:34:47 +0000 Subject: [PATCH 02/10] Test investment activity summary includes EYB lead text when a lead is linked to a project --- .../TableCards/ActivityCards/transformers.js | 24 +++++++---- .../InvestmentActivityCard.cy.jsx | 41 +++++++++++++++++-- 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js b/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js index c03de9c56b..7f0d935919 100644 --- a/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js +++ b/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js @@ -145,21 +145,31 @@ export const transformInteractionToListItem = (activity) => { } } +function getInvestmentSummary(activity) { + let investment = activity.investment + let summary = `${investment.investment_type.name} investment` + if (investment.number_new_jobs === null) { + summary = summary + ` added by ${investment.created_by.name}` + } else { + summary = + summary + + ` for ${checkNewJobs(investment.number_new_jobs)} ${pluraliseLabel(investment.number_new_jobs, 'new job')} added by ${investment.created_by.name}` + } + if (activity.investment.eyb_leads.length !== 0) { + summary = summary + ' from EYB lead' + } + return summary +} + export const transformInvestmentToListItem = (activity) => { const investment = activity.investment - const from_eyb = - activity.investment.eyb_leads.length !== 0 ? 'from EYB lead' : '' - return { id: investment.id, date: formatDate(activity.date, DATE_FORMAT_MEDIUM), tags: [NEW_PROJECT_TAG].filter(({ text }) => Boolean(text)), headingUrl: urls.investments.projects.details(investment.id), headingText: investment.name, - summary: - investment.number_new_jobs == null - ? `${investment.investment_type.name} investment added by ${investment.created_by.name} ${from_eyb}` - : `${investment.investment_type.name} investment for ${checkNewJobs(investment.number_new_jobs)} ${pluraliseLabel(investment.number_new_jobs, 'new job')} added by ${investment.created_by.name} ${from_eyb}`, + summary: getInvestmentSummary(activity), } } diff --git a/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/InvestmentActivityCard.cy.jsx b/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/InvestmentActivityCard.cy.jsx index 1f66e8bfbe..8f4b9f3735 100644 --- a/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/InvestmentActivityCard.cy.jsx +++ b/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/InvestmentActivityCard.cy.jsx @@ -14,7 +14,7 @@ import { CREATED_BY, CREATED_ON } from '../../../../support/activity-constants' const NAME = 'An investment project' const PROJECT_URL = urls.investments.projects.details('2') -const buildAndMountActivity = (newJobs) => { +const buildAndMountActivity = (newJobs, eybLeads = []) => { const activity = { date: CREATED_ON, investment: { @@ -24,6 +24,7 @@ const buildAndMountActivity = (newJobs) => { investment_type: { name: 'FDI', }, + eyb_leads: eybLeads, number_new_jobs: newJobs, }, } @@ -54,7 +55,7 @@ describe('Investment activity card', () => { }) }) - context('When the project has one new job', () => { + context('When the project has one new job and no linked EYB leads', () => { beforeEach(() => { buildAndMountActivity(1) cy.get('[data-test="activity-card-wrapper"]').should('exist') @@ -71,7 +72,24 @@ describe('Investment activity card', () => { }) }) - context('When the project has no new jobs', () => { + context('When the project has one new job and one linked EYB lead', () => { + beforeEach(() => { + buildAndMountActivity(1, ['leadId1']) + cy.get('[data-test="activity-card-wrapper"]').should('exist') + }) + + it('should render the labels and metadata', () => { + assertProjectKindLabel() + assertActivitySubject(NAME, PROJECT_URL, 'activity-card-wrapper') + cy.get('[data-test="activity-date"]').should('have.text', '25 Nov 2058') + cy.get('[data-test="activity-summary"]').should( + 'have.text', + `FDI investment for 1 new job added by ${CREATED_BY.name} from EYB lead` + ) + }) + }) + + context('When the project has no new jobs and no linked EYB leads', () => { beforeEach(() => { buildAndMountActivity(0) cy.get('[data-test="activity-card-wrapper"]').should('exist') @@ -87,4 +105,21 @@ describe('Investment activity card', () => { ) }) }) + + context('When the project has no new jobs and one linked EYB leads', () => { + beforeEach(() => { + buildAndMountActivity(0, ['leadId1']) + cy.get('[data-test="activity-card-wrapper"]').should('exist') + }) + + it('should render the labels and metadata', () => { + assertProjectKindLabel() + assertActivitySubject(NAME, PROJECT_URL, 'activity-card-wrapper') + cy.get('[data-test="activity-date"]').should('have.text', '25 Nov 2058') + cy.get('[data-test="activity-summary"]').should( + 'have.text', + `FDI investment for no new jobs added by ${CREATED_BY.name} from EYB lead` + ) + }) + }) }) From fcb4ef080ad3b9f41726be8e603930e27b001857 Mon Sep 17 00:00:00 2001 From: Sophie Wenban Date: Fri, 13 Dec 2024 12:28:15 +0000 Subject: [PATCH 03/10] Add eyb_leads to faker and mock data used by sandbox and tests --- test/functional/cypress/fakers/company-activity.js | 1 + .../v4/search/company-activity/activity-by-company-id.json | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/functional/cypress/fakers/company-activity.js b/test/functional/cypress/fakers/company-activity.js index bd146f427d..6a1a6df972 100644 --- a/test/functional/cypress/fakers/company-activity.js +++ b/test/functional/cypress/fakers/company-activity.js @@ -68,6 +68,7 @@ const companyActivityInvestmentFaker = ( created_by: userFaker(), foreign_equity_investment: faker.number.int({ min: 50, max: 1000 }), gross_value_added: faker.number.int({ min: 100, max: 2000 }), + eyb_leads: [], ...investmentOverrides, }, ...overrides, diff --git a/test/sandbox/fixtures/v4/search/company-activity/activity-by-company-id.json b/test/sandbox/fixtures/v4/search/company-activity/activity-by-company-id.json index 9883c6934e..0db4a66cee 100644 --- a/test/sandbox/fixtures/v4/search/company-activity/activity-by-company-id.json +++ b/test/sandbox/fixtures/v4/search/company-activity/activity-by-company-id.json @@ -163,7 +163,8 @@ "first_name": "" }, "foreign_equity_investment": 234432, - "gross_value_added": "2000" + "gross_value_added": "2000", + "eyb_leads": [] } }, { @@ -181,7 +182,7 @@ "order": { "reference": "HAM/100", "uk_region": { - "name": "England", + "name": "England", "id": "a80ff5fd-8904-4940-gd91-fe8047e34be5" }, "created_on": "2024-10-16T13:21:06.209056+00:00", From fecfb9cc546aec56cd8759796e6afe70ca2e25c9 Mon Sep 17 00:00:00 2001 From: Sophie Wenban Date: Fri, 13 Dec 2024 13:14:43 +0000 Subject: [PATCH 04/10] Refactor tests --- .../ActivityCard/InvestmentActivityCard.cy.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/InvestmentActivityCard.cy.jsx b/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/InvestmentActivityCard.cy.jsx index 8f4b9f3735..5e463f5f72 100644 --- a/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/InvestmentActivityCard.cy.jsx +++ b/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/InvestmentActivityCard.cy.jsx @@ -13,6 +13,7 @@ import { CREATED_BY, CREATED_ON } from '../../../../support/activity-constants' const NAME = 'An investment project' const PROJECT_URL = urls.investments.projects.details('2') +const EYB_LEAD = [{ id: '1' }] const buildAndMountActivity = (newJobs, eybLeads = []) => { const activity = { @@ -74,7 +75,7 @@ describe('Investment activity card', () => { context('When the project has one new job and one linked EYB lead', () => { beforeEach(() => { - buildAndMountActivity(1, ['leadId1']) + buildAndMountActivity(1, EYB_LEAD) cy.get('[data-test="activity-card-wrapper"]').should('exist') }) @@ -108,7 +109,7 @@ describe('Investment activity card', () => { context('When the project has no new jobs and one linked EYB leads', () => { beforeEach(() => { - buildAndMountActivity(0, ['leadId1']) + buildAndMountActivity(0, EYB_LEAD) cy.get('[data-test="activity-card-wrapper"]').should('exist') }) From a22c060333db4600ad068f3b8f99f89e5e0f9ee6 Mon Sep 17 00:00:00 2001 From: Sophie Wenban Date: Fri, 13 Dec 2024 13:16:10 +0000 Subject: [PATCH 05/10] Test EYB activity card displays the correct data --- .../TableCards/ActivityCards/transformers.js | 2 +- .../ActivityCard/EYBActivityCard.cy.jsx | 84 +++++++++++++++++++ .../cypress/support/activity-assertions.js | 4 + 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/EYBActivityCard.cy.jsx diff --git a/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js b/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js index 7f0d935919..8175986ba1 100644 --- a/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js +++ b/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js @@ -225,7 +225,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 8e3f351612..7ddc39d161 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') } From b687ee1ed4b75595586e45f2bfac049fc2bf68c7 Mon Sep 17 00:00:00 2001 From: Sophie Wenban Date: Mon, 16 Dec 2024 15:18:43 +0000 Subject: [PATCH 06/10] Ensure correct text is displayed when multiple leads are linked to investment --- .../InvestmentActivityCard.cy.jsx | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/InvestmentActivityCard.cy.jsx b/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/InvestmentActivityCard.cy.jsx index 5e463f5f72..56da6669e9 100644 --- a/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/InvestmentActivityCard.cy.jsx +++ b/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/InvestmentActivityCard.cy.jsx @@ -14,6 +14,7 @@ import { CREATED_BY, CREATED_ON } from '../../../../support/activity-constants' const NAME = 'An investment project' const PROJECT_URL = urls.investments.projects.details('2') const EYB_LEAD = [{ id: '1' }] +const EYB_LEADS = [{ id: '2' }, { id: '3' }, { id: '4' }] const buildAndMountActivity = (newJobs, eybLeads = []) => { const activity = { @@ -90,6 +91,26 @@ describe('Investment activity card', () => { }) }) + context( + 'When the project has one new job and multiple linked EYB lead', + () => { + beforeEach(() => { + buildAndMountActivity(1, EYB_LEADS) + cy.get('[data-test="activity-card-wrapper"]').should('exist') + }) + + it('should render the labels and metadata', () => { + assertProjectKindLabel() + assertActivitySubject(NAME, PROJECT_URL, 'activity-card-wrapper') + cy.get('[data-test="activity-date"]').should('have.text', '25 Nov 2058') + cy.get('[data-test="activity-summary"]').should( + 'have.text', + `FDI investment for 1 new job added by ${CREATED_BY.name} from EYB lead` + ) + }) + } + ) + context('When the project has no new jobs and no linked EYB leads', () => { beforeEach(() => { buildAndMountActivity(0) @@ -123,4 +144,24 @@ describe('Investment activity card', () => { ) }) }) + + context( + 'When the project has no new jobs and mutiple linked EYB leads', + () => { + beforeEach(() => { + buildAndMountActivity(0, EYB_LEADS) + cy.get('[data-test="activity-card-wrapper"]').should('exist') + }) + + it('should render the labels and metadata', () => { + assertProjectKindLabel() + assertActivitySubject(NAME, PROJECT_URL, 'activity-card-wrapper') + cy.get('[data-test="activity-date"]').should('have.text', '25 Nov 2058') + cy.get('[data-test="activity-summary"]').should( + 'have.text', + `FDI investment for no new jobs added by ${CREATED_BY.name} from EYB lead` + ) + }) + } + ) }) From 4136ea37370fdc4962ce55819b372a5962066f77 Mon Sep 17 00:00:00 2001 From: Sophie Wenban Date: Mon, 16 Dec 2024 17:20:14 +0000 Subject: [PATCH 07/10] Test that activity for investment projects with EYB leads displays correctly on overview page --- .../cypress/fakers/company-activity.js | 2 +- .../cypress/specs/companies/overview-spec.js | 63 ++++++++++++++++--- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/test/functional/cypress/fakers/company-activity.js b/test/functional/cypress/fakers/company-activity.js index 6a1a6df972..06d84213e2 100644 --- a/test/functional/cypress/fakers/company-activity.js +++ b/test/functional/cypress/fakers/company-activity.js @@ -64,7 +64,7 @@ const companyActivityInvestmentFaker = ( name: faker.word.words(), client_contacts: [userFaker({ job_title: faker.person.jobTitle() })], id: faker.string.uuid(), - number_new_jobs: faker.number.int({ min: 0, max: 50 }), + number_new_jobs: faker.number.int({ min: 1, max: 50 }), created_by: userFaker(), foreign_equity_investment: faker.number.int({ min: 50, max: 1000 }), gross_value_added: faker.number.int({ min: 100, max: 2000 }), diff --git a/test/functional/cypress/specs/companies/overview-spec.js b/test/functional/cypress/specs/companies/overview-spec.js index 75572eba19..9daa6e5c49 100644 --- a/test/functional/cypress/specs/companies/overview-spec.js +++ b/test/functional/cypress/specs/companies/overview-spec.js @@ -391,12 +391,21 @@ describe('Company overview page', () => { // TODO - Unskip relevant parts of this test when we have the associated DAGs in place context('when viewing all activity cards types', () => { const interactionsList = companyActivityListFaker(1) - const investmentsList = companyActivityInvestmentListFaker(1) - const investmentsListNullJobs = companyActivityInvestmentListFaker( + const investmentsListWithJobsNoEYBLead = + companyActivityInvestmentListFaker(1) + const investmentsListNullJobsNoEYBLead = companyActivityInvestmentListFaker( 1, {}, { number_new_jobs: null } ) + const investmentsListWithJobsHasEYBLead = + companyActivityInvestmentListFaker(1, {}, { eyb_leads: [{ id: '1' }] }) + const investmentsListNullJobsHasEYBLead = + companyActivityInvestmentListFaker( + 1, + {}, + { number_new_jobs: null, eyb_leads: [{ id: '1' }] } + ) const orderList = companyActivityOrderListFaker(1) const orderListNoPrimaryMarket = companyActivityOrderListFaker( 1, @@ -511,34 +520,72 @@ describe('Company overview page', () => { activity.interaction.subject ) }) - it('should display Data Hub investment activity', () => { + it('should display Data Hub investment activity with jobs and no link to EYB leads', () => { collectionListRequest( 'v4/search/company-activity', - investmentsList, + investmentsListWithJobsNoEYBLead, urls.companies.overview.index(fixtures.company.venusLtd.id) ) - const activity = investmentsList[0] + const activity = investmentsListWithJobsNoEYBLead[0] cy.get('[data-test="investment-kind-label"]').contains( 'New Investment Project' ) cy.get('[data-test="activity-summary"]').contains( `${activity.investment.investment_type.name} investment for ${activity.investment.number_new_jobs} new jobs added by ${activity.investment.created_by.name}` ) + cy.get('[data-test="activity-summary"]').should( + 'not.include.text', + 'from EYB lead' + ) }) - it('should display Data Hub investment activity with empty number of new jobs', () => { + it('should display Data Hub investment activity with empty number of new jobs and no link to an EYB lead', () => { collectionListRequest( 'v4/search/company-activity', - investmentsListNullJobs, + investmentsListNullJobsNoEYBLead, urls.companies.overview.index(fixtures.company.venusLtd.id) ) - const activity = investmentsListNullJobs[0] + const activity = investmentsListNullJobsNoEYBLead[0] cy.get('[data-test="investment-kind-label"]').contains( 'New Investment Project' ) cy.get('[data-test="activity-summary"]').contains( `${activity.investment.investment_type.name} investment added by ${activity.investment.created_by.name}` ) + cy.get('[data-test="activity-summary"]').should( + 'not.include.text', + 'from EYB lead' + ) + }) + + it('should display Data Hub investment activity with jobs and link to an EYB lead', () => { + collectionListRequest( + 'v4/search/company-activity', + investmentsListWithJobsHasEYBLead, + urls.companies.overview.index(fixtures.company.venusLtd.id) + ) + const activity = investmentsListWithJobsHasEYBLead[0] + cy.get('[data-test="investment-kind-label"]').contains( + 'New Investment Project' + ) + cy.get('[data-test="activity-summary"]').contains( + `${activity.investment.investment_type.name} investment for ${activity.investment.number_new_jobs} new jobs added by ${activity.investment.created_by.name} from EYB lead` + ) + }) + + it('should display Data Hub investment activity with empty number of new jobs and link to an EYB lead', () => { + collectionListRequest( + 'v4/search/company-activity', + investmentsListNullJobsHasEYBLead, + urls.companies.overview.index(fixtures.company.venusLtd.id) + ) + const activity = investmentsListNullJobsHasEYBLead[0] + cy.get('[data-test="investment-kind-label"]').contains( + 'New Investment Project' + ) + cy.get('[data-test="activity-summary"]').contains( + `${activity.investment.investment_type.name} investment added by ${activity.investment.created_by.name} from EYB lead` + ) }) it('should display Data Hub order activity', () => { From 39fa9b67279ce3a355786d141162e4fc011fc678 Mon Sep 17 00:00:00 2001 From: Sophie Wenban Date: Tue, 17 Dec 2024 12:15:04 +0000 Subject: [PATCH 08/10] Test date is displayed on EYB card --- .../CompanyOverview/ActivityCard/EYBActivityCard.cy.jsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/EYBActivityCard.cy.jsx b/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/EYBActivityCard.cy.jsx index 894c2f1292..37304c518c 100644 --- a/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/EYBActivityCard.cy.jsx +++ b/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/EYBActivityCard.cy.jsx @@ -43,6 +43,7 @@ describe('EYB lead activity card', () => { 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` @@ -59,6 +60,7 @@ describe('EYB lead activity card', () => { 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` @@ -75,6 +77,7 @@ describe('EYB lead activity card', () => { 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` From 2b221803e2eb15630615599c6bc518767efd5312 Mon Sep 17 00:00:00 2001 From: Sophie Wenban Date: Tue, 17 Dec 2024 17:19:32 +0000 Subject: [PATCH 09/10] Test that EYB activity cards are displayed on the overview page --- .../cypress/fakers/company-activity.js | 32 ++++++++++++ .../cypress/specs/companies/overview-spec.js | 52 +++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/test/functional/cypress/fakers/company-activity.js b/test/functional/cypress/fakers/company-activity.js index 06d84213e2..2a11318e08 100644 --- a/test/functional/cypress/fakers/company-activity.js +++ b/test/functional/cypress/fakers/company-activity.js @@ -105,6 +105,28 @@ const companyActivityGreatFaker = (overrides = {}, orderOverrides = {}) => ({ ...overrides, }) +const companyActivityEYBFaker = (overrides = {}, eybOverrides = {}) => { + return { + ...companyActivityFaker(), + activity_source: 'eyb_lead', + id: faker.string.uuid(), + company: { + name: faker.company.name, + id: '1c5f7b5f-acd0-4a17-ac9d-8600bb5ded86', + }, + eyb_lead: { + is_high_value: faker.datatype.boolean(), + created_on: '2024-12-02T09:59:03.911296+00:00', + company_name: faker.company.name, + triage_created: '2024-12-01T09:59:03+00:00', + id: faker.string.uuid(), + duns_number: faker.number.int({ min: 1000000, max: 9999999 }).toString(), + ...eybOverrides, + }, + ...overrides, + } +} + const companyActivityInteractionListFaker = (length = 1, overrides) => listFaker({ fakerFunction: companyActivityInteractionFaker, @@ -151,6 +173,15 @@ const companyActivityInvestmentListFaker = ( }) } +const companyActivityEYBListFaker = (length = 1, overrides, EYBOverrides) => { + return listFakerAdditionalOverrides({ + fakerFunction: companyActivityEYBFaker, + length, + overrides, + additionalOverrides: EYBOverrides, + }) +} + export { companyActivityInteractionFaker, companyActivityInvestmentFaker, @@ -158,6 +189,7 @@ export { companyActivityInvestmentListFaker, companyActivityOrderListFaker, companyActivityGreatListFaker, + companyActivityEYBListFaker, } export default companyActivityInteractionListFaker diff --git a/test/functional/cypress/specs/companies/overview-spec.js b/test/functional/cypress/specs/companies/overview-spec.js index 9daa6e5c49..5b6f856df2 100644 --- a/test/functional/cypress/specs/companies/overview-spec.js +++ b/test/functional/cypress/specs/companies/overview-spec.js @@ -6,6 +6,7 @@ import { import { getCollectionList } from '../../support/collection-list-assertions' import { collectionListRequest } from '../../support/actions' import companyActivityListFaker, { + companyActivityEYBListFaker, companyActivityGreatListFaker, companyActivityInvestmentListFaker, companyActivityOrderListFaker, @@ -420,6 +421,21 @@ describe('Company overview page', () => { urls.companies.overview.index(fixtures.company.venusLtd.id) ) }) + const EYBListHighValue = companyActivityEYBListFaker( + 1, + {}, + { is_high_value: true } + ) + const EYBListLowValue = companyActivityEYBListFaker( + 1, + {}, + { is_high_value: false } + ) + const EYBListUnknownValue = companyActivityEYBListFaker( + 1, + {}, + { is_high_value: null } + ) it.skip('should display aventri event activity', () => { cy.get('[data-test="aventri-event-summary"]') @@ -644,6 +660,42 @@ describe('Company overview page', () => { `Enquirer ${activity.great_export_enquiry.contact.first_name} ${activity.great_export_enquiry.contact.last_name}` ) }) + + it('should display Data Hub EYB lead activity with high value', () => { + collectionListRequest( + 'v4/search/company-activity', + EYBListHighValue, + urls.companies.overview.index(fixtures.company.venusLtd.id) + ) + cy.get('[data-test="eyb-label"]').contains('EYB') + cy.get('[data-test="activity-summary"]').contains( + 'A high-value EYB lead associated with this company has been added to Data Hub' + ) + }) + + it('should display Data Hub EYB lead activity with low value', () => { + collectionListRequest( + 'v4/search/company-activity', + EYBListLowValue, + urls.companies.overview.index(fixtures.company.venusLtd.id) + ) + cy.get('[data-test="eyb-label"]').contains('EYB') + cy.get('[data-test="activity-summary"]').contains( + 'A low-value EYB lead associated with this company has been added to Data Hub' + ) + }) + + it('should display Data Hub EYB lead activity with unknown value', () => { + collectionListRequest( + 'v4/search/company-activity', + EYBListUnknownValue, + urls.companies.overview.index(fixtures.company.venusLtd.id) + ) + cy.get('[data-test="eyb-label"]').contains('EYB') + cy.get('[data-test="activity-summary"]').contains( + 'An unknown-value EYB lead associated with this company has been added to Data Hub' + ) + }) }) context( From 3232868c71782da3aec0c8262173b480854d0282 Mon Sep 17 00:00:00 2001 From: Sophie Wenban Date: Tue, 17 Dec 2024 18:11:56 +0000 Subject: [PATCH 10/10] Display linked company name if it exists --- .../TableCards/ActivityCards/transformers.js | 4 +- .../ActivityCard/EYBActivityCard.cy.jsx | 203 +++++++++++++----- 2 files changed, 153 insertions(+), 54 deletions(-) diff --git a/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js b/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js index 8175986ba1..2fef213c4e 100644 --- a/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js +++ b/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js @@ -229,7 +229,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 + : activity.eyb_lead.company_name, summary: `${getEYBValue(activity)}-value EYB lead associated with this company has been added to Data Hub`, } } diff --git a/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/EYBActivityCard.cy.jsx b/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/EYBActivityCard.cy.jsx index 37304c518c..d704537cd8 100644 --- a/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/EYBActivityCard.cy.jsx +++ b/test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/EYBActivityCard.cy.jsx @@ -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, }, @@ -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` + ) + }) + } + ) })