Replaces the placeholder with the page from the design and the texts from the live site: Andrea's introduction with her portrait, how it started, two photos, life outside photography and a booking button. The page is now indexed, with its own title, description, preview image and AboutPage data about Andrea. The portrait loads straight away instead of after the page, since on phones it is the largest paint. Lighthouse no longer lets every indexed page use the homepage's lower mobile performance target; it now only applies to the homepage itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
3.1 KiB
TypeScript
85 lines
3.1 KiB
TypeScript
import { screen } from '@testing-library/react';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { axeResults } from '@/test/axe';
|
|
import { renderWithProviders } from '@/test/renderWithProviders';
|
|
import PageSection from './PageSection';
|
|
|
|
describe('PageSection', () => {
|
|
it('is a region named by its heading', async () => {
|
|
const { container } = await renderWithProviders(
|
|
<PageSection labelledBy="about-title" data-testid="about">
|
|
<h2 id="about-title">Over mij</h2>
|
|
</PageSection>,
|
|
);
|
|
expect(screen.getByRole('region', { name: 'Over mij' })).toBe(
|
|
screen.getByTestId('about'),
|
|
);
|
|
expect(await axeResults(container)).toHaveNoViolations();
|
|
});
|
|
|
|
it('passes the anchor id through for every tone, width and spacing', async () => {
|
|
await renderWithProviders(
|
|
<PageSection
|
|
labelledBy="contact-title"
|
|
id="contact"
|
|
tone="alt"
|
|
width="narrow"
|
|
spacing="tight"
|
|
>
|
|
<h2 id="contact-title">Contact</h2>
|
|
</PageSection>,
|
|
);
|
|
expect(screen.getByRole('region', { name: 'Contact' })).toHaveAttribute(
|
|
'id',
|
|
'contact',
|
|
);
|
|
});
|
|
|
|
it('has no space above when it sits flush below a page head', async () => {
|
|
await renderWithProviders(
|
|
<>
|
|
<PageSection labelledBy="flush-title" data-testid="flush">
|
|
<h2 id="flush-title">Hoi!</h2>
|
|
</PageSection>
|
|
<PageSection
|
|
labelledBy="next-title"
|
|
spacing="flushTop"
|
|
data-testid="flush-top"
|
|
>
|
|
<h2 id="next-title">Verder</h2>
|
|
</PageSection>
|
|
</>,
|
|
);
|
|
const regular = getComputedStyle(screen.getByTestId('flush'));
|
|
const flush = getComputedStyle(screen.getByTestId('flush-top'));
|
|
expect(flush.paddingTop).toBe('0px');
|
|
expect(flush.paddingBottom).toBe(regular.paddingBottom);
|
|
expect(regular.paddingTop).not.toBe('0px');
|
|
});
|
|
|
|
it('is no landmark without a heading to name it', async () => {
|
|
const { container } = await renderWithProviders(
|
|
<PageSection data-testid="photos">
|
|
<p>Foto's</p>
|
|
</PageSection>,
|
|
);
|
|
expect(screen.getByTestId('photos').tagName).toBe('SECTION');
|
|
expect(screen.queryByRole('region')).not.toBeInTheDocument();
|
|
expect(await axeResults(container)).toHaveNoViolations();
|
|
});
|
|
|
|
it('leaves out the content column at full width', async () => {
|
|
await renderWithProviders(
|
|
<PageSection labelledBy="insta-title" width="full">
|
|
<h2 id="insta-title" data-testid="child">
|
|
Instagram
|
|
</h2>
|
|
</PageSection>,
|
|
);
|
|
// The heading is a direct child of the section, not of a Container
|
|
expect(screen.getByTestId('child').parentElement).toBe(
|
|
screen.getByRole('region', { name: 'Instagram' }),
|
|
);
|
|
});
|
|
});
|