fix: live-reload theme CSS vars on editor save and frontmatter changes
Wire notifyThemeSaved through the frontmatter update chain so CSS variables update immediately when: - The user edits a theme note in raw mode and presses Cmd+S - A frontmatter property is changed via the inspector panel Also expose CodeMirror EditorView on the DOM for Playwright test access, add unit tests for onNotePersisted, and a new Playwright smoke test that verifies the full raw-editor → save → CSS-vars-update flow. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -219,6 +219,43 @@ describe('useEditorSave', () => {
|
||||
expect(updateVaultContent).toHaveBeenCalledWith('/vault/note.md', edited)
|
||||
})
|
||||
|
||||
it('calls onNotePersisted with path and content after saving pending content', async () => {
|
||||
const onNotePersisted = vi.fn()
|
||||
const { result } = renderHook(() =>
|
||||
useEditorSave({ updateVaultContent, setTabs, setToastMessage, onNotePersisted })
|
||||
)
|
||||
|
||||
act(() => {
|
||||
result.current.handleContentChange('/vault/theme/default.md', '---\nbackground: "#FFD700"\n---\n')
|
||||
})
|
||||
|
||||
await act(async () => {
|
||||
await result.current.handleSave()
|
||||
})
|
||||
|
||||
expect(onNotePersisted).toHaveBeenCalledWith(
|
||||
'/vault/theme/default.md',
|
||||
'---\nbackground: "#FFD700"\n---\n',
|
||||
)
|
||||
})
|
||||
|
||||
it('calls onNotePersisted for unsaved fallback when no pending content', async () => {
|
||||
const onNotePersisted = vi.fn()
|
||||
const { result } = renderHook(() =>
|
||||
useEditorSave({ updateVaultContent, setTabs, setToastMessage, onNotePersisted })
|
||||
)
|
||||
|
||||
// No handleContentChange — simulate Cmd+S on a newly created unsaved note
|
||||
await act(async () => {
|
||||
await result.current.handleSave({ path: '/vault/theme/default.md', content: '---\nbackground: "#FF0000"\n---\n' })
|
||||
})
|
||||
|
||||
expect(onNotePersisted).toHaveBeenCalledWith(
|
||||
'/vault/theme/default.md',
|
||||
'---\nbackground: "#FF0000"\n---\n',
|
||||
)
|
||||
})
|
||||
|
||||
it('successive edits and saves persist each version correctly', async () => {
|
||||
const { result } = renderSaveHook()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user