fix(workspace): background vector indexing and correct diagram previews
This commit is contained in:
@@ -67,6 +67,7 @@ export const useEditorStore = defineStore('editor', () => {
|
||||
if (currentFilePath.value === targetPath) saveStatus.value = 'save_failed'
|
||||
} finally {
|
||||
pendingSave = null
|
||||
if (currentFilePath.value === targetPath && saveStatus.value === 'dirty') scheduleAutoSave()
|
||||
}
|
||||
})()
|
||||
return pendingSave
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { afterEach, expect, it, vi } from 'vitest'
|
||||
import { useEditorStore } from './editor'
|
||||
import * as workspace from '@/services/workspaceService'
|
||||
|
||||
afterEach(() => { vi.restoreAllMocks(); vi.useRealTimers() })
|
||||
|
||||
it('saves text typed while the previous save is still pending', async () => {
|
||||
vi.useFakeTimers()
|
||||
setActivePinia(createPinia())
|
||||
const store = useEditorStore()
|
||||
store.currentFilePath = '/draft.md'
|
||||
let release!: () => void
|
||||
const write = vi.spyOn(workspace, 'saveFileContent').mockImplementationOnce(() => new Promise<void>(resolve => { release = resolve })).mockResolvedValue()
|
||||
store.updateContent('first')
|
||||
const saving = store.save()
|
||||
store.updateContent('latest')
|
||||
release()
|
||||
await saving
|
||||
expect(store.saveStatus).toBe('dirty')
|
||||
await vi.advanceTimersByTimeAsync(1500)
|
||||
expect(write).toHaveBeenLastCalledWith('/draft.md', 'latest')
|
||||
expect(store.saveStatus).toBe('saved')
|
||||
})
|
||||
Reference in New Issue
Block a user