-
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.
Add tests for GREAT export enquiry activity (#7410)
* Tweak the Great transformers slightly to match the original implementation * Add tests for great export enquiry activities * Remove legacy ActivityFeed code * Fix functional test
- Loading branch information
Showing
11 changed files
with
270 additions
and
101 deletions.
There are no files selected for viewing
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
27 changes: 0 additions & 27 deletions
27
src/client/components/ActivityFeed/activities/card/ActivityCardNotes.jsx
This file was deleted.
Oops, something went wrong.
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
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
114 changes: 114 additions & 0 deletions
114
test/component/cypress/specs/Companies/CompanyActivity/GreatExportActivity.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,114 @@ | ||
import React from 'react' | ||
|
||
import { ItemTemplate } from '../../../../../../src/client/modules/Companies/CompanyActivity' | ||
import { transformGreatExportEnquiryToListItem } from '../../../../../../src/client/modules/Companies/CompanyActivity/transformers' | ||
import { CollectionList } from '../../../../../../src/client/components' | ||
import { | ||
assertMetadataItems, | ||
assertGreatKindLabel, | ||
assertText, | ||
} from '../../../support/activity-assertions' | ||
import { | ||
CONTACT_1, | ||
CREATED_BY, | ||
CREATED_ON, | ||
EMPTY_CONTACT, | ||
} from '../../../support/activity-constants' | ||
|
||
const SUBJECT = 'Lorem ipsum dolor' | ||
const NOTES = | ||
'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.' | ||
const LONG_NOTES = | ||
'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium.' | ||
|
||
const buildAndMountActivity = ( | ||
showOptionalFields, | ||
notes = NOTES, | ||
subject = SUBJECT | ||
) => { | ||
const activity = { | ||
date: CREATED_ON, | ||
great_export_enquiry: { | ||
id: '2', | ||
contact: showOptionalFields ? CONTACT_1 : EMPTY_CONTACT, | ||
data_enquiry: showOptionalFields ? notes : '', | ||
meta_subject: subject, | ||
meta_email_address: showOptionalFields ? CREATED_BY.email : '', | ||
}, | ||
} | ||
|
||
cy.mountWithProvider( | ||
<CollectionList | ||
items={[transformGreatExportEnquiryToListItem(activity)]} | ||
collectionItemTemplate={ItemTemplate} | ||
/> | ||
) | ||
} | ||
|
||
describe('Great Export Enquiry activity card', () => { | ||
context('When the card is rendered with a complete enquiry', () => { | ||
beforeEach(() => { | ||
buildAndMountActivity(true) | ||
cy.get('[data-test=collection-item]').should('exist') | ||
}) | ||
|
||
it('should render the labels and metadata', () => { | ||
assertGreatLabels() | ||
cy.get(`[data-test="collection-item"]`) | ||
.find('h3') | ||
.children() | ||
.should('exist') | ||
.should('have.text', `Enquiry ${SUBJECT}`) | ||
.should('not.have.attr', 'href') | ||
assertMetadataItems([ | ||
` ${NOTES}`, | ||
'Date 25 Nov 2058', | ||
'Contact Alexander Hamilton', | ||
'Job title Test Job', | ||
'Email [email protected]', | ||
]) | ||
}) | ||
}) | ||
|
||
context('When the enquiry has missing fields', () => { | ||
beforeEach(() => { | ||
buildAndMountActivity(false) | ||
cy.get('[data-test=collection-item]').should('exist') | ||
}) | ||
|
||
it('should render the date and the labels', () => { | ||
assertGreatLabels() | ||
assertMetadataItems(['Date 25 Nov 2058']) | ||
}) | ||
}) | ||
|
||
context('When the enquiry has a long name and notes', () => { | ||
beforeEach(() => { | ||
buildAndMountActivity(true, LONG_NOTES, LONG_NOTES) | ||
cy.get('[data-test=collection-item]').should('exist') | ||
}) | ||
|
||
it('should truncate the long fields', () => { | ||
assertGreatLabels() | ||
cy.get(`[data-test="collection-item"]`) | ||
.find('h3') | ||
.children() | ||
.should('exist') | ||
.should('have.text', 'Enquiry Lorem ipsum dolor sit amet, ...') | ||
.should('not.have.attr', 'href') | ||
assertMetadataItems([ | ||
' Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec ...', | ||
'Date 25 Nov 2058', | ||
'Contact Alexander Hamilton', | ||
'Job title Test Job', | ||
'Email [email protected]', | ||
]) | ||
}) | ||
}) | ||
}) | ||
|
||
const assertGreatLabels = () => { | ||
assertText('[data-test="great-theme-label"]', 'great.gov.uk Enquiry') | ||
assertText('[data-test="great-service-label"]', 'Export') | ||
assertGreatKindLabel() | ||
} |
Oops, something went wrong.