feat(w5): ship v2.0.0 platform sync, undo persistence, and updates
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
||||
import { mkdtempSync, rmSync, existsSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
import { tmpdir } from 'os'
|
||||
import { SyncService } from '../../src/main/services/sync.service'
|
||||
import { GlobalSettingsService } from '../../src/main/services/global-settings'
|
||||
import { BookRegistryService } from '../../src/main/services/book-registry'
|
||||
import { SYNC_BUNDLE_NAME } from '../../src/main/services/sync-crypto'
|
||||
import { closeAllBookDbs } from '../../src/main/db/connection'
|
||||
|
||||
describe('SyncService', () => {
|
||||
let userDir: string
|
||||
let sync: SyncService
|
||||
|
||||
beforeEach(() => {
|
||||
userDir = mkdtempSync(join(tmpdir(), 'bilin-sync-svc-'))
|
||||
const settings = new GlobalSettingsService(userDir)
|
||||
const registry = new BookRegistryService(userDir)
|
||||
registry.create({ name: '同步测试书', category: '玄幻', createSampleChapter: false })
|
||||
sync = new SyncService(registry, settings, userDir)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
closeAllBookDbs()
|
||||
try {
|
||||
rmSync(userDir, { recursive: true, force: true })
|
||||
} catch {
|
||||
/* windows file lock */
|
||||
}
|
||||
})
|
||||
|
||||
it('IT-SYNC-01: local-folder sync writes encrypted bundle', async () => {
|
||||
const syncDir = mkdtempSync(join(tmpdir(), 'bilin-sync-target-'))
|
||||
try {
|
||||
sync.configure({
|
||||
config: {
|
||||
mode: 'local-folder',
|
||||
localFolderPath: syncDir,
|
||||
schedule: 'manual'
|
||||
},
|
||||
password: 'test-password-1'
|
||||
})
|
||||
const result = await sync.run('test-password-1')
|
||||
expect(result.status).toBe('ok')
|
||||
expect(existsSync(join(syncDir, SYNC_BUNDLE_NAME))).toBe(true)
|
||||
} finally {
|
||||
rmSync(syncDir, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user