more test fixes
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 1h8m48s

This commit is contained in:
2025-12-20 19:40:49 -08:00
parent 56981236ab
commit 391d00ae15
13 changed files with 127 additions and 82 deletions

View File

@@ -1,7 +1,7 @@
// src/features/flyer/AnalysisPanel.test.tsx
import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest';
import { describe, it, expect, vi, beforeEach, afterEach, type Mock } from 'vitest';
import { AnalysisPanel } from './AnalysisPanel';
import { useFlyerItems } from '../../hooks/useFlyerItems';
import type { Flyer, FlyerItem, Store, MasterGroceryItem } from '../../types';
@@ -79,32 +79,16 @@ describe('AnalysisPanel', () => {
generateImage: mockGenerateImage,
});
// Mock Geolocation API
Object.defineProperty(navigator, 'geolocation', {
writable: true,
value: {
getCurrentPosition: vi.fn().mockImplementation((success) =>
Promise.resolve(
success({
coords: {
latitude: 51.1,
longitude: 45.3,
accuracy: 1,
altitude: null,
altitudeAccuracy: null,
heading: null,
speed: null,
},
timestamp: Date.now(),
})
)
),
},
});
console.log('DEBUG: beforeEach setup complete');
});
it('should render tabs and an initial "Generate" button', () => {
afterEach(() => {
console.log('DEBUG: afterEach - cleaning up');
vi.clearAllMocks();
});
// Increased timeout to 20s to prevent flaky timeouts in slow environments
it('should render tabs and an initial "Generate" button', { timeout: 20000 }, () => {
console.log('DEBUG: Starting render for initial state test');
const startTime = Date.now();
render(<AnalysisPanel selectedFlyer={mockFlyer} />);