test(e2e,unit): add navigation edge cases and component coverage

- Add missing-paths E2E spec for desktop/mobile navigation and contrast
- Add local Playwright config for dev server testing
- Expand unit tests for CMS data server, products, contact and UI components
- Adjust jest config for new test patterns
This commit is contained in:
张翔
2026-07-08 14:47:07 +08:00
parent 7f36211342
commit a6ea2cc72c
11 changed files with 1693 additions and 34 deletions
+10 -3
View File
@@ -10,7 +10,7 @@ jest.mock('@/hooks/use-reduced-motion', () => ({
describe('ScrollProgress', () => {
beforeEach(() => {
jest.clearAllMocks();
// Mock document height for predictable progress calculation
// Mock document/scroll geometry for predictable progress calculation
Object.defineProperty(document.documentElement, 'scrollHeight', {
value: 1000,
configurable: true,
@@ -19,6 +19,11 @@ describe('ScrollProgress', () => {
value: 500,
configurable: true,
});
Object.defineProperty(window, 'scrollY', {
value: 0,
configurable: true,
writable: true,
});
});
it('should always render the progress container', () => {
@@ -44,8 +49,10 @@ describe('ScrollProgress', () => {
const { container } = render(<ScrollProgress />);
const innerBar = (container.firstChild as HTMLElement).firstChild as HTMLElement;
expect(innerBar).toBeInTheDocument();
// 默认 progress 为 0宽度为 0%
expect(innerBar.style.width).toBe('0%');
// 默认 progress 为 0使用 transform scaleX 实现宽度变化
expect(innerBar.style.width).toBe('100%');
expect(innerBar.style.transform).toBe('scaleX(0)');
expect(innerBar.style.transformOrigin).toBe('left');
});
it('should apply default height of 2px', () => {