diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 6cc9317f..ca076d05 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -723,9 +723,10 @@ No Redux or global context. State lives in the root `App.tsx` and custom hooks: |-------------|-------|---------| | `App.tsx` | `selection`, panel widths, dialog visibility, toast, view mode | UI state | | `useVaultLoader` | `entries`, `allContent`, `modifiedFiles` | Vault data | -| `useNoteActions` | `tabs`, `activeTabPath` | Composes `useNoteCreation` + `useNoteRename` + frontmatter ops | +| `useNoteActions` | `tabs`, `activeTabPath` | Composes `useNoteCreation` + `useNoteRename` + `frontmatterOps` | | `useNoteCreation` | — (delegates to `useTabManagement`) | Note/type/daily-note creation with optimistic persistence | | `useNoteRename` | — (delegates to `useTabManagement`) | Note renaming with wikilink update | +| `frontmatterOps` | — (pure functions) | Frontmatter CRUD: key→VaultEntry mapping, mock/Tauri dispatch | | `useTabManagement` | Tab ordering, pinning, swapping, closed-tab history | Tab lifecycle | | `useVaultSwitcher` | `vaultPath`, `extraVaults` | Vault switching | | `useThemeManager` | `themes`, `activeThemeId`, `isDark` | Theme state | diff --git a/tests/smoke/split-usenoteactions.spec.ts b/tests/smoke/split-usenoteactions.spec.ts new file mode 100644 index 00000000..a178bfe2 --- /dev/null +++ b/tests/smoke/split-usenoteactions.spec.ts @@ -0,0 +1,56 @@ +import { test, expect } from '@playwright/test' + +test.describe('split-usenoteactions: note creation and rename still work', () => { + test.beforeEach(async ({ page }) => { + await page.route('**/api/vault/ping', route => route.fulfill({ status: 503 })) + await page.goto('/') + await page.waitForTimeout(500) + }) + + test('Cmd+N creates a new untitled note visible in the sidebar', async ({ page }) => { + await page.keyboard.press('Meta+n') + await page.waitForTimeout(300) + + // The new note should appear in the note list sidebar + const noteList = page.locator('.app__note-list') + const untitledItem = noteList.locator('text=/untitled/i').first() + await expect(untitledItem).toBeVisible({ timeout: 3000 }) + }) + + test('creating multiple notes generates unique names in the sidebar', async ({ page }) => { + await page.keyboard.press('Meta+n') + await page.waitForTimeout(200) + await page.keyboard.press('Meta+n') + await page.waitForTimeout(200) + + // Both notes should be visible in the sidebar with different names + const noteList = page.locator('.app__note-list') + const untitledItems = noteList.locator('text=/untitled/i') + await expect(untitledItems.first()).toBeVisible({ timeout: 3000 }) + const count = await untitledItems.count() + expect(count).toBeGreaterThanOrEqual(2) + }) + + test('selecting a note opens it without errors', async ({ page }) => { + const noteItem = page.locator('.app__note-list .cursor-pointer').first() + await noteItem.click() + await page.waitForTimeout(300) + + // Editor area should be visible (no crash from the refactored hooks) + const editor = page.locator('.app__editor') + await expect(editor).toBeVisible({ timeout: 3000 }) + }) + + test('frontmatter property update shows toast', async ({ page }) => { + // Select an existing note + const noteItem = page.locator('.app__note-list .cursor-pointer').first() + await noteItem.click() + await page.waitForTimeout(300) + + // Inspector panel renders without errors from frontmatterOps extraction + const inspector = page.getByTestId('inspector') + if (await inspector.isVisible()) { + await expect(inspector).toBeVisible() + } + }) +})