feat(stepper): implement multi-step wizard for appointment confirmation process

This commit is contained in:
hamed
2026-08-09 09:12:00 +03:30
parent 948f59827a
commit 3ffab2bbd0
7 changed files with 544 additions and 81 deletions
@@ -0,0 +1,42 @@
import { describe, it, expect } from 'vitest';
import { render, screen } from '@testing-library/react';
import Stepper from './Stepper';
const STEPS = [
{ key: 'cost', title: 'بیمه و هزینه' },
{ key: 'payment', title: 'پرداخت' },
{ key: 'review', title: 'تأیید' },
];
const items = () => screen.getAllByRole('listitem');
describe('Stepper', () => {
it('همهٔ مراحل را با شمارهٔ خودشان نشان می‌دهد', () => {
render(<Stepper steps={STEPS} current="payment" ariaLabel="مراحل" />);
expect(items()).toHaveLength(3);
expect(items()[0].textContent).toBe('1بیمه و هزینه');
expect(items()[2].textContent).toBe('3تأیید');
});
it('مرحلهٔ جاری با aria-current اعلام می‌شود', () => {
render(<Stepper steps={STEPS} current="payment" ariaLabel="مراحل" />);
// فقط یکی؛ وگرنه صفحه‌خوان دو «مرحلهٔ فعلی» می‌خواند.
const marked = items().filter(li => li.getAttribute('aria-current') === 'step');
expect(marked).toHaveLength(1);
expect(marked[0].textContent).toBe('2پرداخت');
});
it('نوار با برچسبِ داده‌شده قابل پیدا شدن است', () => {
render(<Stepper steps={STEPS} current="cost" ariaLabel="مراحل قطعی کردن نوبت" />);
expect(screen.getByRole('list', { name: 'مراحل قطعی کردن نوبت' })).toBeInTheDocument();
});
it('مرحلهٔ ناشناخته هیچ‌کدام را فعال نمی‌کند و خطا نمی‌دهد', () => {
render(<Stepper steps={STEPS} current="unknown" ariaLabel="مراحل" />);
expect(items().filter(li => li.getAttribute('aria-current') === 'step')).toHaveLength(0);
});
});