Fix test suite teardown and gate CI on tests plus header WCAG audit.

Repair Navigation and HeroSection assertions, stop deleting window.location in jsdom setup, and add validate/a11y-live GitHub workflows with type-check and test:ci scripts.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
defiQUG
2026-06-15 19:29:33 -07:00
co-authored by Cursor
parent 5c465d176e
commit d00ab4cbaf
8 changed files with 177 additions and 107 deletions
+8 -4
View File
@@ -1,6 +1,6 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { render } from '@testing-library/react'
import { screen, fireEvent } from '@testing-library/dom'
import { screen, fireEvent, within } from '@testing-library/dom'
import '@testing-library/jest-dom'
import { Navigation } from '../Navigation'
@@ -57,8 +57,12 @@ describe('Navigation Component', () => {
it('displays mobile menu when mobileMenuOpen is true', () => {
render(<Navigation {...mockProps} mobileMenuOpen={true} />)
expect(screen.getAllByText('Stories').length).toBeGreaterThanOrEqual(1)
expect(screen.getByText('Events')).toBeInTheDocument()
expect(screen.getByText('Contact')).toBeInTheDocument()
const mobileMenu = document.getElementById('mobile-menu')
expect(mobileMenu).toBeTruthy()
const menu = within(mobileMenu!)
expect(menu.getByText('Stories')).toBeInTheDocument()
expect(menu.getByText('Events')).toBeInTheDocument()
expect(menu.getByText('Contact')).toBeInTheDocument()
})
})
@@ -37,10 +37,10 @@ describe('HeroSection Component', () => {
it('renders call-to-action buttons', () => {
render(<HeroSection />)
const donateButton = screen.getByRole('link', { name: /Donate Now/ })
const helpButton = screen.getByRole('link', { name: /Get Help/ })
const donateButton = screen.getByRole('link', { name: /Donate now to Miracles in Motion/i })
const helpButton = screen.getByRole('link', { name: /Get help — request assistance/i })
expect(donateButton).toHaveAttribute('href', '#/donate')
expect(helpButton).toHaveAttribute('href', '#/request-assistance')
})
+8 -22
View File
@@ -33,7 +33,8 @@ global.ResizeObserver = MockResizeObserver
// Mock matchMedia
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: vi.fn().mockImplementation(query => ({
configurable: true,
value: vi.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
@@ -53,26 +54,11 @@ const localStorageMock = {
clear: vi.fn(),
}
Object.defineProperty(window, 'localStorage', {
value: localStorageMock
configurable: true,
value: localStorageMock,
})
// Mock window.location
delete (window as any).location
Object.defineProperty(window, 'location', {
writable: true,
value: {
...window.location,
hash: '#/',
pathname: '/',
get search() {
return '';
},
get href() {
return 'http://localhost:3000/';
},
assign: vi.fn(),
replace: vi.fn(),
reload: vi.fn(),
},
});
// Hash-router default — avoid deleting window.location (breaks Vitest jsdom teardown)
if (window.location.hash !== '#/') {
window.history.replaceState({}, '', '/#/')
}