Refactor tests and API context integration
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 5m55s
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 5m55s
- Updated tests in `useShoppingLists`, `useWatchedItems`, and various components to use `waitFor` for asynchronous assertions. - Enhanced error handling in `errorHandler` middleware tests to include validation errors and status codes. - Modified `AuthView`, `ProfileManager.Auth`, and `ProfileManager.Authenticated` tests to check for `AbortSignal` in API calls. - Removed duplicate assertions in `auth.routes.test`, `budget.routes.test`, and `gamification.routes.test`. - Introduced reusable logger matcher in `budget.routes.test`, `deals.routes.test`, `flyer.routes.test`, and `user.routes.test`. - Simplified API client mock in `aiApiClient.test` to handle token overrides correctly. - Removed unused `apiUtils.ts` file. - Added `ApiContext` and `ApiProvider` for better API client management in React components.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// src/hooks/useWatchedItems.test.tsx
|
||||
import { renderHook, act } from '@testing-library/react';
|
||||
import { renderHook, act, waitFor } from '@testing-library/react';
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { useWatchedItems } from './useWatchedItems';
|
||||
import { useApi } from './useApi';
|
||||
@@ -122,7 +122,9 @@ describe('useWatchedItems Hook', () => {
|
||||
await result.current.removeWatchedItem(itemIdToRemove);
|
||||
});
|
||||
|
||||
expect(mockRemoveWatchedItemApi).toHaveBeenCalledWith(itemIdToRemove);
|
||||
await waitFor(() => {
|
||||
expect(mockRemoveWatchedItemApi).toHaveBeenCalledWith(itemIdToRemove);
|
||||
});
|
||||
expect(mockSetWatchedItems).toHaveBeenCalledWith(expect.any(Function));
|
||||
|
||||
// Verify the logic inside the updater function
|
||||
|
||||
Reference in New Issue
Block a user