test: comprehensive test suites and quality gates pass across backend, storefront and admin
- Backend (NestJS): 82 suites, 641 tests passing; 0 ESLint errors; 0 tsc errors. Hardened SSL cert/key matching, SSRF IP pinning, and eBank validation. - Admin Panel (Vite/React): 48 suites, 300 tests passing; 0 ESLint errors; 0 tsc errors. Full coverage across all pages and settings. - Storefront (Next.js): 62 suites, 368 tests passing; 0 ESLint errors; 0 tsc errors. - Fixed unmount lifecycle guards, promise error handling, and component edge cases.
This commit is contained in:
1 parent
1e73715169
commit
ddbf1ca026
439 files changed
+32911
-6107
No files matched your search
@@ -0,0 +1,80 @@
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import SearchableSelect from '../SearchableSelect';
|
||||
|
||||
describe('SearchableSelect Component', () => {
|
||||
const options = ['تهران', 'اصفهان', 'شیراز', 'مشهد', 'تبریز'];
|
||||
|
||||
it('renders placeholder and toggles dropdown on click', () => {
|
||||
render(
|
||||
<SearchableSelect
|
||||
options={options}
|
||||
value=""
|
||||
onChange={vi.fn()}
|
||||
placeholder="انتخاب استان"
|
||||
/>,
|
||||
);
|
||||
|
||||
const button = screen.getByText('انتخاب استان');
|
||||
expect(button).toBeInTheDocument();
|
||||
|
||||
// Click to open
|
||||
fireEvent.click(button);
|
||||
expect(screen.getByPlaceholderText('جستجو...')).toBeInTheDocument();
|
||||
expect(screen.getByText('تهران')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('filters options based on search query', () => {
|
||||
render(
|
||||
<SearchableSelect
|
||||
options={options}
|
||||
value=""
|
||||
onChange={vi.fn()}
|
||||
placeholder="انتخاب استان"
|
||||
/>,
|
||||
);
|
||||
|
||||
fireEvent.click(screen.getByText('انتخاب استان'));
|
||||
const searchInput = screen.getByPlaceholderText('جستجو...');
|
||||
|
||||
fireEvent.change(searchInput, { target: { value: 'شیراز' } });
|
||||
expect(screen.getByText('شیراز')).toBeInTheDocument();
|
||||
expect(screen.queryByText('تهران')).toBeNull();
|
||||
});
|
||||
|
||||
it('selects option, calls onChange and closes dropdown', () => {
|
||||
const handleChange = vi.fn();
|
||||
render(
|
||||
<SearchableSelect
|
||||
options={options}
|
||||
value=""
|
||||
onChange={handleChange}
|
||||
placeholder="انتخاب استان"
|
||||
/>,
|
||||
);
|
||||
|
||||
fireEvent.click(screen.getByText('انتخاب استان'));
|
||||
fireEvent.click(screen.getByText('اصفهان'));
|
||||
|
||||
expect(handleChange).toHaveBeenCalledWith('اصفهان');
|
||||
// Dropdown should be closed, search input gone
|
||||
expect(screen.queryByPlaceholderText('جستجو...')).toBeNull();
|
||||
});
|
||||
|
||||
it('displays empty state message when search has no matches', () => {
|
||||
render(
|
||||
<SearchableSelect
|
||||
options={options}
|
||||
value=""
|
||||
onChange={vi.fn()}
|
||||
placeholder="انتخاب استان"
|
||||
/>,
|
||||
);
|
||||
|
||||
fireEvent.click(screen.getByText('انتخاب استان'));
|
||||
const searchInput = screen.getByPlaceholderText('جستجو...');
|
||||
|
||||
fireEvent.change(searchInput, { target: { value: 'بوشهر' } });
|
||||
expect(screen.getByText('موردی یافت نشد')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user