import type { GetStaticProps } from 'next'; import Head from 'next/head'; import type { ReactNode } from 'react'; import { useIntl } from 'react-intl'; import { getLayout, Link, LinksListWidget, PageLayout, SearchForm, } from '../components'; import { getThematicsPreview, getTopicsPreview, getTotalThematics, getTotalTopics, } from '../services/graphql'; import type { NextPageWithLayout, RawThematicPreview, RawTopicPreview, } from '../types'; import { ROUTES } from '../utils/constants'; import { getLinksListItems, getPageLinkFromRawData } from '../utils/helpers'; import { loadTranslation, type Messages } from '../utils/helpers/server'; import { useBreadcrumb, useSettings } from '../utils/hooks'; type Error404PageProps = { thematicsList: RawThematicPreview[]; topicsList: RawTopicPreview[]; translation: Messages; }; /** * Error 404 page. */ const Error404Page: NextPageWithLayout = ({ thematicsList, topicsList, }) => { const intl = useIntl(); const { website } = useSettings(); const title = intl.formatMessage({ defaultMessage: 'Page not found', description: 'Error404Page: page title', id: 'KnWeKh', }); const body = intl.formatMessage( { defaultMessage: 'Sorry, it seems that the page your are looking for does not exist. If you think this path should work, feel free to contact me with the necessary information so that I can fix the problem.', id: '9sGNKq', description: 'Error404Page: page body', }, { link: (chunks: ReactNode) => {chunks}, } ); const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({ title, url: ROUTES.NOT_FOUND, }); const pageTitle = intl.formatMessage( { defaultMessage: 'Error 404: Page not found - {websiteName}', description: '404Page: SEO - Page title', id: '310o3F', }, { websiteName: website.name } ); const pageDescription = intl.formatMessage({ defaultMessage: 'Page not found.', description: '404Page: SEO - Meta description', id: '48Ww//', }); const thematicsListTitle = intl.formatMessage({ defaultMessage: 'Thematics', description: 'Error404Page: thematics list widget title', id: 'HohQPh', }); const topicsListTitle = intl.formatMessage({ defaultMessage: 'Topics', description: 'Error404Page: topics list widget title', id: 'GVpTIl', }); return ( <> {pageTitle} {/*eslint-disable-next-line react/jsx-no-literals -- Name allowed */} getPageLinkFromRawData(thematic, 'thematic') ) )} title={thematicsListTitle} level={2} />, getPageLinkFromRawData(topic, 'topic')) )} title={topicsListTitle} level={2} />, ]} > {body}

{intl.formatMessage({ defaultMessage: 'You can also try a search:', description: 'Error404Page: try a search message', id: 'XKy7rx', })}

); }; Error404Page.getLayout = (page) => getLayout(page, { useGrid: true, withExtraPadding: true }); export const getStaticProps: GetStaticProps = async ({ locale, }) => { const totalThematics = await getTotalThematics(); const thematics = await getThematicsPreview({ first: totalThematics }); const totalTopics = await ge
import { describe, expect, it } from '@jest/globals';
import { render, screen as rtlScreen } from '@testing-library/react';
import { PageSidebar } from './page-sidebar';

describe('PageSidebar', () => {
  it('renders its contents', () => {
    const body =
      'Repellendus dignissimos quos dolores sunt pariatur rem optio qui aut. Dolore optio est quam tenetur minus. Dolorem voluptas id maiores rerum velit omnis esse impedit. Unde reiciendis nisi nostrum et. Quia accusamus asperiores. Commodi est provident sequi eaque ipsa ut necessitatibus.';

    render(<PageSidebar>{body}</PageSidebar>);

    expect(rtlScreen.getByText(body)).toBeInTheDocument();
  });
});