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__/card.spec.tsx
Normal file
40
apps/web/components/ui/__tests__/card.spec.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '../card';
|
||||
|
||||
describe('Card', () => {
|
||||
it('renders card with all sub-components', () => {
|
||||
render(
|
||||
<Card data-testid="card">
|
||||
<CardHeader>
|
||||
<CardTitle>Title</CardTitle>
|
||||
<CardDescription>Description</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>Content</CardContent>
|
||||
<CardFooter>Footer</CardFooter>
|
||||
</Card>,
|
||||
);
|
||||
|
||||
expect(screen.getByTestId('card')).toBeInTheDocument();
|
||||
expect(screen.getByText('Title')).toBeInTheDocument();
|
||||
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Content')).toBeInTheDocument();
|
||||
expect(screen.getByText('Footer')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('applies custom className to Card', () => {
|
||||
render(<Card data-testid="card" className="custom">Content</Card>);
|
||||
expect(screen.getByTestId('card')).toHaveClass('custom');
|
||||
expect(screen.getByTestId('card')).toHaveClass('rounded-lg');
|
||||
});
|
||||
|
||||
it('renders CardTitle as h3', () => {
|
||||
render(<CardTitle>My Title</CardTitle>);
|
||||
expect(screen.getByRole('heading', { level: 3 })).toHaveTextContent('My Title');
|
||||
});
|
||||
|
||||
it('renders CardDescription as paragraph', () => {
|
||||
render(<CardDescription>My Description</CardDescription>);
|
||||
expect(screen.getByText('My Description').tagName).toBe('P');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user