fix: updated packages
This commit is contained in:
@@ -43,15 +43,6 @@ const { mockFs, mockWatcher, mockChokidarWatch } = vi.hoisted(() => {
|
||||
|
||||
vi.mock('fs/promises', () => mockFs);
|
||||
|
||||
// Mock path (use posix-style for consistent tests)
|
||||
vi.mock('path', async () => {
|
||||
const actual = await vi.importActual<typeof import('path')>('path');
|
||||
return {
|
||||
...actual,
|
||||
default: actual,
|
||||
};
|
||||
});
|
||||
|
||||
// Mock electron
|
||||
vi.mock('electron', () => ({
|
||||
app: {
|
||||
|
||||
@@ -561,10 +561,23 @@ describe('SyncEngine', () => {
|
||||
});
|
||||
|
||||
it('should log sync completion with results', async () => {
|
||||
// Use real timers for this test as TaskManager may use timers
|
||||
vi.useRealTimers();
|
||||
|
||||
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
||||
|
||||
const { getDatabase } = await import('../../src/main/database');
|
||||
|
||||
// Reset the Dropbox sync mock to return success (might have been modified by previous test)
|
||||
mockDropboxSyncEngine.syncAll.mockResolvedValue({
|
||||
success: true,
|
||||
uploaded: 0,
|
||||
downloaded: 0,
|
||||
deleted: 0,
|
||||
conflicts: 0,
|
||||
errors: [],
|
||||
});
|
||||
|
||||
// Mock a complete sync with no pending items (so it completes quickly)
|
||||
vi.mocked(getDatabase).mockReturnValue({
|
||||
getLocal: vi.fn(() => ({
|
||||
@@ -595,10 +608,15 @@ describe('SyncEngine', () => {
|
||||
};
|
||||
|
||||
await syncEngine.configure(config);
|
||||
await syncEngine.sync('push');
|
||||
const result = await syncEngine.sync('push');
|
||||
|
||||
// Check that at least one log call contains "[SyncEngine]" and "complete"
|
||||
// Debug: check what was logged
|
||||
const calls = consoleSpy.mock.calls;
|
||||
|
||||
// Check that sync completed successfully
|
||||
expect(result.success).toBe(true);
|
||||
|
||||
// Check that at least one log call contains "[SyncEngine]" and "complete"
|
||||
const hasCompleteLog = calls.some((call: any[]) =>
|
||||
call.some((arg: any) => typeof arg === 'string' && arg.includes('[SyncEngine]') && arg.includes('complete'))
|
||||
);
|
||||
|
||||
@@ -35,6 +35,7 @@ Object.defineProperty(globalThis, 'localStorage', {
|
||||
// Mock window.electronAPI for renderer tests
|
||||
Object.defineProperty(globalThis, 'window', {
|
||||
value: {
|
||||
localStorage: localStorageMock,
|
||||
electronAPI: {
|
||||
posts: {
|
||||
create: vi.fn(),
|
||||
|
||||
Reference in New Issue
Block a user