Extracts shared section blocks for use beyond the homepage
HomeSection becomes PageSection, since every page needs the same section frame, and gains a flushTop spacing for a block right below a page head. The framed photo next to text from the homepage About block becomes MediaText, and the accent label that four components wrote out by hand becomes Eyebrow, which can also render as a heading. The homepage renders exactly as before: a layout comparison of every element against master at three widths shows no differences. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { screen } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { ContentImage } from '@/content/types';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import MediaText from './MediaText';
|
||||
|
||||
const image: ContentImage = {
|
||||
src: '/andrea.jpg',
|
||||
alt: 'Andrea met haar camera',
|
||||
width: 1200,
|
||||
height: 800,
|
||||
};
|
||||
|
||||
describe('MediaText', () => {
|
||||
it('shows the photo and the text column', async () => {
|
||||
const { container } = await renderWithProviders(
|
||||
<MediaText image={image} aspectRatio="4 / 3" data-testid="block">
|
||||
<h2>Hoi! Ik ben Andrea</h2>
|
||||
<p>Lifestyle fotograaf uit Huizen.</p>
|
||||
</MediaText>,
|
||||
);
|
||||
expect(screen.getByRole('img')).toHaveAccessibleName(image.alt);
|
||||
expect(
|
||||
screen.getByRole('heading', { name: 'Hoi! Ik ben Andrea' }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText('Lifestyle fotograaf uit Huizen.'),
|
||||
).toBeInTheDocument();
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('puts the photo before the text, also when stacked', async () => {
|
||||
await renderWithProviders(
|
||||
<MediaText image={image} aspectRatio="4 / 3">
|
||||
<h2>Hoi! Ik ben Andrea</h2>
|
||||
</MediaText>,
|
||||
);
|
||||
const photo = screen.getByRole('img');
|
||||
const heading = screen.getByRole('heading');
|
||||
expect(
|
||||
photo.compareDocumentPosition(heading) &
|
||||
Node.DOCUMENT_POSITION_FOLLOWING,
|
||||
).toBeTruthy();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user