Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export win content review #6582

Merged
merged 4 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -129,7 +130,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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { H3 } from '@govuk-react/heading'
import ResourceOptionsField from '../../../components/Form/elements/ResourceOptionsField'
import { getQueryParamsFromLocation } from '../../../../client/utils/url'
import { Step, FieldTypeahead } from '../../../components'
import { idNamesToValueLabels } from '../../../utils'
import { StyledHintParagraph } from './styled'
import { steps } from './constants'
import {
Expand All @@ -27,7 +28,7 @@ const CustomerDetailsStep = () => {
id={companyId}
label="Company contacts"
hint="This contact will be emailed to approve the win."
required="Select a contact"
required="Select a company contact"
placeholder="Select contact"
resource={CompanyContactsResource}
field={FieldTypeahead}
Expand All @@ -51,6 +52,9 @@ const CustomerDetailsStep = () => {
required="Select HQ location"
field={FieldTypeahead}
resource={UKRegionsResource}
resultToOptions={(result) =>
idNamesToValueLabels(result.filter(({ name }) => name !== 'All'))
}
fullWidth={true}
/>
<ResourceOptionsField
Expand Down
4 changes: 3 additions & 1 deletion src/client/modules/ExportWins/Form/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ export const validateTeamMembers = (team_members) =>
: null

export const validateWinDate = ({ month, year }) =>
!isDateWithinLastTwelveMonths(new Date(year, month - 1))
isDateWithinLastTwelveMonths(new Date(year, month - 1))
? null
: 'Date must be in the last 12 months'
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"
noResults="You don't have any rejected export wins."
payload={{ confirmed: WIN_STATUS.REJECTED }}
>
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"
noResults="You don't have any sent export wins."
payload={{ confirmed: WIN_STATUS.SENT }}
>
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 @@ -69,6 +69,7 @@ export const WinsWonTable = ({ exportWins }) => {
export default () => (
<ExportWinsResource.Paginated
id="export-wins-won"
heading="Export win"
noResults="You don't have any won export wins."
payload={{ confirmed: WIN_STATUS.WON }}
>
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
Loading