From 63ab3e7ef5ec9378634fabcafac5dd7e88b7374c Mon Sep 17 00:00:00 2001 From: Sophie Wenban Date: Mon, 16 Dec 2024 17:20:14 +0000 Subject: [PATCH] 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', () => {