Skip to content

Commit

Permalink
Merge pull request #7254 from uktrade/TET-830-update-order-activity-s…
Browse files Browse the repository at this point in the history
…ummary

add summary to omis order
  • Loading branch information
bau123 authored Oct 24, 2024
2 parents 6f260e8 + 912b350 commit 3d053e1
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 14 deletions.
10 changes: 6 additions & 4 deletions src/client/modules/Companies/CompanyActivity/transformers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -154,7 +159,7 @@ export const transformOrderToListItem = (activity) => {
].filter(({ text }) => Boolean(text)),
headingUrl: urls.omis.order(order.id),
headingText: order.reference,
summary: '',
summary: summary,
}
}

Expand Down
19 changes: 13 additions & 6 deletions test/functional/cypress/fakers/company-activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand All @@ -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,
Expand Down
25 changes: 24 additions & 1 deletion test/functional/cypress/specs/companies/activity-feed-spec.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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))
})
Expand All @@ -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
Expand All @@ -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(() => {
Expand Down
19 changes: 19 additions & 0 deletions test/functional/cypress/specs/companies/overview-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 3d053e1

Please sign in to comment.