try try again - almost giving up
Some checks are pending
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Has started running

This commit is contained in:
2025-12-06 11:03:39 -08:00
parent 763c6f6808
commit 6a6e94842c
4 changed files with 63 additions and 33 deletions

View File

@@ -120,10 +120,14 @@ describe('App Component', () => {
renderApp();
// Wait for the header (which means app loaded) AND the bulk importer
// --- FIX LEDGER --- KEEP THIS UPDATED
// 1. Expect `bulk-importer-mock`. Failed (Element not found).
// Reason: `AdminPage` is mocked, so its children (including BulkImporter) are not rendered.
// 2. Current Strategy: Expect `admin-page-mock`. This proves routing to /admin worked.
await waitFor(() => {
expect(screen.getByTestId('header-mock')).toBeInTheDocument();
expect(screen.getByTestId('bulk-importer-mock')).toBeInTheDocument();
expect(screen.getByTestId('admin-page-mock')).toBeInTheDocument();
});
});

View File

@@ -375,20 +375,27 @@ describe('ProfileManager Authenticated User Features', () => {
// --- Profile Tab ---
it('should allow updating the user profile', async () => {
// FIX: Ensure the mock returns a Promise that resolves to the Response,
// and that the JSON method returns the expected data.
// --- FIX LEDGER ---
// 1. Standard mockResolvedValue. Failed (callback not called).
// 2. Attempt: Return `new Response()`. Failed (callback not called).
// 3. Current Strategy: Return plain object with `ok` and `json` methods to simulate Response.
// Also reset mocks to ensure no contamination.
const updatedProfileData = { ...authenticatedProfile, full_name: 'Updated Name' };
(mockedApiClient.updateUserProfile as Mock).mockResolvedValue({
// Reset mocks to ensure clean state
vi.mocked(mockedApiClient.updateUserProfile).mockReset();
vi.mocked(mockedApiClient.updateUserAddress).mockReset();
vi.mocked(mockedApiClient.updateUserProfile).mockResolvedValue({
ok: true,
json: async () => updatedProfileData,
});
} as Response);
// Also mock the address update which happens in parallel
(mockedApiClient.updateUserAddress as Mock).mockResolvedValue({
vi.mocked(mockedApiClient.updateUserAddress).mockResolvedValue({
ok: true,
json: async () => ({}),
});
} as Response);
render(<ProfileManager {...authenticatedProps} />);

View File

@@ -30,19 +30,36 @@ vi.mock('@google/genai', () => ({
GoogleGenAI: MockGoogleGenAIImplementation,
}));
// 3. Robust mock for file system operations
// Ensure the mock works for both default and named imports across fs and node:fs
const fsMock = {
// --- FIX LEDGER ---
// 1. Mock `fs/promises` default export. Failed.
// 2. Mock `fs` and `node:fs`. Failed.
// 3. Current Strategy: Mock modules to return the HOISTED mock variables directly.
vi.mock('fs', () => ({
default: { readFile: mockReadFile, promises: { readFile: mockReadFile } },
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 } }));
vi.mock('node:fs', () => ({
default: { readFile: mockReadFile, promises: { readFile: mockReadFile } },
readFile: mockReadFile,
promises: {
readFile: mockReadFile,
},
}));
vi.mock('fs/promises', () => ({
default: { readFile: mockReadFile },
readFile: mockReadFile,
}));
vi.mock('node:fs/promises', () => ({
default: { readFile: mockReadFile },
readFile: mockReadFile,
}));
// 4. Mock sharp
vi.mock('sharp', () => ({

View File

@@ -1,23 +1,25 @@
import { describe, it, expect, vi, beforeEach, beforeAll, type Mock } from 'vitest';
// 1. Hoist the spies so they are initialized before the mock factory executes
const { successSpy, errorSpy } = vi.hoisted(() => {
return {
successSpy: vi.fn(),
errorSpy: vi.fn(),
};
});
// --- FIX LEDGER ---
// 1. Initial attempt: Spy on default export property. Failed (0 calls).
// 2. Attempt: Hoisted spies attached to default export. Failed (0 calls).
// 3. Current Strategy: Mock the module to return a simple object structure for default export.
// Using vi.hoisted to ensure spies are available to both the factory and the test body.
const { successSpy, errorSpy } = vi.hoisted(() => ({
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;
const toastFn = vi.fn();
(toastFn as any).success = successSpy;
(toastFn as any).error = errorSpy;
return {
default: fn,
__esModule: true,
default: toastFn,
success: successSpy,
error: errorSpy,
__esModule: true,
};
});