try try again - almost giving up
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 4m27s
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 4m27s
This commit is contained in:
@@ -30,14 +30,7 @@ vi.mock('./pages/admin/AdminPage', () => ({ AdminPage: () => <div data-testid="a
|
||||
// In react-router v6, wrapper routes must render an <Outlet /> for nested routes to appear.
|
||||
// Our previous mock was trying to render `{children}`, which is incorrect for this pattern.
|
||||
// This new mock correctly simulates the behavior of the actual AdminRoute component.
|
||||
vi.mock('./components/AdminRoute', () => ({
|
||||
AdminRoute: ({ children }: { children?: React.ReactNode }) => (
|
||||
<div data-testid="admin-route-mock">
|
||||
{children}
|
||||
<Outlet />
|
||||
</div>
|
||||
)
|
||||
}));
|
||||
vi.mock('./components/AdminRoute', () => ({ AdminRoute: ({ children }: { children: React.ReactNode }) => <div data-testid="admin-route-mock">{children || <Outlet />}</div> }));
|
||||
vi.mock('./pages/admin/CorrectionsPage', () => ({ CorrectionsPage: () => <div data-testid="corrections-page-mock">Corrections Page</div> }));
|
||||
vi.mock('./pages/admin/ActivityLog', () => ({ ActivityLog: () => <div data-testid="activity-log-mock">Activity Log</div> }));
|
||||
vi.mock('./features/shopping/WatchedItemsList', () => ({ WatchedItemsList: () => <div data-testid="watched-items-list-mock">Watched Items List</div> }));
|
||||
@@ -122,7 +115,7 @@ describe('App Component', () => {
|
||||
isLoading: false,
|
||||
});
|
||||
|
||||
// Also mock the API call that might happen inside useAuth or App useEffects
|
||||
// Also mock the API call just in case App uses it directly on mount
|
||||
mockedApiClient.getAuthenticatedUserProfile.mockResolvedValue(new Response(JSON.stringify(mockAdminProfile)));
|
||||
|
||||
renderApp();
|
||||
|
||||
@@ -398,7 +398,6 @@ describe('ProfileManager Authenticated User Features', () => {
|
||||
fireEvent.click(screen.getByRole('button', { name: /save profile/i }));
|
||||
|
||||
await waitFor(() => {
|
||||
console.log('onProfileUpdate calls:', mockOnProfileUpdate.mock.calls);
|
||||
expect(mockedApiClient.updateUserProfile).toHaveBeenCalled();
|
||||
expect(mockOnProfileUpdate).toHaveBeenCalledWith(expect.objectContaining({ full_name: 'Updated Name' }));
|
||||
// Match any success message containing "Profile" and "updated"
|
||||
|
||||
@@ -31,30 +31,18 @@ vi.mock('@google/genai', () => ({
|
||||
}));
|
||||
|
||||
// 3. Robust mock for file system operations
|
||||
// We need to support "import fs from 'fs/promises'" (default export)
|
||||
// AND "import { readFile } from 'fs/promises'" (named export)
|
||||
vi.mock('fs/promises', () => {
|
||||
const defaultExport = {
|
||||
readFile: mockReadFile,
|
||||
};
|
||||
return {
|
||||
...defaultExport,
|
||||
default: defaultExport,
|
||||
};
|
||||
});
|
||||
|
||||
// Also mock 'fs' in case it's imported that way
|
||||
vi.mock('fs', () => ({
|
||||
default: {
|
||||
promises: {
|
||||
readFile: mockReadFile,
|
||||
},
|
||||
readFile: (path: any, cb: any) => cb(null, Buffer.from('')), // legacy callback style
|
||||
},
|
||||
// Ensure the mock works for both default and named imports across fs and node:fs
|
||||
const fsMock = {
|
||||
readFile: mockReadFile,
|
||||
promises: {
|
||||
readFile: mockReadFile,
|
||||
},
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
vi.mock('fs', () => ({ ...fsMock, default: fsMock }));
|
||||
vi.mock('node:fs', () => ({ ...fsMock, default: fsMock }));
|
||||
vi.mock('fs/promises', () => ({ readFile: mockReadFile, default: { readFile: mockReadFile } }));
|
||||
vi.mock('node:fs/promises', () => ({ readFile: mockReadFile, default: { readFile: mockReadFile } }));
|
||||
|
||||
// 4. Mock sharp
|
||||
vi.mock('sharp', () => ({
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
import { describe, it, expect, vi, beforeEach, beforeAll, type Mock } from 'vitest';
|
||||
|
||||
// 1. Define spies
|
||||
const successSpy = vi.fn();
|
||||
const errorSpy = vi.fn();
|
||||
|
||||
// 2. Create the mock function with properties
|
||||
const mockToastFn = vi.fn() as any;
|
||||
mockToastFn.success = successSpy;
|
||||
mockToastFn.error = errorSpy;
|
||||
|
||||
// 3. Mock the module
|
||||
vi.mock('../lib/toast', () => {
|
||||
// 1. Hoist the spies so they are initialized before the mock factory executes
|
||||
const { successSpy, errorSpy } = vi.hoisted(() => {
|
||||
return {
|
||||
default: mockToastFn,
|
||||
successSpy: vi.fn(),
|
||||
errorSpy: vi.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
// 2. Mock the local re-export using the hoisted spies
|
||||
vi.mock('../lib/toast', () => {
|
||||
const fn = vi.fn();
|
||||
// Attach the spies to the mocked default function
|
||||
(fn as any).success = successSpy;
|
||||
(fn as any).error = errorSpy;
|
||||
|
||||
return {
|
||||
default: fn,
|
||||
__esModule: true,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user