mirror of
				https://github.com/theoludwig/theoludwig.git
				synced 2025-10-14 20:23:25 +02:00 
			
		
		
		
	test: fix e2e tests + 500 error page
This commit is contained in:
		| @@ -1,8 +1,4 @@ | ||||
| { | ||||
|   "urls": [ | ||||
|     "http://127.0.0.1:3000/", | ||||
|     "http://127.0.0.1:3000/blog", | ||||
|     "http://127.0.0.1:3000/blog/hello-world" | ||||
|   ], | ||||
|   "urls": ["http://127.0.0.1:3000/", "http://127.0.0.1:3000/blog"], | ||||
|   "files": ["./public/curriculum-vitae/index.html"] | ||||
| } | ||||
|   | ||||
| @@ -2,8 +2,6 @@ | ||||
|  | ||||
| import { useEffect } from 'react' | ||||
|  | ||||
| import { ErrorPage } from '@/components/ErrorPage' | ||||
|  | ||||
| export interface ErrorHandlingProps { | ||||
|   error: Error | ||||
| } | ||||
| @@ -15,7 +13,20 @@ const ErrorHandling = (props: ErrorHandlingProps): JSX.Element => { | ||||
|     console.error(error) | ||||
|   }, [error]) | ||||
|  | ||||
|   return <ErrorPage statusCode={500} message='Server error' /> | ||||
|   return ( | ||||
|     <main className='flex flex-col flex-1 items-center justify-center'> | ||||
|       <h1 className='my-6 text-4xl font-semibold'> | ||||
|         Error{' '} | ||||
|         <span | ||||
|           className='text-yellow dark:text-yellow-dark' | ||||
|           data-cy='status-code' | ||||
|         > | ||||
|           500 | ||||
|         </span> | ||||
|       </h1> | ||||
|       <p className='text-center text-lg'>Server error</p> | ||||
|     </main> | ||||
|   ) | ||||
| } | ||||
|  | ||||
| export default ErrorHandling | ||||
|   | ||||
| @@ -1,11 +1,31 @@ | ||||
| import Link from 'next/link' | ||||
|  | ||||
| import { getI18n } from '@/i18n/i18n.server' | ||||
| import { ErrorPage } from '@/components/ErrorPage' | ||||
|  | ||||
| const NotFound = (): JSX.Element => { | ||||
|   const i18n = getI18n() | ||||
|  | ||||
|   return ( | ||||
|     <ErrorPage statusCode={404} message={i18n.translate('errors.not-found')} /> | ||||
|     <main className='flex flex-col flex-1 items-center justify-center'> | ||||
|       <h1 className='my-6 text-4xl font-semibold'> | ||||
|         {i18n.translate('errors.error')}{' '} | ||||
|         <span | ||||
|           className='text-yellow dark:text-yellow-dark' | ||||
|           data-cy='status-code' | ||||
|         > | ||||
|           404 | ||||
|         </span> | ||||
|       </h1> | ||||
|       <p className='text-center text-lg'> | ||||
|         {i18n.translate('errors.not-found')}{' '} | ||||
|         <Link | ||||
|           href='/' | ||||
|           className='text-yellow hover:underline dark:text-yellow-dark' | ||||
|         > | ||||
|           {i18n.translate('errors.return-to-home-page')} | ||||
|         </Link> | ||||
|       </p> | ||||
|     </main> | ||||
|   ) | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,36 +0,0 @@ | ||||
| import Link from 'next/link' | ||||
|  | ||||
| import { getI18n } from '@/i18n/i18n.server' | ||||
|  | ||||
| export interface ErrorPageProps { | ||||
|   statusCode: number | ||||
|   message: string | ||||
| } | ||||
|  | ||||
| export const ErrorPage = (props: ErrorPageProps): JSX.Element => { | ||||
|   const { message, statusCode } = props | ||||
|   const i18n = getI18n() | ||||
|  | ||||
|   return ( | ||||
|     <main className='flex flex-col flex-1 items-center justify-center'> | ||||
|       <h1 className='my-6 text-4xl font-semibold'> | ||||
|         {i18n.translate('errors.error')}{' '} | ||||
|         <span | ||||
|           className='text-yellow dark:text-yellow-dark' | ||||
|           data-cy='status-code' | ||||
|         > | ||||
|           {statusCode} | ||||
|         </span> | ||||
|       </h1> | ||||
|       <p className='text-center text-lg'> | ||||
|         {message}{' '} | ||||
|         <Link | ||||
|           href='/' | ||||
|           className='text-yellow hover:underline dark:text-yellow-dark' | ||||
|         > | ||||
|           {i18n.translate('errors.return-to-home-page')} | ||||
|         </Link> | ||||
|       </p> | ||||
|     </main> | ||||
|   ) | ||||
| } | ||||
| @@ -37,15 +37,17 @@ describe('Common > Header', () => { | ||||
|   }) | ||||
|  | ||||
|   describe('Switch Language', () => { | ||||
|     it('should switch locale from EN (default) to FR', () => { | ||||
|     it('should switch locale from English (default) to French', () => { | ||||
|       cy.get('h1').contains('Théo LUDWIG') | ||||
|       cy.get('[data-cy=locale-flag-text]').contains('EN') | ||||
|       cy.get('[data-cy=locale-flag-text]').contains('English') | ||||
|       cy.get('[data-cy=locales-list]').should('not.be.visible') | ||||
|       cy.get('[data-cy=locale-click]').click() | ||||
|       cy.get('[data-cy=locales-list]').should('be.visible') | ||||
|       cy.get('[data-cy=locales-list] > li:first-child').contains('FR').click() | ||||
|       cy.get('[data-cy=locales-list] > li:first-child') | ||||
|         .contains('French') | ||||
|         .click() | ||||
|       cy.get('[data-cy=locales-list]').should('not.be.visible') | ||||
|       cy.get('[data-cy=locale-flag-text]').contains('FR') | ||||
|       cy.get('[data-cy=locale-flag-text]').contains('French') | ||||
|       cy.get('h1').contains('Théo LUDWIG') | ||||
|     }) | ||||
|  | ||||
|   | ||||
| @@ -1,11 +0,0 @@ | ||||
| describe('Page /500', () => { | ||||
|   beforeEach(() => { | ||||
|     return cy.visit('/500', { failOnStatusCode: false }) | ||||
|   }) | ||||
|  | ||||
|   it('should display the statusCode of 500', () => { | ||||
|     cy.get('[data-cy=status-code]').contains('500') | ||||
|   }) | ||||
| }) | ||||
|  | ||||
| export {} | ||||
		Reference in New Issue
	
	Block a user