Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into snyk-upgrade-7cb7d96991fec278ac99495cb11c0898
Browse files Browse the repository at this point in the history
nibivi77 committed Oct 25, 2023
2 parents 5f1fd3a + 4c7f35d commit e56ada8
Showing 36 changed files with 707 additions and 3,680 deletions.
9 changes: 8 additions & 1 deletion __tests__/components/BenefitTasks.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { render, screen } from '@testing-library/react'
import '@testing-library/jest-dom/extend-expect'

import { axe, toHaveNoViolations } from 'jest-axe'
import BenefitTasks from '../../components/BenefitTasks'

expect.extend(toHaveNoViolations)
// the code below is to avoid the following error: ... was not wrapped in act(...)"
jest.mock('next/link', () => {
return ({ children }) => {
return children
}
})

describe('BenefitTasks', () => {
const taskListTest = {
@@ -19,7 +26,7 @@ describe('BenefitTasks', () => {
},
],
}
it('renders Benefit Task', () => {
it('renders Benefit Task', async () => {
render(
<BenefitTasks
acronym={'test'}
8 changes: 7 additions & 1 deletion __tests__/components/Breadcrumb.test.js
Original file line number Diff line number Diff line change
@@ -8,6 +8,13 @@ import { Breadcrumb } from '../../components/Breadcrumb'

expect.extend(toHaveNoViolations)

// the code below is to avoid the following error: ... was not wrapped in act(...)"
jest.mock('next/link', () => {
return ({ children }) => {
return children
}
})

describe('BreadCrumb', () => {
it('renders primary', () => {
const primary = render(
@@ -58,7 +65,6 @@ describe('BreadCrumb', () => {
/>
)
const results = await axe(container)

expect(results).toHaveNoViolations()
})
})
7 changes: 7 additions & 0 deletions __tests__/components/ErrorPage.test.js
Original file line number Diff line number Diff line change
@@ -9,6 +9,13 @@ import { axe, toHaveNoViolations } from 'jest-axe'

expect.extend(toHaveNoViolations)

// the code below is to avoid the following error: ... was not wrapped in act(...)"
jest.mock('next/link', () => {
return ({ children }) => {
return children
}
})

describe('Error Pages', () => {
it('has no a11y violations 404', async () => {
const { container } = render(<ErrorPage lang="en" errType="404" isAuth />)
7 changes: 7 additions & 0 deletions __tests__/components/Header.test.js
Original file line number Diff line number Diff line change
@@ -8,6 +8,13 @@ import { Header } from '../../components/Header'

expect.extend(toHaveNoViolations)

// the code below is to avoid the following error: ... was not wrapped in act(...)"
jest.mock('next/link', () => {
return ({ children }) => {
return children
}
})

describe('Header', () => {
let mockFn
beforeEach(() => {
20 changes: 13 additions & 7 deletions __tests__/components/Language.test.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
/**
* @jest-environment jsdom
*/
import { render, screen, act } from '@testing-library/react'
import { render, screen, waitFor } from '@testing-library/react'
import '@testing-library/jest-dom/extend-expect'
import { axe, toHaveNoViolations } from 'jest-axe'
import { Language } from '../../components/Language'

expect.extend(toHaveNoViolations)

// the code below is to avoid the following error: ... was not wrapped in act(...)"
jest.mock('next/link', () => ({
__esModule: true,
default: ({ children, href }) => (
<children.type {...children.props} href={href} />
),
}))

describe('Language', () => {
it("renders 'English' without problems", () => {
it("renders 'English' without problems", async () => {
const englishLong = render(<Language id="enLong" lang="fr" path="/en" />)

expect(englishLong).toBeTruthy()
await waitFor(() => expect(englishLong).toBeTruthy())
expect(screen.getByText('English')).toBeInTheDocument
})

it("renders 'EN' without problems", () => {
it("renders 'EN' without problems", async () => {
const englishAbbr = render(
<Language id="enAbbr" lang="fr" path="/en" abbr="EN" />
)

expect(englishAbbr).toBeTruthy()
await waitFor(() => expect(englishAbbr).toBeTruthy())
expect(screen.getByText('EN')).toBeInTheDocument
})

4 changes: 4 additions & 0 deletions __tests__/components/ProfileTasks.test.js
Original file line number Diff line number Diff line change
@@ -14,11 +14,15 @@ describe('ProfileTasks', () => {
title: 'Province of residence',
icon: 'circle',
link: '/dashboard',
areaLabel: 'task1',
betaPopUp: false,
},
{
title: 'Language of correspondence',
icon: 'stamp',
link: '/dashboard',
areaLabel: 'task2',
betaPopUp: false,
},
]}
/>
15 changes: 14 additions & 1 deletion __tests__/pages/profile.test.js
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import { render, screen } from '@testing-library/react'
import '@testing-library/jest-dom'
import Profile from '../../pages/profile'
import Heading from '../../components/Heading'
import { getServerSideProps } from '../../pages/profile'

import { useRouter } from 'next/router'
@@ -57,6 +58,10 @@ jest.mock('../../graphql/mappers/auth-modals', () => ({
},
}))

jest.mock('../../components/Heading')
// return props.title from Heading mock
Heading.mockImplementation((props) => props.title)

describe('My Profile page', () => {
const content = {
list: [
@@ -69,7 +74,7 @@ describe('My Profile page', () => {
areaLabel: 'areaLabel',
link: '/',
icon: '',
betaPopUp: 'betaPopUp',
betaPopUp: false,
},
],
},
@@ -97,6 +102,10 @@ describe('My Profile page', () => {
it('should render the page in English', () => {
render(
<Profile
heading={{
id: 'my-dashboard-heading',
title: 'pageName',
}}
locale="en"
content={content}
meta={{}}
@@ -113,6 +122,10 @@ describe('My Profile page', () => {
it('should render the page in French', () => {
render(
<Profile
heading={{
id: 'my-dashboard-headingFR',
title: 'headingFR',
}}
locale="fr"
content={content}
meta={{}}
2 changes: 1 addition & 1 deletion components/Card.js
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ export default function Card(props) {
className="pb-6 md:pb-8 md:pt-4 px-3 sm:px-8 md:px-15 w-full"
acronym={props.acronym}
refPageAA={props.refPageAA}
ariaLabel={props.cardTitle}
ariaLabel={`${props.cardTitle} - ${props.viewMoreLessCaption}`}
/>
{!isOpen ? null : (
<div className="pb-6" data-cy="sectionList">
4 changes: 2 additions & 2 deletions components/ContextualAlert.js
Original file line number Diff line number Diff line change
@@ -87,8 +87,8 @@ ContextualAlert.propTypes = {
/**
* heading text
*/
message_heading: PropTypes.string.isRequired,

message_heading: PropTypes.oneOfType([PropTypes.string, PropTypes.object])
.isRequired,
/**
* body text
*/
6 changes: 3 additions & 3 deletions components/Footer.js
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ export function Footer(props) {
href={btnLink}
className="sm:hidden float-left cursor-pointer text-sm"
>
Top of page / Haut de la page
{t.topOfPage}
<FontAwesomeIcon
icon={icon['chevron-up']}
className="text-sm sm:hidden pl-2"
@@ -89,7 +89,7 @@ export function Footer(props) {
})}
<li className="sm:hidden float-left cursor-pointer text-sm">
<a id="top_btn" href={btnLink}>
Top of page / Haut de la page
{t.topOfPage}
<FontAwesomeIcon
icon={icon['chevron-up']}
className="text-sm sm:hidden pl-2"
@@ -112,7 +112,7 @@ export function Footer(props) {
: 'h-[25px] md:h-[40px] w-[105px] md:w-[164px]'
} my-[15px]`}
src={logo}
alt="Symbol of the Government of Canada"
alt={t.footerCanadaCaAltText}
width={143}
height={34}
/>
6 changes: 5 additions & 1 deletion components/Header.js
Original file line number Diff line number Diff line change
@@ -40,7 +40,11 @@ export function Header(props) {
: 'md:max-h-[35px] max-h-[20px]'
} md:max-w-[360px] max-w-[206px]`}
src={lang === 'en' ? logoFile : logoFileFR}
alt="Government of Canada"
alt={
lang === 'en'
? 'Government of Canada'
: 'Governement du Canada'
}
width={819}
height={76}
/>
24 changes: 16 additions & 8 deletions components/Menu.js
Original file line number Diff line number Diff line change
@@ -28,18 +28,26 @@ export function Menu(props) {
return () => window.removeEventListener('click', handleClick)
}, [showDropdown])

useEffect(() => {
if (!showDropdown) return
function handleEsc(event) {
if (event.key === 'Escape') {
setShowDropdown(false)
}
}
window.addEventListener('keydown', handleEsc)
return () => window.removeEventListener('keydown', handleEsc)
}, [showDropdown])

return (
<div className="relative w-full bg-blue-primary">
<div className="w-full bg-blue-primary">
<nav className="sch-container sch-container-menu sm:flex items-center justify-between sm:h-[60px]">
<div className="h-[60px] flex sm:h-full items-center">
<p
id="mainSiteNav"
className="text-white font-display font-bold md:text-[24px] text-[19px] sm:p-0 sch-container mb-0 pr-0 sm:ml-4 md:ml-0"
>
<div className="h-[60px] flex items-center text-white font-display font-bold text-[19px] leading-[21px] md:text-2xl mx-15px md:m-0 ">
<span id="mainSiteNav">
{lang === 'fr'
? 'Mon dossier Service Canada'
: 'My Service Canada Account'}
</p>
</span>
</div>
<div
className="w-full sm:w-[260px] h-full bg-bright-blue-pale hover:bg-gray-50a focus:bg-gray-50a"
@@ -54,7 +62,7 @@ export function Menu(props) {
aria-haspopup="true"
data-testid="menuButton"
aria-expanded={showDropdown}
className="flex h-[60px] justify-between w-full h-full font-bold font-body items-center sm:py-2px pl-4 text-blue-primary ring-offset-2 focus:ring-2 ring-blue-hover rounded-sm focus:outline-none focus:mb-1"
className="flex justify-between w-full h-full font-bold font-body items-center py-0.5 pl-4 text-blue-primary ring-offset-2 focus:ring-2 ring-blue-hover rounded-sm focus:outline-none focus:mb-1"
>
<span className="flex items-center">
<svg
2 changes: 1 addition & 1 deletion cypress/e2e/PageObjects/termsAndConditionsPO.cy.js
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ function BackToDashboardButton() {
}

function ValidateinformationSection() {
cy.get('[data-cy="terms-conditions"]>div:nth-child(2)').should('be.visible')
cy.get('[data-cy="terms-conditions"]').should('be.visible')
}

module.exports = {
2 changes: 1 addition & 1 deletion graphql/mappers/beta-banner-opt-out.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ export async function getBetaBannerContent() {
const resOptOut = await clientQuery(queryOptOut)
const resDictionary = await clientQuery(queryDictionary)

const resOptOutContent = resOptOut.data.schContentv1ByPath.item || {}
const resOptOutContent = resOptOut.data.schContentV1ByPath.item || {}
const resDictionaryContent = resDictionary.data.dictionaryV1List.items || {}

const mappedBanner = {
2 changes: 1 addition & 1 deletion graphql/mappers/beta-popup-exit.js
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ export async function getBetaPopupExitContent() {
const query = require('../queries/beta-popup-exit.graphql')
const res = await clientQuery(query)

const content = res.data.schContentv1ByPath.item || {}
const content = res.data.schContentV1ByPath.item || {}
const fallbackContent = {
scId: 'beta-popup-exit',
scHeadingEn: 'Exiting beta version',
2 changes: 1 addition & 1 deletion graphql/mappers/beta-popup-page-not-available.js
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ export async function getBetaPopupNotAvailableContent() {
const query = require('../queries/beta-popup-page-not-available.graphql')
const res = await clientQuery(query)

const content = res.data.schContentv1ByPath.item
const content = res.data.schContentV1ByPath.item
const fallbackContent = {
scId: 'beta-popup-page-not-available',
scHeadingEn: 'Exiting beta version',
2 changes: 1 addition & 1 deletion graphql/mappers/contact-us-pages-dynamic.js
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ export async function getContactUsPage(id) {
const query = require('../queries/contact-us-pages-dynamic.graphql')
const response = await clientQuery(query)

const queryData = response.data.schPagev1List.items.find(
const queryData = response.data.schPageV1List.items.find(
(page) => page.scId === id
)

14 changes: 7 additions & 7 deletions graphql/mappers/contact-us.js
Original file line number Diff line number Diff line change
@@ -15,16 +15,16 @@ export async function getContactUsContent() {
const mappedSecurity = {
en: {
breadcrumb:
response.data.schPagev1ByPath.item.scBreadcrumbParentPages.map(
response.data.schPageV1ByPath.item.scBreadcrumbParentPages.map(
(level) => {
return {
link: level.scPageNameEn,
text: level.scTitleEn,
}
}
),
pageName: response.data.schPagev1ByPath.item.scPageNameEn,
heading: response.data.schPagev1ByPath.item.scTitleEn,
pageName: response.data.schPageV1ByPath.item.scPageNameEn,
heading: response.data.schPageV1ByPath.item.scTitleEn,
subHeading: introFragment.scContentEn.json[0].content[0].value,
links: [
{
@@ -61,16 +61,16 @@ export async function getContactUsContent() {
},
fr: {
breadcrumb:
response.data.schPagev1ByPath.item.scBreadcrumbParentPages.map(
response.data.schPageV1ByPath.item.scBreadcrumbParentPages.map(
(level) => {
return {
link: level.scPageNameFr,
text: level.scTitleFr,
}
}
),
pageName: response.data.schPagev1ByPath.item.scPageNameFr,
heading: response.data.schPagev1ByPath.item.scTitleFr,
pageName: response.data.schPageV1ByPath.item.scPageNameFr,
heading: response.data.schPageV1ByPath.item.scTitleFr,
subHeading: introFragment.scContentFr.json[0].content[0].value,
links: [
{
@@ -110,7 +110,7 @@ export async function getContactUsContent() {
}

const findFragmentByScId = (res, id) => {
return res.data.schPagev1ByPath.item.scFragments.find(
return res.data.schPageV1ByPath.item.scFragments.find(
(element) => element.scId === id
)
}
Loading

0 comments on commit e56ada8

Please sign in to comment.