Skip to content

Commit

Permalink
Update functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgain committed Mar 5, 2024
1 parent cfc1ffe commit 88ea969
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/client/components/Resource/ExportWins.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createCollectionResource } from './Resource'

export default createCollectionResource('Export wins', 'v4/export-win')
export default createCollectionResource('Export Wins', 'v4/export-win')
3 changes: 2 additions & 1 deletion src/client/components/Resource/Paginated.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const PaginatedResource = multiInstance({
}),
component: ({
name,
heading,
id,
children,
pageSize = 10,
Expand Down Expand Up @@ -126,7 +127,7 @@ const PaginatedResource = multiInstance({
<LoadingBox name={name} id={id}>
<CollectionHeader
totalItems={result.count}
collectionName={name}
collectionName={heading || name}
/>
{totalPages > 0 && (
<StyledCollectionSort totalPages={totalPages} />
Expand Down
1 change: 1 addition & 0 deletions src/client/modules/ExportWins/Status/WinsRejectedList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import urls from '../../../../lib/urls'
export default () => (
<ExportWinsResource.Paginated
id="export-wins-rejected"
heading="Export win"
payload={{ confirmed: WIN_FILTERS.REJECTED }}
>
{(page) => (
Expand Down
1 change: 1 addition & 0 deletions src/client/modules/ExportWins/Status/WinsSentList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import urls from '../../../../lib/urls'
export default () => (
<ExportWinsResource.Paginated
id="export-wins-sent"
heading="Export win"
payload={{ confirmed: WIN_FILTERS.SENT }}
>
{(page) => (
Expand Down
1 change: 1 addition & 0 deletions src/client/modules/ExportWins/Status/WinsWonTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const WinsWonTable = ({ exportWins }) => (
export default () => (
<ExportWinsResource.Paginated
id="export-wins-won"
heading="Export win"
payload={{ confirmed: WIN_FILTERS.WON }}
>
{(page) => <WinsWonTable exportWins={page} />}
Expand Down
34 changes: 32 additions & 2 deletions test/functional/cypress/specs/export-win/add-export-win-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,14 @@ describe('Adding an export win', () => {
it('should display validation error messages on mandatory fields', () => {
clickContinueButton()
assertErrorSummary([
'Select a contact',
'Select a company contact',
'Select HQ location',
'Select export potential',
'Select export experience',
])
assertFieldError(
cy.get(customerDetails.contacts),
'Select a contact',
'Select a company contact',
true
)
assertFieldError(
Expand Down Expand Up @@ -733,6 +733,36 @@ describe('Adding an export win', () => {
)
assertFieldError(cy.get(winDetails.sector), 'Enter a sector', false)
})

it('should display a validation error message when the win date is in the future', () => {
const today = new Date()
// Indexing starts at zero (0 - 11) so we have to increment by 2 for next month
const month = today.getMonth() + 2
const year = today.getFullYear()
cy.get(winDetails.dateMonth).type(month)
cy.get(winDetails.dateYear).type(year)
clickContinueButton()
assertFieldError(
cy.get(winDetails.date),
'Date must be in the last 12 months',
true
)
})

it('should display a validation error message when the win date is greater than twelve months ago', () => {
const today = new Date()
// Indexing starts at zero (0 - 11) so no need to decrement by 1
const month = today.getMonth()
const year = today.getFullYear() - 1
cy.get(winDetails.dateMonth).type(month)
cy.get(winDetails.dateYear).type(year)
clickContinueButton()
assertFieldError(
cy.get(winDetails.date),
'Date must be in the last 12 months',
true
)
})
})

context('Support provided', () => {
Expand Down

0 comments on commit 88ea969

Please sign in to comment.