diff --git a/src/db/db-worker.ts b/src/db/db-worker.ts index 9c81e24..127127e 100644 --- a/src/db/db-worker.ts +++ b/src/db/db-worker.ts @@ -161,6 +161,16 @@ self.onmessage = async (event: MessageEvent) => { const { statements } = payload as TransactionPayload; + // Clear any dangling transaction state from a prior exec() with + // RETURNING — SQLite WASM's oo1.DB.exec can leave autocommit off + // after INSERT…RETURNING with returnValue:'resultRows'. + try { db.exec('COMMIT;'); } catch (err) { + const msg = err instanceof Error ? err.message : String(err); + if (!msg.includes('no transaction is active')) { + throw err; // Unexpected error — rethrow + } + } + db.exec('BEGIN TRANSACTION;'); try { const results = []; diff --git a/tests/e2e/features.spec.ts b/tests/e2e/features.spec.ts index 8f98c74..077b84a 100644 --- a/tests/e2e/features.spec.ts +++ b/tests/e2e/features.spec.ts @@ -328,8 +328,9 @@ test.describe('Entity Editor with Source URL', () => { const sourceInput = page.locator('#entity-source-url'); await sourceInput.fill('https://example.com/persisted-article'); - // Wait for tiptap editor to initialize before saving + // Wait for tiptap editor to fully initialize (useEditor hook returns non-null) await expect(page.locator('.tiptap-content')).toBeVisible({ timeout: 5000 }); + await expect(page.locator('.tiptap-content .ProseMirror[contenteditable="true"]')).toBeVisible({ timeout: 5000 }); // Save entity const saveBtn = page.locator('button.primary', { hasText: 'Save to DB' }); diff --git a/tests/e2e/library.spec.ts b/tests/e2e/library.spec.ts index d5a602e..81e989a 100644 --- a/tests/e2e/library.spec.ts +++ b/tests/e2e/library.spec.ts @@ -16,8 +16,9 @@ test.describe('Library View', () => { await page.fill('input[placeholder="Entity Name (e.g. TRIZ)"]', 'Library Test Entity'); await page.selectOption('select', 'concept'); - // Wait for tiptap editor to initialize before saving + // Wait for tiptap editor to fully initialize (useEditor hook returns non-null) await expect(page.locator('.tiptap-content')).toBeVisible({ timeout: 5000 }); + await expect(page.locator('.tiptap-content .ProseMirror[contenteditable="true"]')).toBeVisible({ timeout: 5000 }); await page.click('button:has-text("Save to DB")'); await expect(page.locator('[role="alert"]')).toContainText('Saved successfully', { timeout: 10000 }); });