Files
goodgo-platform/apps/web/components/chuyen-nhuong/__tests__/transfer-item-table.spec.tsx
Ho Ngoc Hai f5118244b7 fix(a11y): resolve serious accessibility issues on search page (GOO-110)
- Add aria-hidden="true" to all decorative inline SVGs (bookmark, view-mode, funnel, checkmark)
- Convert save-search popover to proper dialog: role="dialog", aria-modal, focus trap, Escape key, focus return to trigger
- Add aria-pressed on list/map/split view-mode toggle buttons
- Add aria-expanded + aria-controls on mobile filter toggle button
- Add role="status" + aria-label="Đang tải..." on Suspense fallback

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-24 10:26:50 +07:00

65 lines
2.1 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { TransferItemTable } from '../transfer-item-table';
const baseItem = {
id: 'i1',
name: 'Tủ lạnh Toshiba',
brand: 'Toshiba',
modelName: 'GR-RT624WE-PMV',
category: 'APPLIANCE' as const,
condition: 'GOOD' as const,
purchaseYear: 2022,
originalPriceVND: '15000000',
askingPriceVND: '8000000',
aiEstimatePriceVND: '7500000',
aiConfidence: 0.85,
quantity: 1,
};
describe('TransferItemTable', () => {
it('renders empty state when no items', () => {
render(<TransferItemTable items={[]} />);
expect(
screen.getByText('Chưa có danh sách vật phẩm.'),
).toBeInTheDocument();
});
it('renders all column headers', () => {
render(<TransferItemTable items={[baseItem]} />);
expect(screen.getByText('Tên')).toBeInTheDocument();
expect(screen.getByText('Loại')).toBeInTheDocument();
expect(screen.getByText('Tình trạng')).toBeInTheDocument();
expect(screen.getByText('Thương hiệu')).toBeInTheDocument();
expect(screen.getByText('SL')).toBeInTheDocument();
expect(screen.getByText('Giá yêu cầu')).toBeInTheDocument();
expect(screen.getByText('Giá AI')).toBeInTheDocument();
});
it('renders item row with localized currency formatting', () => {
render(<TransferItemTable items={[baseItem]} />);
expect(screen.getByText('Tủ lạnh Toshiba')).toBeInTheDocument();
expect(screen.getByText('GR-RT624WE-PMV')).toBeInTheDocument();
expect(screen.getByText(/8\.000\.000/)).toBeInTheDocument();
expect(screen.getByText(/7\.500\.000/)).toBeInTheDocument();
});
it('falls back to em-dash for missing brand and AI estimate', () => {
render(
<TransferItemTable
items={[
{
...baseItem,
id: 'i2',
brand: null,
aiEstimatePriceVND: null,
aiConfidence: null,
},
]}
/>,
);
const dashes = screen.getAllByText('—');
expect(dashes.length).toBeGreaterThanOrEqual(2);
});
});