Adds the Contact section to the homepage
Adds the contact form with the live fields, validation and browser-side anti-spam, behind a coming-soon notice with a mail button until the API exists. A "Boek" link on a price card selects its package, tidies the URL and moves focus to the form. The form loads only when it comes near the screen, so the hero does not wait for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+23
-1
@@ -4,7 +4,7 @@ import {
|
||||
createRouter,
|
||||
RouterProvider,
|
||||
} from '@tanstack/react-router';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { render, screen, waitFor, within } from '@testing-library/react';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import lighthouseConfig from '../lighthouserc.cjs';
|
||||
import ErrorPage from './components/StatusPage/ErrorPage';
|
||||
@@ -146,6 +146,7 @@ describe('homepage', () => {
|
||||
}),
|
||||
screen.getByRole('region', { name: 'Prijzen' }),
|
||||
screen.getByRole('region', { name: 'Lieve woorden' }),
|
||||
screen.getByRole('region', { name: 'Contact' }),
|
||||
];
|
||||
|
||||
let previous: Element = hero;
|
||||
@@ -162,6 +163,27 @@ describe('homepage', () => {
|
||||
});
|
||||
|
||||
describe('homepage ?pakket=', () => {
|
||||
it('a "Boek Newborn" link selects Newborn, tidies the URL and focuses Contact', async () => {
|
||||
const { router } = await renderApp('/?pakket=newborn#contact');
|
||||
// The form is lazy; arriving via "Boek" loads it straight away
|
||||
expect(
|
||||
await screen.findByTestId('contact-form-shoot', undefined, {
|
||||
timeout: 10_000,
|
||||
}),
|
||||
).toHaveValue('newborn');
|
||||
await waitFor(() => expect(router.state.location.searchStr).toBe(''));
|
||||
expect(router.state.location.hash).toBe('contact');
|
||||
// The form stays once loaded, also now that ?pakket= is gone
|
||||
expect(screen.getByTestId('contact-form-shoot')).toHaveValue('newborn');
|
||||
// within the section: the footer has a "Contact" heading too
|
||||
expect(
|
||||
within(screen.getByRole('region', { name: 'Contact' })).getByRole(
|
||||
'heading',
|
||||
{ level: 2 },
|
||||
),
|
||||
).toHaveFocus();
|
||||
});
|
||||
|
||||
it.each(['/?pakket=newborn', '/?pakket=123', '/?pakket=%3Cscript%3E'])(
|
||||
'%s renders the homepage without errors',
|
||||
async (path) => {
|
||||
|
||||
Reference in New Issue
Block a user