fix(a11y): 无障碍与 lint 修复(对比度/alt 属性/触控目标收窄)+ Geist 本地字体系统

This commit is contained in:
2026-08-31 12:03:32 +08:00
parent 0786af3db9
commit b65ddd1ff7
20 changed files with 125 additions and 76 deletions
+7 -5
View File
@@ -83,16 +83,18 @@ describe('CaseCard', () => {
it('should render background image when provided', async () => {
const { CaseCard } = await import('./case-card');
const { container } = render(<CaseCard {...mockCase} />);
const img = container.querySelector('img[alt=""]');
expect(img).toBeInTheDocument();
expect(img).toHaveAttribute('src', '/images/cases/manufacturing.jpg');
// 组件用 CSS 背景图而非 <img>,使 404 图片静默降级为纯色底
const bg = container.querySelector('[style*="background-image"]');
expect(bg).toBeInTheDocument();
expect(bg).toHaveAttribute('aria-hidden', 'true');
expect(bg).toHaveStyle({ backgroundImage: 'url(/images/cases/manufacturing.jpg)' });
});
it('should not render background image when not provided', async () => {
const { CaseCard } = await import('./case-card');
const { container } = render(<CaseCard {...mockCase} image={undefined} />);
const img = container.querySelector('img[alt=""]');
expect(img).not.toBeInTheDocument();
const bg = container.querySelector('[style*="background-image"]');
expect(bg).not.toBeInTheDocument();
});
it('should use context as fallback when challenge is empty', async () => {
@@ -75,9 +75,11 @@ describe('InsightCard', () => {
const { container } = render(
<InsightCard {...mockInsight} featured image="/images/insights/trends.jpg" />
);
const img = container.querySelector('img');
expect(img).toBeInTheDocument();
expect(img).toHaveAttribute('src', '/images/insights/trends.jpg');
// 组件用 CSS 背景图而非 <img>,使 404 图片静默降级为纯色底
const bg = container.querySelector('[style*="background-image"]');
expect(bg).toBeInTheDocument();
expect(bg).toHaveAttribute('aria-hidden', 'true');
expect(bg).toHaveStyle({ backgroundImage: 'url(/images/insights/trends.jpg)' });
});
it('should render link element when provided', async () => {