import { render, screen } from '@testing-library/react' import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' import { axe } from 'jest-axe' import Progress from '../src/progress/index.jsx' import A11yProgress from '../src/progress/a11y.jsx' describe('Progress (normal tier)', () => { it('renders a native progress element with the base class', () => { render() const el = screen.getByTestId('p') expect(el.tagName).toBe('PROGRESS') expect(el).toHaveClass('abaabil-progress') }) it('defaults max to 100', () => { render() expect(screen.getByTestId('p')).toHaveAttribute('max', '100') }) it('leaves value unset when omitted, which is what makes it indeterminate', () => { render() expect(screen.getByTestId('p')).not.toHaveAttribute('value') }) it('does not default value to 0, which would claim an unknown task is 0% done', () => { render() expect(screen.getByTestId('p').getAttribute('value')).toBeNull() }) it('adds no ARIA attributes and no role at the normal tier', () => { render() const el = screen.getByTestId('p') expect([...el.attributes].map((a) => a.name).filter((a) => a.startsWith('aria-'))).toEqual([]) expect(el).not.toHaveAttribute('role') }) }) describe('Progress (a11y tier)', () => { let warn beforeEach(() => { warn = vi.spyOn(console, 'warn').mockImplementation(() => {}) }) afterEach(() => { warn.mockRestore() }) it('associates a real label via htmlFor/id', () => { render() const el = screen.getByRole('progressbar', { name: 'Uploading' }) expect(screen.getByText('Uploading').tagName).toBe('LABEL') expect(screen.getByText('Uploading')).toHaveAttribute('for', el.id) }) it('names the bar with aria-labelledby, because a