Shares the contact form, contact card and privacy line
ContactPanel holds the coming-soon gate, the shoot options, the package chosen via ?pakket= and the form, which loads as its own chunk either when it comes near the screen (homepage) or right away (contact page). ContactDetails shows the ways to reach Andrea as a card with icons. A privacy line now sits under the form and under the coming-soon notice, and the reply time in the thank-you comes from the site content. Instagram is listed before Facebook, so the footer and hero follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
import { screen, within } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import siteContent from '@/content/siteContent';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import ContactDetails from './ContactDetails';
|
||||
|
||||
type Props = Partial<React.ComponentProps<typeof ContactDetails>>;
|
||||
|
||||
const card = (props: Props = {}) => (
|
||||
<ContactDetails
|
||||
titleId="details-title"
|
||||
title="Direct contact"
|
||||
email={siteContent.email}
|
||||
socials={siteContent.socials}
|
||||
data-testid="details"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
const portrait = {
|
||||
src: '/portret.jpg',
|
||||
alt: 'Andrea',
|
||||
width: 144,
|
||||
height: 144,
|
||||
};
|
||||
|
||||
describe('ContactDetails', () => {
|
||||
it('lists e-mail, Instagram and Facebook under a named heading', async () => {
|
||||
const { container } = await renderWithProviders(card());
|
||||
expect(
|
||||
screen.getByRole('heading', { level: 2, name: 'Direct contact' }),
|
||||
).toHaveAttribute('id', 'details-title');
|
||||
const list = screen.getByRole('list', { name: 'Direct contact' });
|
||||
const names = within(list)
|
||||
.getAllByRole('link')
|
||||
.map((link) => link.textContent);
|
||||
expect(names).toEqual([
|
||||
'info@andreaslop.nl',
|
||||
'@andreaslopfotografie (opent in nieuw tabblad)',
|
||||
'Andrea Slop Fotografie (opent in nieuw tabblad)',
|
||||
]);
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('mails with the default subject in the same tab', async () => {
|
||||
await renderWithProviders(card());
|
||||
const mail = screen.getByTestId('contact-details-email');
|
||||
expect(mail).toHaveAttribute(
|
||||
'href',
|
||||
'mailto:info@andreaslop.nl?subject=Vraag%20via%20andreaslop.nl',
|
||||
);
|
||||
expect(mail).not.toHaveAttribute('target');
|
||||
});
|
||||
|
||||
it('opens the socials safely in a new tab and says so', async () => {
|
||||
await renderWithProviders(card());
|
||||
const instagram = screen.getByRole('link', {
|
||||
name: '@andreaslopfotografie (opent in nieuw tabblad)',
|
||||
});
|
||||
expect(instagram).toHaveAttribute('target', '_blank');
|
||||
expect(instagram).toHaveAttribute('rel', 'noopener noreferrer');
|
||||
expect(instagram).toHaveAttribute(
|
||||
'href',
|
||||
'https://www.instagram.com/andreaslopfotografie/',
|
||||
);
|
||||
});
|
||||
|
||||
it('hides the icons from assistive technology', async () => {
|
||||
await renderWithProviders(card());
|
||||
const icons = screen.getByTestId('details').querySelectorAll('svg');
|
||||
expect(icons).toHaveLength(3);
|
||||
icons.forEach((icon) =>
|
||||
expect(icon).toHaveAttribute('aria-hidden', 'true'),
|
||||
);
|
||||
});
|
||||
|
||||
it('renders nothing without a valid channel', async () => {
|
||||
const { container } = await renderWithProviders(
|
||||
card({ email: { user: '', domain: '' }, socials: [] }),
|
||||
);
|
||||
expect(screen.queryByTestId('details')).toBeNull();
|
||||
expect(container.querySelector('h2')).toBeNull();
|
||||
});
|
||||
|
||||
it('shows the portrait as decoration next to the heading', async () => {
|
||||
const { container } = await renderWithProviders(card({ portrait }));
|
||||
const photo = screen.getByTestId('contact-details-portrait');
|
||||
expect(photo).toHaveAttribute('src', '/portret.jpg');
|
||||
expect(photo).toHaveAttribute('alt', '');
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('can appear twice on a page with its own heading ids', async () => {
|
||||
const { container } = await renderWithProviders(
|
||||
<>
|
||||
{card({ titleId: 'details-a', 'data-testid': 'a' })}
|
||||
{card({ titleId: 'details-b', 'data-testid': 'b' })}
|
||||
</>,
|
||||
);
|
||||
expect(
|
||||
screen.getAllByRole('list', { name: 'Direct contact' }),
|
||||
).toHaveLength(2);
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user