diff --git a/__tests__/ContractCardAccessibility.test.tsx b/__tests__/ContractCardAccessibility.test.tsx new file mode 100644 index 0000000..475861f --- /dev/null +++ b/__tests__/ContractCardAccessibility.test.tsx @@ -0,0 +1,87 @@ +import React from 'react' +import { render, screen, fireEvent } from '@testing-library/react' +import '@testing-library/jest-dom' +import ContractCard from '../components/ContractCard' +import { WatchedContract } from '@/types' + +const mockContract: WatchedContract = { + id: 'test-contract-1', + label: 'Test Escrow Contract', + contract_id: 'CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7', + network: 'testnet', + rules: [ + { type: 'AnyTransaction' }, + ], + webhook_url: 'https://example.com/webhook', + created_at: 1700000000000, + updated_at: 1700000000000, + enabled: true, +} + +describe('ContractCard Accessibility in Selection Mode (Issue #217)', () => { + it('renders a label element instead of a div role="button" when selectable', () => { + const onToggleSelect = jest.fn() + const { container } = render( + + ) + + // Ensure there is no div with role="button" nesting the checkbox + expect(screen.queryByRole('button', { name: /select/i })).not.toBeInTheDocument() + expect(container.querySelector('[role="button"]')).toBeNull() + + // The root element must be a