try try again - almost giving up
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 4m35s
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 4m35s
This commit is contained in:
@@ -118,12 +118,14 @@ describe('App Component', () => {
|
||||
// Also mock the API call just in case App uses it directly on mount
|
||||
mockedApiClient.getAuthenticatedUserProfile.mockResolvedValue(new Response(JSON.stringify(mockAdminProfile)));
|
||||
|
||||
renderApp();
|
||||
|
||||
// --- FIX LEDGER ---
|
||||
// 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.
|
||||
// 2. Expect `admin-page-mock` but render default route `/`. Failed (Element not found).
|
||||
// Reason: `renderApp()` defaults to `/`, so `AdminPage` at `/admin` is never rendered.
|
||||
// 3. Current Strategy: Explicitly render `['/admin']`.
|
||||
|
||||
renderApp(['/admin']);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId('header-mock')).toBeInTheDocument();
|
||||
|
||||
@@ -19,48 +19,35 @@ const { mockGenerateContent, mockReadFile, mockToBuffer, mockExtract, mockSharp
|
||||
};
|
||||
});
|
||||
|
||||
// 2. Mock the @google/genai SDK
|
||||
const MockGoogleGenAIImplementation = class {
|
||||
constructor(public config: { apiKey: string }) {}
|
||||
get models() { return { generateContent: mockGenerateContent }; }
|
||||
getGenerativeModel() { return { generateContent: mockGenerateContent }; }
|
||||
};
|
||||
|
||||
vi.mock('@google/genai', () => ({
|
||||
GoogleGenAI: MockGoogleGenAIImplementation,
|
||||
}));
|
||||
|
||||
// --- FIX LEDGER ---
|
||||
// 1. Mock `fs/promises` default export. Failed.
|
||||
// 2. Mock `fs` and `node:fs` using external object. Failed (hoisting issue).
|
||||
// 3. Mock modules to return the HOISTED mock variables directly. Failed.
|
||||
// 4. Current Strategy: Inline mock definitions inside vi.mock factory to guarantee availability and correct structure.
|
||||
// 4. Inline mock definitions inside vi.mock factory. Failed (potentially due to complex object nesting).
|
||||
// 5. Current Strategy: Use vi.fn() directly inside factory for GoogleGenAI and a unified factory for FS to ensure consistency.
|
||||
|
||||
vi.mock('fs', () => ({
|
||||
default: { readFile: mockReadFile, promises: { readFile: mockReadFile } },
|
||||
readFile: mockReadFile,
|
||||
promises: {
|
||||
readFile: mockReadFile,
|
||||
},
|
||||
}));
|
||||
// 2. Mock the @google/genai SDK
|
||||
vi.mock('@google/genai', () => {
|
||||
return {
|
||||
GoogleGenAI: class {
|
||||
constructor(public config: { apiKey: string }) {}
|
||||
get models() { return { generateContent: mockGenerateContent }; }
|
||||
getGenerativeModel() { return { generateContent: mockGenerateContent }; }
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock('node:fs', () => ({
|
||||
default: { readFile: mockReadFile, promises: { readFile: mockReadFile } },
|
||||
readFile: mockReadFile,
|
||||
promises: {
|
||||
readFile: mockReadFile,
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock('fs/promises', () => ({
|
||||
// 3. Robust mock for file system operations
|
||||
const fsFactory = () => ({
|
||||
default: { readFile: mockReadFile },
|
||||
readFile: mockReadFile,
|
||||
}));
|
||||
promises: { readFile: mockReadFile }
|
||||
});
|
||||
|
||||
vi.mock('node:fs/promises', () => ({
|
||||
default: { readFile: mockReadFile },
|
||||
readFile: mockReadFile,
|
||||
}));
|
||||
vi.mock('fs', fsFactory);
|
||||
vi.mock('node:fs', fsFactory);
|
||||
vi.mock('fs/promises', fsFactory);
|
||||
vi.mock('node:fs/promises', fsFactory);
|
||||
|
||||
// 4. Mock sharp
|
||||
vi.mock('sharp', () => ({
|
||||
|
||||
@@ -4,7 +4,8 @@ import { describe, it, expect, vi, beforeEach, beforeAll, type Mock } from 'vite
|
||||
// 1. Initial attempt: Spy on default export property. Failed (0 calls).
|
||||
// 2. Attempt: Hoisted spies attached to default export. Failed (0 calls).
|
||||
// 3. Attempt: Function-as-object mock. Failed (TS error / 0 calls).
|
||||
// 4. Current Strategy: Mock module to return a plain object as default export, matching import usage.
|
||||
// 4. Attempt: Plain object mock. Failed (0 calls).
|
||||
// 5. Current Strategy: Mock default export as a callable function with properties using Object.assign.
|
||||
|
||||
const { successSpy, errorSpy } = vi.hoisted(() => ({
|
||||
successSpy: vi.fn(),
|
||||
@@ -12,11 +13,15 @@ const { successSpy, errorSpy } = vi.hoisted(() => ({
|
||||
}));
|
||||
|
||||
vi.mock('../lib/toast', () => {
|
||||
const toastFn = vi.fn();
|
||||
// Assign properties to the function object itself to satisfy `toast.success` calls
|
||||
Object.assign(toastFn, {
|
||||
success: successSpy,
|
||||
error: errorSpy,
|
||||
});
|
||||
|
||||
return {
|
||||
default: {
|
||||
success: successSpy,
|
||||
error: errorSpy,
|
||||
},
|
||||
default: toastFn,
|
||||
success: successSpy,
|
||||
error: errorSpy,
|
||||
__esModule: true,
|
||||
|
||||
Reference in New Issue
Block a user