-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
test/component/cypress/specs/Companies/CompanyActivity/OrderActivity.cy.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import React from 'react' | ||
|
||
import urls from '../../../../../../src/lib/urls' | ||
|
||
import { ItemTemplate } from '../../../../../../src/client/modules/Companies/CompanyActivity' | ||
import { transformOrderToListItem } from '../../../../../../src/client/modules/Companies/CompanyActivity/transformers' | ||
import { CollectionList } from '../../../../../../src/client/components' | ||
import { | ||
assertActivitySubject, | ||
assertMetadataItems, | ||
assertOrderKindLabel, | ||
assertText, | ||
} from '../../../support/activity-assertions' | ||
import { | ||
CONTACT_1, | ||
CONTACT_2, | ||
CREATED_BY, | ||
CREATED_ON, | ||
} from '../../../support/activity-constants' | ||
|
||
const REFERENCE = 'FYH243/24' | ||
const ORDER_URL = urls.omis.order('2') | ||
|
||
const buildAndMountActivity = (contact = CONTACT_1, ukRegion = true) => { | ||
const activity = { | ||
date: CREATED_ON, | ||
order: { | ||
id: '2', | ||
primary_market: { | ||
name: 'Test Country', | ||
}, | ||
uk_region: ukRegion | ||
? { | ||
name: 'Test UK Region', | ||
} | ||
: null, | ||
created_by: CREATED_BY, | ||
contact: contact, | ||
reference: REFERENCE, | ||
}, | ||
} | ||
|
||
cy.mountWithProvider( | ||
<CollectionList | ||
items={[transformOrderToListItem(activity)]} | ||
collectionItemTemplate={ItemTemplate} | ||
/> | ||
) | ||
} | ||
|
||
describe('Order activity card', () => { | ||
context('When the card is rendered with a complete order', () => { | ||
beforeEach(() => { | ||
buildAndMountActivity() | ||
cy.get('[data-test=collection-item]').should('exist') | ||
}) | ||
|
||
it('should render the labels and metadata', () => { | ||
assertOrderLabels() | ||
assertActivitySubject(REFERENCE, ORDER_URL) | ||
assertMetadataItems([ | ||
'Date 25 Nov 2058', | ||
'Country Test Country', | ||
'UK region Test UK Region', | ||
'Added by Bernard Harris-Patel [email protected], Test Team 1 ', | ||
'Company contact Alexander Hamilton, Test Job', | ||
]) | ||
}) | ||
}) | ||
|
||
context('When the order has missing fields', () => { | ||
beforeEach(() => { | ||
buildAndMountActivity(CONTACT_2, false) | ||
cy.get('[data-test=collection-item]').should('exist') | ||
}) | ||
|
||
it('should render the labels and metadata', () => { | ||
assertOrderLabels() | ||
assertActivitySubject(REFERENCE, ORDER_URL) | ||
assertMetadataItems([ | ||
'Date 25 Nov 2058', | ||
'Country Test Country', | ||
'Added by Bernard Harris-Patel [email protected], Test Team 1 ', | ||
'Company contact Oliver Twist', | ||
]) | ||
}) | ||
}) | ||
}) | ||
|
||
const assertOrderLabels = () => { | ||
assertText('[data-test="order-theme-label"]', 'Orders (OMIS)') | ||
assertText('[data-test="order-service-label"]', 'Event') | ||
assertOrderKindLabel() | ||
} |
72 changes: 72 additions & 0 deletions
72
test/component/cypress/specs/Companies/CompanyOverview/ActivityCard/OrderActivityCard.cy.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React from 'react' | ||
|
||
import urls from '../../../../../../../src/lib/urls' | ||
|
||
import { transformOrderToListItem } 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, | ||
assertOrderKindLabel, | ||
} from '../../../../support/activity-assertions' | ||
import { CREATED_BY, CREATED_ON } from '../../../../support/activity-constants' | ||
|
||
const REFERENCE = 'FYH243/24' | ||
const ORDER_URL = urls.omis.order('2') | ||
|
||
const buildAndMountActivity = (showCreatedBy = true) => { | ||
const activity = { | ||
date: CREATED_ON, | ||
order: { | ||
id: '2', | ||
primary_market: { | ||
name: 'Test Country', | ||
}, | ||
created_by: showCreatedBy ? CREATED_BY : null, | ||
reference: REFERENCE, | ||
}, | ||
} | ||
|
||
cy.mountWithProvider( | ||
<CollectionList | ||
items={[transformOrderToListItem(activity)]} | ||
collectionItemTemplate={ItemTemplate} | ||
/> | ||
) | ||
} | ||
|
||
describe('Order activity card', () => { | ||
context('When the card is rendered with a complete order', () => { | ||
beforeEach(() => { | ||
buildAndMountActivity() | ||
cy.get('[data-test="activity-card-wrapper"]').should('exist') | ||
}) | ||
|
||
it('should render the labels and metadata', () => { | ||
assertOrderKindLabel() | ||
assertActivitySubject(REFERENCE, ORDER_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', | ||
'Export to Test Country added by Bernard Harris-Patel' | ||
) | ||
}) | ||
}) | ||
|
||
context('When the order has no created_by name', () => { | ||
beforeEach(() => { | ||
buildAndMountActivity(false) | ||
cy.get('[data-test="activity-card-wrapper"]').should('exist') | ||
}) | ||
|
||
it('should render the labels and metadata', () => { | ||
assertOrderKindLabel() | ||
assertActivitySubject(REFERENCE, ORDER_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', | ||
'Export to Test Country' | ||
) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters