feat(cache): implement Redis caching for search & analytics hot paths
- Add TTL-specific cache durations: district stats (5min), market report (15min), heatmap (5min) - Add Redis caching to GeoSearch handler with 60s TTL - Add cache invalidation on listing.approved, listing.updated, listing.deactivated, listing.sold events - Invalidate search, geo_search, and all analytics cache prefixes on listing state changes - Update tests for new CacheService dependency in event handler and geo-search handler Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
40
apps/web/components/ui/__tests__/select.spec.tsx
Normal file
40
apps/web/components/ui/__tests__/select.spec.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { Select } from '../select';
|
||||
|
||||
describe('Select', () => {
|
||||
it('renders with options', () => {
|
||||
render(
|
||||
<Select aria-label="Property type">
|
||||
<option value="">Chọn loại</option>
|
||||
<option value="APARTMENT">Căn hộ</option>
|
||||
<option value="HOUSE">Nhà phố</option>
|
||||
</Select>,
|
||||
);
|
||||
expect(screen.getByRole('combobox', { name: 'Property type' })).toBeInTheDocument();
|
||||
expect(screen.getAllByRole('option')).toHaveLength(3);
|
||||
});
|
||||
|
||||
it('handles value change', async () => {
|
||||
const onChange = vi.fn();
|
||||
render(
|
||||
<Select aria-label="Type" onChange={onChange}>
|
||||
<option value="">Chọn</option>
|
||||
<option value="SALE">Bán</option>
|
||||
<option value="RENT">Cho thuê</option>
|
||||
</Select>,
|
||||
);
|
||||
await userEvent.selectOptions(screen.getByRole('combobox'), 'SALE');
|
||||
expect(onChange).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('is disabled when disabled prop is set', () => {
|
||||
render(
|
||||
<Select disabled aria-label="Disabled select">
|
||||
<option>Option</option>
|
||||
</Select>,
|
||||
);
|
||||
expect(screen.getByRole('combobox')).toBeDisabled();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user