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:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user