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

Add application name bar to header #308

Merged
merged 4 commits into from
Feb 7, 2023
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
25 changes: 25 additions & 0 deletions __tests__/components/ApplicationNameBar.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import '@testing-library/jest-dom/extend-expect'
import { render, screen } from '@testing-library/react'

import { axe, toHaveNoViolations } from 'jest-axe'

import ApplicationNameBar from '../../components/ApplicationNameBar'

expect.extend(toHaveNoViolations)

describe('ApplicationNameBar', () => {
const sut = <ApplicationNameBar text="Test" href="/somelink" />

it('renders', () => {
render(sut)
const screenText = screen.getByText('Test')
expect(screenText).toBeInTheDocument()
expect(document.querySelector('a')?.getAttribute('href')).toBe('/somelink')
})

it('meets a11y', async () => {
const { container } = render(sut)
const results = await axe(container)
expect(results).toHaveNoViolations()
})
})
24 changes: 24 additions & 0 deletions components/ApplicationNameBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { FC } from 'react'

import Link from 'next/link'

export interface ApplicationNameBarProps {
text: string
href: string
}

const ApplicationNameBar: FC<ApplicationNameBarProps> = ({ text, href }) => {
return (
<div id="app-bar" className="bg-blue-dark">
<section className="container mx-auto p-4">
<Link href={href}>
<a className="font-body md:text-[28px] text-lg font-bold text-white hover:underline">
{text}
</a>
</Link>
</section>
</div>
)
}

export default ApplicationNameBar
9 changes: 6 additions & 3 deletions components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Image from 'next/future/image'
import Link from 'next/link'
import { useRouter } from 'next/router'

import ApplicationNameBar from './ApplicationNameBar'
import Banner from './Banner'

export interface HeaderProps {
Expand Down Expand Up @@ -47,7 +48,7 @@ const Header: FC<HeaderProps> = ({ gocLink, skipToMainText }) => {
description={t('banner.description')}
/>
)}
<div className="container mx-auto flex flex-col justify-between px-4 pt-2.5 md:flex md:flex-row">
<div className="container mx-auto flex flex-col justify-between px-4 py-2.5 md:flex md:flex-row">
<div className="flex flex-row content-center items-center justify-between md:mt-7">
<a href={gocLink}>
<Image
Expand Down Expand Up @@ -92,8 +93,10 @@ const Header: FC<HeaderProps> = ({ gocLink, skipToMainText }) => {
</div>
</div>

{/* Border */}
<div className="mb-2 mt-4 border-t pb-2"></div>
<ApplicationNameBar
text={t('application-name-bar')}
href="/expectations"
/>

{/* <Menu
loginText={t('login')}
Expand Down
2 changes: 1 addition & 1 deletion components/LinkButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const LinkButton: FC<LinkButtonProps> = ({
const styleClasses = styles[style ?? 'default']

return (
<Link href={href} passHref>
<Link href={href}>
<a
target={external ? '_blank' : undefined}
rel={external ? 'noopener noreferrer' : undefined}
Expand Down
9 changes: 9 additions & 0 deletions cypress/e2e/email.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ describe('email page loads', () => {
cy.get('[data-cy=toggle-language-link]').should('contain.text', 'English')
})

it('should have a bar in the header with the application name', () => {
cy.get('#app-bar').should("be.visible")
})

it('should redirect you to the expectations page when clicking the text in the application name bar', () => {
cy.get('#app-bar a').click()
cy.location('pathname').should("equal", "/en/expectations")
})

it('has no detectable a11y violations on load', () => {
cy.injectAxe()
cy.wait(500)
Expand Down
9 changes: 9 additions & 0 deletions cypress/e2e/expectations.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ describe('expectations page loads', () => {
cy.get('#btn-agree').first().click()
cy.location('pathname').should("equal", "/en/landing")
})

it('should have a bar in the header with the application name', () => {
cy.get('#app-bar').should("be.visible")
})

it('should redirect you to the expectations page when clicking the text in the application name bar', () => {
cy.get('#app-bar a').click()
cy.location('pathname').should("equal", "/en/expectations")
})

it('has no detectable a11y violations on load', () => {
cy.injectAxe()
Expand Down
9 changes: 9 additions & 0 deletions cypress/e2e/landing.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ describe('landing page loads', () => {
it('should display the button for has ESRF',()=>{
cy.get(`#with-esrf`).should('be.visible')
})

it('should have a bar in the header with the application name', () => {
cy.get('#app-bar').should("be.visible")
})

it('should redirect you to the expectations page when clicking the text in the application name bar', () => {
cy.get('#app-bar a').click()
cy.location('pathname').should("equal", "/en/expectations")
})

it('has no detectable a11y violations on load', () => {
cy.injectAxe()
Expand Down
9 changes: 9 additions & 0 deletions cypress/e2e/status.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ describe('status page loads', () => {
cy.get('[data-cy=toggle-language-link]').should('contain.text', 'English')
})

it('should have a bar in the header with the application name', () => {
cy.get('#app-bar').should("be.visible")
})

it('should redirect you to the expectations page when clicking the text in the application name bar', () => {
cy.get('#app-bar a').click()
cy.location('pathname').should("equal", "/en/expectations")
})

it('has no detectable a11y violations on load', () => {
cy.injectAxe()
cy.wait(500)
Expand Down
3 changes: 2 additions & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@
"banner": {
"alert": "Test site",
"description": "You cannot check the status of your passport application through this test site. Parts of this site may not work and will change."
}
},
"application-name-bar": "Passport application status checker"
}
3 changes: 2 additions & 1 deletion public/locales/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@
"banner": {
"alert": "Lieu de test",
"description": "Vous ne pouvez pas vérifier l'état de votre demande de passeport via ce site de test. Certaines parties de ce site peuvent ne pas fonctionner et seront modifiées."
}
},
"application-name-bar": "Vérificateur de l'état de la demande de passeport"
}