Fixes the scroll to Contact from the price cards
Removing ?pakket= from the URL replaced the click's navigation before the router scrolled to #contact, and told it not to scroll, so nothing happened. The clean-up now asks the router to scroll there, below the fixed header. The review carousel's placeholder is now the longest review itself, so it matches the carousel's height at every width and no longer shifts the target while the page scrolls past it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
RouterProvider,
|
||||
} from '@tanstack/react-router';
|
||||
import { render, screen, waitFor, within } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import lighthouseConfig from '../lighthouserc.cjs';
|
||||
import ErrorPage from './components/StatusPage/ErrorPage';
|
||||
@@ -163,6 +164,27 @@ describe('homepage', () => {
|
||||
});
|
||||
|
||||
describe('homepage ?pakket=', () => {
|
||||
it('a click on "Boek Newborn" scrolls to Contact and selects Newborn', async () => {
|
||||
const scrolls = vi.spyOn(Element.prototype, 'scrollIntoView');
|
||||
const user = userEvent.setup();
|
||||
await renderApp('/');
|
||||
await user.click(
|
||||
await screen.findByRole('link', { name: 'Boek Newborn' }),
|
||||
);
|
||||
expect(
|
||||
await screen.findByTestId('contact-form-shoot', undefined, {
|
||||
timeout: 10_000,
|
||||
}),
|
||||
).toHaveValue('newborn');
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
scrolls.mock.contexts.some(
|
||||
(element) => (element as Element).id === 'contact',
|
||||
),
|
||||
).toBe(true),
|
||||
);
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user