Skip to content

Commit

Permalink
Merge 794a239 into e8c9a0f
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-comeau authored Nov 6, 2023
2 parents e8c9a0f + 794a239 commit 7ee37d2
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 215 deletions.
18 changes: 9 additions & 9 deletions __mocks__/next/image.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* eslint-disable @next/next/no-img-element */

import { DetailedHTMLProps, ImgHTMLAttributes } from 'react'

const NextImageMock = (
props: DetailedHTMLProps<
ImgHTMLAttributes<HTMLImageElement>,
HTMLImageElement
>,
) => {
return <img {...{ alt: '', ...props }} />
interface NextImageMockProps {
alt?: string
height?: string | number
src?: string
width?: string | number
}

const NextImageMock = ({ alt, height, src, width }: NextImageMockProps) => (
<img alt={alt} height={height} src={src} width={width} />
)

export default NextImageMock
16 changes: 8 additions & 8 deletions __tests__/api/check-status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ describe('api/check-status', () => {
async () =>
({
status: 200,
} as Response)
}) as Response,
)
global.fetch = fetchMock

const esrf = faker.helpers.replaceSymbols('?#######')
const givenName = faker.name.firstName()
const surname = faker.name.lastName()
const givenName = faker.person.firstName()
const surname = faker.person.lastName()
const dateOfBirth = faker.date.past()
const year = dateOfBirth.getFullYear().toString().padStart(4, '0')
const month = (dateOfBirth.getMonth() + 1).toString().padStart(2, '0')
Expand All @@ -68,7 +68,7 @@ describe('api/check-status', () => {
surname: checkStatusApiRequestQuery.surname,
}).toString()
expect(fetchMock).toHaveBeenCalledWith(
`http://localhost:8080/api/v1/passport-statuses/_search?${apiSearchQuery}`
`http://localhost:8080/api/v1/passport-statuses/_search?${apiSearchQuery}`,
)

fetchMock.mockClear()
Expand All @@ -80,13 +80,13 @@ describe('api/check-status', () => {
async () =>
({
status: 404,
} as Response)
}) as Response,
)
global.fetch = fetchMock

const esrf = faker.helpers.replaceSymbols('?#######')
const givenName = faker.name.firstName()
const surname = faker.name.lastName()
const givenName = faker.person.firstName()
const surname = faker.person.lastName()
const dateOfBirth = faker.date.past()
const year = dateOfBirth.getFullYear().toString().padStart(4, '0')
const month = (dateOfBirth.getMonth() + 1).toString().padStart(2, '0')
Expand All @@ -113,7 +113,7 @@ describe('api/check-status', () => {
surname: checkStatusApiRequestQuery.surname,
}).toString()
expect(fetchMock).toHaveBeenCalledWith(
`http://localhost:8080/api/v1/passport-statuses/_search?${apiSearchQuery}`
`http://localhost:8080/api/v1/passport-statuses/_search?${apiSearchQuery}`,
)

fetchMock.mockClear()
Expand Down
18 changes: 9 additions & 9 deletions __tests__/api/email-esrf.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ describe('api/email-esrf', () => {
async () =>
({
status: 202,
} as Response)
}) as Response,
)
global.fetch = fetchMock

const givenName = faker.name.firstName()
const surname = faker.name.lastName()
const email = faker.internet.email(
givenName,
surname,
'example.fakerjs.dev'
)
const givenName = faker.person.firstName()
const surname = faker.person.lastName()
const email = faker.internet.email({
firstName: givenName,
lastName: surname,
provider: 'example.fakerjs.dev',
})
const dateOfBirth = faker.date.past()
const year = dateOfBirth.getFullYear().toString().padStart(4, '0')
const month = (dateOfBirth.getMonth() + 1).toString().padStart(2, '0')
Expand Down Expand Up @@ -79,7 +79,7 @@ describe('api/email-esrf', () => {
body: `{"Client":{"BirthDate":{"Date":"${body.dateOfBirth}"},"PersonContactInformation":{"ContactEmailID":"${body.email}"},"PersonName":{"PersonGivenName":["${body.givenName}"],"PersonSurName":"${body.surname}"},"PersonPreferredLanguage":{"LanguageName":"ENGLISH"}}}`,
headers: { 'Content-Type': 'application/json' },
method: 'POST',
}
},
)

