fix(a11y): close cross-app interaction gaps
CI and Deploy / test (pull_request) Successful in 4m54s
CI and Deploy / deploy (pull_request) Has been skipped

This commit is contained in:
cesnimda
2026-08-15 17:49:42 +02:00
parent deed948183
commit a7c25499bb
23 changed files with 224 additions and 61 deletions
+9 -2
View File
@@ -1,6 +1,6 @@
import React from 'react';
import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';
import { render, screen, waitFor } from '@testing-library/react';
import { MemoryRouter, Route, Routes } from 'react-router-dom';
import { api } from './api';
@@ -16,6 +16,8 @@ jest.mock('./api', () => ({
const mockedApi = api as jest.Mocked<typeof api>;
test('public CV exposes the rendered CV and PDF download', async () => {
const originalInnerWidth = window.innerWidth;
Object.defineProperty(window, 'innerWidth', { configurable: true, value: 375 });
mockedApi.get.mockResolvedValueOnce({ data: { html: '<p>Public CV</p>', name: 'Ada Lovelace' } } as any);
render(
@@ -24,7 +26,12 @@ test('public CV exposes the rendered CV and PDF download', async () => {
</MemoryRouter>,
);
expect(await screen.findByTitle('Public CV')).toHaveAttribute('srcdoc', '<p>Public CV</p>');
const frame = await screen.findByTitle('Public CV');
expect(frame).toHaveAttribute('srcdoc', '<p>Public CV</p>');
expect(Number.parseFloat(frame.style.width)).toBeGreaterThan(790);
await waitFor(() => expect(frame.style.transform).not.toBe('scale(1)'));
expect(Number.parseFloat(screen.getByTestId('public-cv-frame-container').style.width)).toBeLessThanOrEqual(343);
expect(screen.getByRole('link', { name: 'Download PDF' })).toHaveAttribute('href', '/api/public-cv/public-slug/pdf');
expect(mockedApi.get).toHaveBeenCalledWith('/public-cv/public-slug');
Object.defineProperty(window, 'innerWidth', { configurable: true, value: originalInnerWidth });
});