Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix([sharing-annotationssync-cache-bucket-asset-keys]): use vi.hoisted for statMock so the mocked closure binds safely

[._.]/ Adam Eivya10ff36bbfea
diff --git a/server/services/sharing/annotationsSync.test.js b/server/services/sharing/annotationsSync.test.js
index e1ea79c4cd..31ae5956d8 100644
--- a/server/services/sharing/annotationsSync.test.js
+++ b/server/services/sharing/annotationsSync.test.js
@@ -53,8 +53,10 @@ vi.mock('fs', async () => {
// Stub `assets/{images,videos}` readdir to return [] (legacy v1 fallback) and
// `stat` so the manifests-dir mtime can be driven from individual tests (used
-// by the cache hit/miss assertions).
-const statMock = vi.fn(async () => ({ mtimeMs: 1 }));
+// by the cache hit/miss assertions). `vi.mock` factories are hoisted above
+// top-level `const`s, so the shared `statMock` binding must come from
+// `vi.hoisted` or the closure can fire before initialization.
+const { statMock } = vi.hoisted(() => ({ statMock: vi.fn(async () => ({ mtimeMs: 1 })) }));
vi.mock('fs/promises', async () => {
const actual = await vi.importActual('fs/promises');
return { ...actual, readdir: vi.fn(async () => []), stat: statMock };