Files
carmanagement/apps/homepage/tests/unit/components/controls.test.tsx
T
root d7fb7b7a7b
Build & Deploy / Build & Push Docker Image (push) Failing after 47s
Build & Deploy / Deploy to VPS (push) Has been skipped
Test / API Unit Tests (push) Failing after 5m4s
Test / Marketplace Unit Tests (push) Failing after 4m55s
Test / Admin Unit Tests (push) Successful in 9m37s
Test / Dashboard Unit Tests (push) Successful in 9m37s
Test / API Integration Tests (push) Successful in 9m54s
redesign the homepage
2026-06-26 16:27:21 -04:00

32 lines
1.3 KiB
TypeScript

import { Accordion } from '@/components/controls/Accordion';
import { Tabs } from '@/components/controls/Tabs';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { describe, expect, it } from 'vitest';
describe('selection and disclosure controls', () => {
it('moves tab focus and selection with arrow keys', async () => {
const user = userEvent.setup();
render(
<Tabs
label="Views"
items={[
{ id: 'one', label: 'One', content: 'Panel one' },
{ id: 'two', label: 'Two', content: 'Panel two' },
]}
/>,
);
const first = screen.getByRole('tab', { name: 'One' });
await user.click(first);
await user.keyboard('{ArrowRight}');
expect(screen.getByRole('tab', { name: 'Two' })).toHaveAttribute('aria-selected', 'true');
expect(screen.getByRole('tabpanel', { name: 'Two' })).toHaveTextContent('Panel two');
});
it('uses native disclosure semantics for accordion items', () => {
render(<Accordion items={[{ id: 'faq', title: 'Question', content: 'Answer' }]} />);
expect(screen.getByText('Question').closest('summary')).toBeInTheDocument();
expect(screen.getByText('Answer').closest('details')).not.toHaveAttribute('open');
});
});