diff --git a/src/client/modules/Companies/CompanyActivity/transformers.js b/src/client/modules/Companies/CompanyActivity/transformers.js index 2bce2d69f88..ab7a327c068 100644 --- a/src/client/modules/Companies/CompanyActivity/transformers.js +++ b/src/client/modules/Companies/CompanyActivity/transformers.js @@ -215,10 +215,12 @@ export const transformOrderToListItem = (activity) => { label: 'Country', value: activity.order.primary_market.name, }, - { - label: 'UK region', - value: activity.order.uk_region, - }, + activity.order.uk_region + ? { + label: 'UK region', + value: activity.order.uk_region.name, + } + : '', { label: 'Added by', value: activity.order.created_by diff --git a/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js b/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js index 4fa80baaeca..44fc9695632 100644 --- a/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js +++ b/src/client/modules/Companies/CompanyOverview/TableCards/ActivityCards/transformers.js @@ -141,7 +141,12 @@ export const transformInvestmentToListItem = (activity) => { export const transformOrderToListItem = (activity) => { const order = activity.order - + let summary = [] + order.primary_market + ? summary.push( + `Export to ${order.primary_market.name} added by ${order.created_by.name}` + ) + : summary.push('') return { id: order.id, date: formatMediumDate(activity.date), @@ -154,7 +159,7 @@ export const transformOrderToListItem = (activity) => { ].filter(({ text }) => Boolean(text)), headingUrl: urls.omis.order(order.id), headingText: order.reference, - summary: '', + summary: summary, } } diff --git a/test/functional/cypress/fakers/company-activity.js b/test/functional/cypress/fakers/company-activity.js index 85dfe676a8d..cb2dfdde0af 100644 --- a/test/functional/cypress/fakers/company-activity.js +++ b/test/functional/cypress/fakers/company-activity.js @@ -75,15 +75,16 @@ const companyActivityInvestmentFaker = ( } } -const companyActivityOrderFaker = (overrides = {}) => ({ +const companyActivityOrderFaker = (overrides = {}, orderOverrides = {}) => ({ ...companyActivityFaker(), activity_source: 'order', order: { - primary_market: faker.location.country(), - uk_region: faker.location.county(), + primary_market: { name: faker.location.country(), id: faker.string.uuid() }, + uk_region: { id: faker.string.uuid(), name: faker.location.county() }, created_by: userFaker(), - company_contact: userFaker({ job_title: faker.person.jobTitle() }), + contact: userFaker({ job_title: faker.person.jobTitle() }), reference: faker.company.buzzPhrase(), + ...orderOverrides, }, ...overrides, }) @@ -95,12 +96,18 @@ const companyActivityInteractionListFaker = (length = 1, overrides) => overrides, }) -const companyActivityOrderListFaker = (length = 1, overrides) => - listFaker({ +const companyActivityOrderListFaker = ( + length = 1, + overrides, + orderOverrides +) => { + return listFakerAdditionalOverrides({ fakerFunction: companyActivityOrderFaker, length, overrides, + additionalOverrides: orderOverrides, }) +} const companyActivityInvestmentListFaker = ( length = 1, diff --git a/test/functional/cypress/specs/companies/activity-feed-spec.js b/test/functional/cypress/specs/companies/activity-feed-spec.js index c68df511671..ce009d91add 100644 --- a/test/functional/cypress/specs/companies/activity-feed-spec.js +++ b/test/functional/cypress/specs/companies/activity-feed-spec.js @@ -1,3 +1,6 @@ +import { collectionListRequest } from '../../support/actions' +import { companyActivityOrderListFaker } from '../../fakers/company-activity' + const fixtures = require('../../fixtures') const urls = require('../../../../../src/lib/urls') const { assertCompanyBreadcrumbs } = require('../../support/assertions') @@ -52,6 +55,11 @@ describe('Company activity feed', () => { }) context('Orders (OMIS)', () => { + const orderListNoUkRegion = companyActivityOrderListFaker( + 1, + {}, + { uk_region: null } + ) beforeEach(() => { cy.visit(urls.companies.activity.index(company.id)) }) @@ -73,7 +81,6 @@ describe('Company activity feed', () => { matchCase: false, }) }) - it('displays the order reference with link', () => { cy.get('[data-test="collection-item"]').each(() => cy @@ -86,6 +93,22 @@ describe('Company activity feed', () => { ) ) }) + it('displays the order with a uk region', () => { + cy.get('[data-test="collection-item"]').each(() => + cy.get('span').contains('UK region') + ) + }) + + it('should display Data Hub order activity with no uk region', () => { + collectionListRequest( + 'v4/search/company-activity', + orderListNoUkRegion, + urls.companies.activity.index(fixtures.company.venusLtd.id) + ) + cy.get('[data-test="collection-item"]').each(() => + cy.get('span').contains('UK region').should('not.exist') + ) + }) context('Investment project', () => { beforeEach(() => { diff --git a/test/functional/cypress/specs/companies/overview-spec.js b/test/functional/cypress/specs/companies/overview-spec.js index 42cc454d5a8..f197b83458a 100644 --- a/test/functional/cypress/specs/companies/overview-spec.js +++ b/test/functional/cypress/specs/companies/overview-spec.js @@ -396,6 +396,11 @@ describe('Company overview page', () => { { number_new_jobs: null } ) const orderList = companyActivityOrderListFaker(1) + const orderListNoPrimaryMarket = companyActivityOrderListFaker( + 1, + {}, + { primary_market: null } + ) beforeEach(() => { collectionListRequest( 'v4/search/company-activity', @@ -542,7 +547,21 @@ describe('Company overview page', () => { orderList, urls.companies.overview.index(fixtures.company.venusLtd.id) ) + const activity = orderList[0] + cy.get('[data-test="order-kind-label"]').contains('New Order') + cy.get('[data-test="activity-summary"]').contains( + `Export to ${activity.order.primary_market.name} added by ${activity.order.created_by.name}` + ) + }) + + it('should display Data Hub order with no summary', () => { + collectionListRequest( + 'v4/search/company-activity', + orderListNoPrimaryMarket, + urls.companies.overview.index(fixtures.company.venusLtd.id) + ) cy.get('[data-test="order-kind-label"]').contains('New Order') + cy.get('[data-test="activity-summary"]').should('have.value', '') }) it.skip('should display Data Hub event', () => { 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 b7cd59dc910..d23d8feb613 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 @@ -180,7 +180,10 @@ "investment": null, "order": { "reference": "HAM/100", - "uk_region": null, + "uk_region": { + "name": "England", + "id": "a80ff5fd-8904-4940-gd91-fe8047e34be5" + }, "created_on": "2024-10-16T13:21:06.209056+00:00", "contact": { "name": "bil billy",