fix: validate active note cache refresh
This commit is contained in:
@@ -497,10 +497,14 @@ describe('useNoteActions hook', () => {
|
||||
})
|
||||
|
||||
describe('note open is read-only', () => {
|
||||
it('does not sync title or reload entry when opening or reopening a note', async () => {
|
||||
it('does not sync title or reload entry when opening or freshness-validating a note', async () => {
|
||||
vi.mocked(isTauri).mockReturnValue(true)
|
||||
const entry = makeEntry({ path: '/test/vault/qa-test.md', filename: 'qa-test.md', title: 'Qa Test' })
|
||||
vi.mocked(invoke).mockResolvedValueOnce('# Qa Test\n')
|
||||
vi.mocked(invoke).mockImplementation(async (command) => {
|
||||
if (command === 'validate_note_content') return true
|
||||
if (command === 'get_note_content') return '# Qa Test\n'
|
||||
return null
|
||||
})
|
||||
|
||||
const { result } = renderHook(() => useNoteActions(makeConfig([entry])))
|
||||
|
||||
@@ -510,9 +514,10 @@ describe('useNoteActions hook', () => {
|
||||
const desyncedEntry = { ...entry, title: 'Wrong Title Desynced' }
|
||||
await act(async () => { await result.current.handleSelectNote(desyncedEntry) })
|
||||
|
||||
expect(vi.mocked(invoke)).toHaveBeenCalledTimes(callCountAfterFirstOpen)
|
||||
expect(vi.mocked(invoke)).toHaveBeenCalledTimes(callCountAfterFirstOpen + 1)
|
||||
expect(vi.mocked(invoke).mock.calls).toEqual([
|
||||
['get_note_content', { path: '/test/vault/qa-test.md' }],
|
||||
['validate_note_content', { path: '/test/vault/qa-test.md', content: '# Qa Test\n' }],
|
||||
])
|
||||
expect(result.current.tabs[0].entry.title).toBe('Qa Test')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user