feat: add accessible Skip to Content link

- Add SkipLink component with off-screen styling
- Add translation keys for skip link text
- Integrate SkipLink in App.tsx and wrap content in #main-content
- Add unit tests for SkipLink

Co-authored-by: ragusa-it <196988693+ragusa-it@users.noreply.github.com>
This commit is contained in:
google-labs-jules[bot]
2026-02-07 01:53:13 +00:00
parent 2587b9dd29
commit 7018459185
7 changed files with 82 additions and 8 deletions

View File

@@ -0,0 +1,34 @@
// @vitest-environment jsdom
import { render, screen, cleanup } from '@testing-library/react';
import { describe, it, expect, afterEach, vi } from 'vitest';
import { SkipLink } from '../SkipLink';
// Mock i18n
vi.mock('../../../i18n', () => ({
useTranslation: () => ({
t: {
nav: {
skipToContent: 'Skip to content',
},
},
}),
}));
describe('SkipLink', () => {
afterEach(() => {
cleanup();
});
it('renders a link with correct href and text', () => {
render(<SkipLink />);
const link = screen.getByRole('link', { name: /skip to content/i });
expect(link).toBeTruthy();
expect(link.getAttribute('href')).toBe('#main-content');
});
it('has class attribute for styling', () => {
render(<SkipLink />);
const link = screen.getByRole('link');
expect(link.getAttribute('class')).toBeTruthy();
});
});