chore: remove GitHub Actions workflows, use Woodpecker CI exclusively

This commit is contained in:
张翔
2026-03-10 13:10:11 +08:00
parent 0a1adfc2a2
commit e8dffa4f05
82 changed files with 19565 additions and 101 deletions
+199
View File
@@ -0,0 +1,199 @@
import { describe, it, expect, jest, beforeEach, afterEach } from '@jest/globals';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import '@testing-library/jest-dom';
const mockPush = jest.fn();
const mockReplace = jest.fn();
jest.mock('next/navigation', () => ({
usePathname: jest.fn(() => '/'),
useSearchParams: jest.fn(() => new URLSearchParams()),
useRouter: jest.fn(() => ({
push: mockPush,
replace: mockReplace,
})),
}));
jest.mock('next/link', () => {
return ({ children, href, onClick, ...props }: any) => (
<a href={href} onClick={onClick} {...props}>
{children}
</a>
);
});
jest.mock('next/image', () => {
return ({ src, alt, width, height, className, ...props }: any) => (
<img src={src} alt={alt} width={width} height={height} className={className} {...props} />
);
});
jest.mock('framer-motion', () => ({
motion: {
div: ({ children, className, ...props }: any) => (
<div className={className} {...props}>
{children}
</div>
),
},
AnimatePresence: ({ children }: any) => <>{children}</>,
}));
jest.mock('lucide-react', () => ({
Menu: () => <span data-testid="menu-icon" />,
X: () => <span data-testid="x-icon" />,
}));
jest.mock('@/components/ui/button', () => ({
Button: ({ children, className, asChild, ...props }: any) => (
<button className={className} {...props}>
{children}
</button>
),
}));
jest.mock('@/lib/constants', () => ({
COMPANY_INFO: {
name: '四川睿新致远科技有限公司',
shortName: '睿新致遠',
},
NAVIGATION: [
{ id: 'home', label: '首页', href: '/' },
{ id: 'services', label: '服务', href: '/#services' },
{ id: 'products', label: '产品', href: '/#products' },
{ id: 'cases', label: '案例', href: '/#cases' },
{ id: 'about', label: '关于', href: '/#about' },
{ id: 'contact', label: '联系', href: '/contact' },
],
}));
jest.mock('@/hooks/use-focus-trap', () => ({
useFocusTrap: () => ({ current: null }),
}));
import { Header } from './header';
describe('Header', () => {
beforeEach(() => {
jest.clearAllMocks();
});
afterEach(() => {
jest.clearAllMocks();
});
describe('Rendering', () => {
it('should render header component', () => {
render(<Header />);
expect(screen.getByRole('banner')).toBeInTheDocument();
});
it('should render logo', () => {
render(<Header />);
const logo = screen.getByAltText('四川睿新致远科技有限公司');
expect(logo).toBeInTheDocument();
});
it('should render desktop navigation', () => {
render(<Header />);
expect(screen.getByTestId('desktop-navigation')).toBeInTheDocument();
});
it('should render navigation items', () => {
render(<Header />);
expect(screen.getByText('首页')).toBeInTheDocument();
expect(screen.getByText('服务')).toBeInTheDocument();
expect(screen.getByText('产品')).toBeInTheDocument();
expect(screen.getByText('案例')).toBeInTheDocument();
expect(screen.getByText('关于')).toBeInTheDocument();
expect(screen.getByText('联系')).toBeInTheDocument();
});
it('should render consult button', () => {
render(<Header />);
expect(screen.getByTestId('consult-button')).toBeInTheDocument();
});
it('should render mobile menu button', () => {
render(<Header />);
expect(screen.getByTestId('mobile-menu-button')).toBeInTheDocument();
});
});
describe('Mobile Menu', () => {
it('should toggle mobile menu on button click', async () => {
render(<Header />);
const menuButton = screen.getByTestId('mobile-menu-button');
expect(screen.queryByTestId('mobile-navigation')).not.toBeInTheDocument();
fireEvent.click(menuButton);
await waitFor(() => {
expect(screen.getByTestId('mobile-navigation')).toBeInTheDocument();
});
fireEvent.click(menuButton);
await waitFor(() => {
expect(screen.queryByTestId('mobile-navigation')).not.toBeInTheDocument();
});
});
it('should show X icon when menu is open', async () => {
render(<Header />);
const menuButton = screen.getByTestId('mobile-menu-button');
fireEvent.click(menuButton);
await waitFor(() => {
expect(screen.getByTestId('x-icon')).toBeInTheDocument();
});
});
it('should show Menu icon when menu is closed', () => {
render(<Header />);
expect(screen.getByTestId('menu-icon')).toBeInTheDocument();
});
});
describe('Accessibility', () => {
it('should have proper ARIA attributes on menu button', () => {
render(<Header />);
const menuButton = screen.getByTestId('mobile-menu-button');
expect(menuButton).toHaveAttribute('aria-expanded', 'false');
expect(menuButton).toHaveAttribute('aria-controls', 'mobile-menu');
expect(menuButton).toHaveAttribute('aria-label', '打开菜单');
});
it('should update aria-expanded when menu is toggled', async () => {
render(<Header />);
const menuButton = screen.getByTestId('mobile-menu-button');
fireEvent.click(menuButton);
await waitFor(() => {
expect(menuButton).toHaveAttribute('aria-expanded', 'true');
expect(menuButton).toHaveAttribute('aria-label', '关闭菜单');
});
});
it('should have proper navigation role', () => {
render(<Header />);
const nav = screen.getByTestId('desktop-navigation');
expect(nav).toHaveAttribute('role', 'navigation');
});
});
describe('Navigation', () => {
it('should have correct href for navigation items', () => {
render(<Header />);
const homeLink = screen.getByText('首页').closest('a');
const contactLink = screen.getByText('联系').closest('a');
expect(homeLink).toHaveAttribute('href', '/');
expect(contactLink).toHaveAttribute('href', '/contact');
});
});
});