aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-12-09 18:13:46 +0100
committerArmand Philippot <git@armandphilippot.com>2023-12-09 18:18:34 +0100
commitcd2cb5748be9e9c479d9802dd3897de1cd1cbd9f (patch)
tree29d0022f7beb1d365354079479f653cd4ff70ba9
parent2cc983064467fdef5630eeabc1a87d454afdb58d (diff)
refactor(pages): refine LegalNotice page
* remove unnecessary dependency (useRouter) * fix React errors (blurWidth/blurHeight) * complete Cypress tests
m---------src/content0
-rw-r--r--src/pages/mentions-legales.tsx14
-rw-r--r--tests/cypress/e2e/pages/legal-notice.cy.ts15
3 files changed, 20 insertions, 9 deletions
diff --git a/src/content b/src/content
-Subproject a7e4d94a2211651ddcf5524a25a93f52678877f
+Subproject 1ec792edf94bc5f69e2b92c6b020804387920d1
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<HTMLDivElement>({ 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 = () => {
/>
<PageSidebar>
<TocWidget
- heading={<Heading level={3}>{tocTitle}</Heading>}
+ heading={<Heading level={2}>{tocTitle}</Heading>}
tree={tree}
/>
</PageSidebar>
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'
+ );
+ });
});