From cd2cb5748be9e9c479d9802dd3897de1cd1cbd9f Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Sat, 9 Dec 2023 18:13:46 +0100 Subject: refactor(pages): refine LegalNotice page * remove unnecessary dependency (useRouter) * fix React errors (blurWidth/blurHeight) * complete Cypress tests --- src/content | 2 +- src/pages/mentions-legales.tsx | 14 ++++++-------- tests/cypress/e2e/pages/legal-notice.cy.ts | 15 ++++++++++++++- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/content b/src/content index a7e4d94..1ec792e 160000 --- a/src/content +++ b/src/content @@ -1 +1 @@ -Subproject commit a7e4d94a2211651ddcf5524a25a93f52678877fc +Subproject commit 1ec792edf94bc5f69e2b92c6b020804387920d18 diff --git a/src/pages/mentions-legales.tsx b/src/pages/mentions-legales.tsx index 7d46680..176c8fe 100644 --- a/src/pages/mentions-legales.tsx +++ b/src/pages/mentions-legales.tsx @@ -1,7 +1,5 @@ -/* eslint-disable max-statements */ import type { GetStaticProps } from 'next'; import Head from 'next/head'; -import { useRouter } from 'next/router'; import Script from 'next/script'; import { useIntl } from 'react-intl'; import { @@ -36,13 +34,12 @@ const LegalNoticePage: NextPageWithLayout = () => { title, url: ROUTES.LEGAL_NOTICE, }); - const { ref, tree } = useHeadingsTree({ fromLevel: 2 }); - const { asPath } = useRouter(); + const webpageSchema = getWebPageSchema({ description: seo.description, locale: CONFIG.locales.defaultLocale, - slug: asPath, + slug: ROUTES.LEGAL_NOTICE, title: seo.title, updateDate: dates.update, }); @@ -52,13 +49,14 @@ const LegalNoticePage: NextPageWithLayout = () => { id: 'legal-notice', kind: 'page', locale: CONFIG.locales.defaultLocale, - slug: asPath, + slug: ROUTES.LEGAL_NOTICE, title, }); const schemaJsonLd = getSchemaJson([webpageSchema, articleSchema]); + const page = { title: `${seo.title} - ${CONFIG.name}`, - url: `${CONFIG.url}${asPath}`, + url: `${CONFIG.url}${ROUTES.LEGAL_NOTICE}`, }; const tocTitle = intl.formatMessage({ defaultMessage: 'Table of Contents', @@ -100,7 +98,7 @@ const LegalNoticePage: NextPageWithLayout = () => { /> {tocTitle}} + heading={{tocTitle}} tree={tree} /> diff --git a/tests/cypress/e2e/pages/legal-notice.cy.ts b/tests/cypress/e2e/pages/legal-notice.cy.ts index 0f2fb8c..2e4f045 100644 --- a/tests/cypress/e2e/pages/legal-notice.cy.ts +++ b/tests/cypress/e2e/pages/legal-notice.cy.ts @@ -1,8 +1,21 @@ import { ROUTES } from '../../../../src/utils/constants'; describe('Legal Notice Page', () => { - it('successfully loads', () => { + beforeEach(() => { cy.visit(ROUTES.LEGAL_NOTICE); + }); + + it('successfully loads', () => { cy.findByRole('heading', { level: 1 }).contains('Mentions légales'); }); + + it('contains a breadcrumbs', () => { + cy.findByRole('navigation', { name: 'Fil d’Ariane' }).should('exist'); + }); + + it('contains a table of contents', () => { + cy.findByRole('heading', { level: 2, name: 'Table des matières' }).should( + 'exist' + ); + }); }); -- cgit v1.2.3