Adds the shoot page layout and the shoot-type submenu
Shoot pages follow design E: breadcrumb, story blocks, process timeline with icons, photo mosaic, FAQ, package block and booking call to action, with per-shoot OG images. The navigation gets a "Soorten fotoshoots" submenu (desktop panel, mobile group) built from shootTypes, with exact current-page matching in menu, footer and breadcrumb. A 404 under /soorten-fotoshoots/ also offers a link back to the overview. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
import { cleanup, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import fc from 'fast-check';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { FaqItem } from '@/content/types';
|
||||
import { faqItems } from '@/test/arbitraries';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import FaqList from './FaqList';
|
||||
|
||||
const items: FaqItem[] = [
|
||||
{
|
||||
id: 'een',
|
||||
question: 'Wanneer boek ik?',
|
||||
answer: [
|
||||
'Zo vroeg mogelijk, zie ',
|
||||
{ text: 'de prijzen', to: '/', hash: 'prijzen' },
|
||||
'.',
|
||||
],
|
||||
},
|
||||
{ id: 'twee', question: 'Waar?', answer: ['Bij jullie thuis.'] },
|
||||
{ id: 'drie', question: 'Hoe lang?', answer: ['Twee uur.'] },
|
||||
];
|
||||
|
||||
describe('FaqList', () => {
|
||||
it('shows every question closed, with the answers in the page', async () => {
|
||||
const { container } = await renderWithProviders(
|
||||
<FaqList items={items} data-testid="faq" />,
|
||||
);
|
||||
const details = container.querySelectorAll('details');
|
||||
expect(details).toHaveLength(3);
|
||||
for (const item of details) expect(item).not.toHaveAttribute('open');
|
||||
for (const item of items) {
|
||||
expect(screen.getByText(item.question).tagName).toBe('SUMMARY');
|
||||
}
|
||||
expect(
|
||||
screen.getByText('Bij jullie thuis.', { exact: false }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('link', { name: 'de prijzen' }),
|
||||
).toHaveAttribute('href', '/#prijzen');
|
||||
// The questions are labels, not headings
|
||||
expect(screen.queryByRole('heading')).toBeNull();
|
||||
expect(
|
||||
container.querySelectorAll('summary svg[aria-hidden="true"]'),
|
||||
).toHaveLength(3);
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
// jsdom does not turn Enter or Space on a summary into the click that
|
||||
// opens the details (browsers do, for any summary that is the first
|
||||
// child of its details), and user-event only does so for buttons and
|
||||
// links. So the test checks what the page controls: the summary is
|
||||
// focusable and is the first child of its details, and activating it
|
||||
// (the click a browser sends) toggles the item.
|
||||
it('has a focusable summary as first child, which toggles the item when activated', async () => {
|
||||
const user = userEvent.setup();
|
||||
const { container } = await renderWithProviders(
|
||||
<FaqList items={items} />,
|
||||
);
|
||||
const first = container.querySelector('details')!;
|
||||
const summary = first.firstElementChild as HTMLElement;
|
||||
expect(summary.tagName).toBe('SUMMARY');
|
||||
expect(summary).toHaveTextContent('Wanneer boek ik?');
|
||||
expect(summary.getAttribute('tabindex')).not.toBe('-1');
|
||||
await user.tab();
|
||||
expect(summary).toHaveFocus();
|
||||
await user.click(summary);
|
||||
expect(first).toHaveAttribute('open');
|
||||
await user.click(summary);
|
||||
expect(first).not.toHaveAttribute('open');
|
||||
});
|
||||
|
||||
it('renders nothing without questions', async () => {
|
||||
const { container } = await renderWithProviders(<FaqList items={[]} />);
|
||||
expect(container.querySelector('details')).toBeNull();
|
||||
});
|
||||
|
||||
it('has one closed details per item, with every answer in the page (invariant)', async () => {
|
||||
for (const sample of fc.sample(faqItems, { numRuns: 6 })) {
|
||||
const { container } = await renderWithProviders(
|
||||
<FaqList items={sample} />,
|
||||
);
|
||||
const details = container.querySelectorAll('details');
|
||||
expect(details).toHaveLength(sample.length);
|
||||
details.forEach((item, index) => {
|
||||
expect(item.hasAttribute('open')).toBe(false);
|
||||
expect(item.querySelector('summary')!.textContent).toBe(
|
||||
sample[index].question,
|
||||
);
|
||||
const answer = sample[index].answer
|
||||
.map((piece) =>
|
||||
typeof piece === 'string' ? piece : piece.text,
|
||||
)
|
||||
.join('');
|
||||
expect(item.querySelector('p')!.textContent).toBe(answer);
|
||||
});
|
||||
cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user