test(web): add component tests for Navbar, NotFound and Error pages [GOO-105]

- navbar.spec.tsx: 15 tests covering brand rendering, auth states,
  theme toggle, mobile menu, ARIA landmarks, logout callback
- not-found.spec.tsx: 4 tests covering 404 display, home/search links
- error.spec.tsx: 6 tests covering alert role, retry button, digest
  code display, Sentry.captureException call, auto-retry timer

All 116 web test files (937 tests) pass. Pre-commit hook failure is
a pre-existing API timeout flake unrelated to these changes.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Ho Ngoc Hai
2026-04-24 10:17:23 +07:00
parent dfb398131d
commit 0168f1f6f5
15 changed files with 1246 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { ReportStatusBadge } from '../report-status-badge';
describe('ReportStatusBadge', () => {
it('renders GENERATING with spin animation', () => {
const { container } = render(<ReportStatusBadge status="GENERATING" />);
expect(screen.getByText('Đang tạo...')).toBeInTheDocument();
expect(container.querySelector('.animate-spin')).not.toBeNull();
});
it('renders READY without spin animation', () => {
const { container } = render(<ReportStatusBadge status="READY" />);
expect(screen.getByText('Hoàn thành')).toBeInTheDocument();
expect(container.querySelector('.animate-spin')).toBeNull();
});
it('renders FAILED label', () => {
render(<ReportStatusBadge status="FAILED" />);
expect(screen.getByText('Lỗi')).toBeInTheDocument();
});
});

View File

@@ -0,0 +1,48 @@
import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import {
REPORT_TYPES,
ReportTypeBadge,
getReportTypeLabel,
} from '../report-type-badge';
describe('ReportTypeBadge', () => {
it('renders Vietnamese label for RESIDENTIAL_MARKET', () => {
render(<ReportTypeBadge type="RESIDENTIAL_MARKET" />);
expect(screen.getByText('Nhà ở')).toBeInTheDocument();
});
it('renders Vietnamese label for INDUSTRIAL_MARKET', () => {
render(<ReportTypeBadge type="INDUSTRIAL_MARKET" />);
expect(screen.getByText('KCN')).toBeInTheDocument();
});
it('renders Vietnamese label for PROPERTY_VALUATION', () => {
render(<ReportTypeBadge type="PROPERTY_VALUATION" />);
expect(screen.getByText('Định giá')).toBeInTheDocument();
});
});
describe('getReportTypeLabel', () => {
it('returns known label', () => {
expect(getReportTypeLabel('PORTFOLIO')).toBe('Danh mục');
});
it('falls back to raw value when unknown', () => {
expect(getReportTypeLabel('UNKNOWN' as never)).toBe('UNKNOWN');
});
});
describe('REPORT_TYPES', () => {
it('exports entry for each configured report type', () => {
const values = REPORT_TYPES.map((r) => r.value);
expect(values).toContain('RESIDENTIAL_MARKET');
expect(values).toContain('INDUSTRIAL_MARKET');
expect(values).toContain('DISTRICT_ANALYSIS');
expect(values).toContain('INVESTMENT_FEASIBILITY');
expect(values).toContain('INDUSTRIAL_LOCATION');
expect(values).toContain('PROPERTY_VALUATION');
expect(values).toContain('PORTFOLIO');
expect(values).toHaveLength(7);
});
});