fetchMock.mockClear()
Expand Down
22 changes: 11 additions & 11 deletions cypress/e2e/email.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('email page loads', () => {
.then((text) => {
cy.title().should(
'eq',
`${text} - Passport Application Status Checker - Canada.ca`
`${text} - Passport Application Status Checker - Canada.ca`,
)
})
})
Expand All @@ -32,7 +32,7 @@ describe('email page loads', () => {
.then((text) => {
cy.title().should(
'eq',
`${text} - Vérificateur de l'état d'une demande de passeport - Canada.ca`
`${text} - Vérificateur de l'état d'une demande de passeport - Canada.ca`,
)
})
})
Expand Down Expand Up @@ -67,13 +67,13 @@ describe('email page loads', () => {

describe('responses', () => {
beforeEach(() => {
const givenName = faker.name.firstName()
const surname = faker.name.lastName()
const email = faker.internet.email(
givenName,
surname,
'example.fakerjs.dev'
)
const givenName = faker.person.firstName()
const surname = faker.person.lastName()
const email = faker.internet.email({
firstName: givenName,
lastName: surname,
provider: 'example.fakerjs.dev',
})
const dateOfBirth = faker.date.past()
const year = dateOfBirth.getFullYear().toString().padStart(4, '0')
const month = (dateOfBirth.getMonth() + 1).toString().padStart(2, '0')
Expand All @@ -90,7 +90,7 @@ describe('responses', () => {
{
statusCode: 202,
body: 'Email sent if found',
}
},
).as('email-esrf')

cy.get('#email').type(email)
Expand All @@ -108,7 +108,7 @@ describe('responses', () => {
cy.wrap(interception.request.body.surname).should('eq', surname)
cy.wrap(interception.request.body.dateOfBirth).should(
'eq',
`${year}-${month}-${day}`
`${year}-${month}-${day}`,
)
cy.wrap(interception.request.body.locale).should('eq', 'en')
})
Expand Down
20 changes: 10 additions & 10 deletions cypress/e2e/status.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('status page loads', () => {
.then((text) => {
cy.title().should(
'eq',
`${text} - Passport Application Status Checker - Canada.ca`
`${text} - Passport Application Status Checker - Canada.ca`,
)
})
})
Expand All @@ -34,7 +34,7 @@ describe('status page loads', () => {
.then((text) => {
cy.title().should(
'eq',
`${text} - Vérificateur de l'état d'une demande de passeport - Canada.ca`
`${text} - Vérificateur de l'état d'une demande de passeport - Canada.ca`,
)
})
})
Expand Down Expand Up @@ -82,7 +82,7 @@ describe('ESRF field validation', () => {

describe('givenName field validation', () => {
it('validates valid givenName', () => {
cy.get('#givenName').type(faker.name.firstName())
cy.get('#givenName').type(faker.person.firstName())
cy.get('#btn-submit').click()
cy.get('#input-givenName-error').should('not.exist')
})
Expand All @@ -95,7 +95,7 @@ describe('givenName field validation', () => {

describe('surname field validation', () => {
it('validates valid surname', () => {
cy.get('#surname').type(faker.name.lastName())
cy.get('#surname').type(faker.person.lastName())
cy.get('#btn-submit').click()
cy.get('#input-surname-error').should('not.exist')
})
Expand Down Expand Up @@ -156,8 +156,8 @@ statusCodes.forEach((response) => {
describe(`responses- loads result - '${response.status}'`, () => {
beforeEach(() => {
const esrf = faker.helpers.replaceSymbols('?#######')
const givenName = faker.name.firstName()
const surname = faker.name.lastName()
const givenName = faker.person.firstName()
const surname = faker.person.lastName()
const dateOfBirth = faker.date.past()
const year = dateOfBirth.getFullYear().toString().padStart(4, '0')
const month = (dateOfBirth.getMonth() + 1).toString().padStart(2, '0')
Expand All @@ -177,7 +177,7 @@ statusCodes.forEach((response) => {
{
statusCode: 200,
body: response,
}
},
).as('check-status')

cy.get('#esrf').type(esrf)
Expand Down Expand Up @@ -206,8 +206,8 @@ statusCodes.forEach((response) => {
describe('responses - loads no result', () => {
beforeEach(() => {
const esrf = faker.helpers.replaceSymbols('?#######')
const givenName = faker.name.firstName()
const surname = faker.name.lastName()
const givenName = faker.person.firstName()
const surname = faker.person.lastName()
const dateOfBirth = faker.date.past()
const year = dateOfBirth.getFullYear().toString().padStart(4, '0')
const month = (dateOfBirth.getMonth() + 1).toString().padStart(2, '0')
Expand All @@ -227,7 +227,7 @@ describe('responses - loads no result', () => {
{
statusCode: 404,
body: 'Passport Status Not Found',
}
},
).as('check-status')

cy.get('#esrf').type(esrf)
Expand Down
Loading

0 comments on commit 7ee37d2

Please sign in to comment.