feat: add MFA/TOTP auth, PII encryption, agents/leads/inquiries modules, and comprehensive tests
- Add TOTP-based MFA with setup, verify, disable, backup codes, and challenge flow - Add PII field encryption middleware with AES-256-GCM and deterministic search hashes - Add agents, inquiries, and leads domain modules with entities, events, value objects - Add web dashboard pages for inquiries and leads with detail dialogs - Add 30+ component tests (valuation, charts, listings, search, providers, UI) - Add Prisma migrations for encryption hash columns and MFA TOTP support - Fix all ESLint errors (unused imports, duplicate imports, lint auto-fixes) - Update dependencies and lock file - Clean up obsolete exploration/QA docs, add audit documentation Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { DistrictBarChart } from '../district-bar-chart';
|
||||
|
||||
// Mock recharts
|
||||
vi.mock('recharts', () => ({
|
||||
ResponsiveContainer: ({ children }: { children: React.ReactNode }) => (
|
||||
<div data-testid="responsive-container">{children}</div>
|
||||
),
|
||||
BarChart: ({ children, data }: { children: React.ReactNode; data: unknown[] }) => (
|
||||
<div data-testid="bar-chart" data-count={data.length}>{children}</div>
|
||||
),
|
||||
Bar: ({ dataKey }: { dataKey: string }) => <div data-testid={`bar-${dataKey}`} />,
|
||||
XAxis: ({ dataKey }: { dataKey: string }) => <div data-testid={`xaxis-${dataKey}`} />,
|
||||
YAxis: () => <div data-testid="yaxis" />,
|
||||
CartesianGrid: () => <div data-testid="grid" />,
|
||||
Tooltip: () => <div data-testid="tooltip" />,
|
||||
}));
|
||||
|
||||
const sampleData = [
|
||||
{ district: 'Quận 1', price: 120, listings: 50 },
|
||||
{ district: 'Quận 2', price: 80, listings: 40 },
|
||||
{ district: 'Quận 7', price: 65, listings: 60 },
|
||||
];
|
||||
|
||||
describe('DistrictBarChart', () => {
|
||||
it('renders responsive container', () => {
|
||||
render(<DistrictBarChart data={sampleData} />);
|
||||
expect(screen.getByTestId('responsive-container')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders bar chart', () => {
|
||||
render(<DistrictBarChart data={sampleData} />);
|
||||
expect(screen.getByTestId('bar-chart')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders bar with default dataKey "price"', () => {
|
||||
render(<DistrictBarChart data={sampleData} />);
|
||||
expect(screen.getByTestId('bar-price')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders bar with custom dataKey', () => {
|
||||
render(<DistrictBarChart data={sampleData} dataKey="listings" />);
|
||||
expect(screen.getByTestId('bar-listings')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders XAxis with district key', () => {
|
||||
render(<DistrictBarChart data={sampleData} />);
|
||||
expect(screen.getByTestId('xaxis-district')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders CartesianGrid', () => {
|
||||
render(<DistrictBarChart data={sampleData} />);
|
||||
expect(screen.getByTestId('grid')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders Tooltip', () => {
|
||||
render(<DistrictBarChart data={sampleData} />);
|
||||
expect(screen.getByTestId('tooltip')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('passes data to chart', () => {
|
||||
render(<DistrictBarChart data={sampleData} />);
|
||||
expect(screen.getByTestId('bar-chart')).toHaveAttribute('data-count', '3');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user