Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
e2e(standalone): get database to load
Elian Doranc3b1cfd7a5d0
diff --git a/apps/client-standalone/src/local-server-worker.ts b/apps/client-standalone/src/local-server-worker.tsindex 420cb46a7f..3418beea02 100644--- a/apps/client-standalone/src/local-server-worker.ts+++ b/apps/client-standalone/src/local-server-worker.ts@@ -189,6 +189,17 @@ async function initialize(): Promise<void> {throw new Error(`Failed to fetch test fixture: ${response.status} ${response.statusText}`);}const buffer = new Uint8Array(await response.arrayBuffer());+ // Verify we actually got a SQLite database, not an SPA-fallback+ // index.html served for a missing file. SQLite databases start+ // with the 16-byte magic string "SQLite format 3\0".+ const magic = new TextDecoder().decode(buffer.subarray(0, 15));+ if (magic !== "SQLite format 3") {+ throw new Error(+ `Test fixture at /test-fixtures/document.db is not a SQLite database ` ++ `(got ${buffer.byteLength} bytes starting with "${magic}"). ` ++ `The file is likely missing and the SPA fallback is returning index.html.`+ );+ }sqlProvider!.loadFromBuffer(buffer);} else if (sqlProvider!.isOpfsAvailable()) {// Try to use OPFS for persistent storagediff --git a/apps/client-standalone/vite.config.mts b/apps/client-standalone/vite.config.mtsindex 0fa1dfbe96..cb38be1e81 100644--- a/apps/client-standalone/vite.config.mts+++ b/apps/client-standalone/vite.config.mts@@ -162,9 +162,14 @@ if (process.env.TRILIUM_INTEGRATION_TEST) {viteStaticCopy({targets: [{- src: "../../../packages/trilium-core/src/test/fixtures/document.db",+ // Forward slashes are required because fast-glob (used+ // internally) treats backslashes as escape characters on+ // Windows. `stripBase` drops the source's directory+ // structure so the file lands flat at `test-fixtures/document.db`+ // rather than mirroring the `packages/trilium-core/...` path.+ src: join(__dirname, "../../packages/trilium-core/src/test/fixtures/document.db").replace(/\\/g, "/"),dest: "test-fixtures",- rename: "document.db"+ rename: { stripBase: true }}]})