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:
59
apps/web/components/ui/__tests__/table.spec.tsx
Normal file
59
apps/web/components/ui/__tests__/table.spec.tsx
Normal file
@@ -0,0 +1,59 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell } from '../table';
|
||||
|
||||
describe('Table', () => {
|
||||
it('renders a complete table structure', () => {
|
||||
render(
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Name</TableHead>
|
||||
<TableHead>Price</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<TableRow>
|
||||
<TableCell>Apartment</TableCell>
|
||||
<TableCell>1,000,000 VND</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>,
|
||||
);
|
||||
|
||||
expect(screen.getByRole('table')).toBeInTheDocument();
|
||||
expect(screen.getByText('Name')).toBeInTheDocument();
|
||||
expect(screen.getByText('Price')).toBeInTheDocument();
|
||||
expect(screen.getByText('Apartment')).toBeInTheDocument();
|
||||
expect(screen.getByText('1,000,000 VND')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders multiple rows', () => {
|
||||
render(
|
||||
<Table>
|
||||
<TableBody>
|
||||
<TableRow><TableCell>Row 1</TableCell></TableRow>
|
||||
<TableRow><TableCell>Row 2</TableCell></TableRow>
|
||||
<TableRow><TableCell>Row 3</TableCell></TableRow>
|
||||
</TableBody>
|
||||
</Table>,
|
||||
);
|
||||
|
||||
expect(screen.getAllByRole('row')).toHaveLength(3);
|
||||
});
|
||||
|
||||
it('applies custom className to table elements', () => {
|
||||
render(
|
||||
<Table>
|
||||
<TableBody>
|
||||
<TableRow data-testid="row" className="highlight">
|
||||
<TableCell data-testid="cell" className="bold">Data</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>,
|
||||
);
|
||||
|
||||
expect(screen.getByTestId('row')).toHaveClass('highlight');
|
||||
expect(screen.getByTestId('cell')).toHaveClass('bold');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user