From a358d96a808b95c14a1b6f0e0506da941b03fef5 Mon Sep 17 00:00:00 2001 From: claude code agent 227 Date: Fri, 26 Jun 2026 20:44:23 +0300 Subject: [PATCH] test(git-sync): mock db.transaction in movePage provenance specs After rebasing onto develop, movePage runs its cycle-check + UPDATE inside executeTx(this.db) (develop #207 advisory-lock/atomic cycle-guard). The git-sync provenance specs still passed a bare `{}` db, so executeTx hit `db.transaction is not a function`. Reuse the same trxStub Proxy + transaction mock the develop movePage specs use so both the advisory-lock `sql.execute(trx)` and updatePage resolve. Production movePage keeps BOTH develop's lock/cycle guard AND git-sync's provenance stamping; this only updates the test harness. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../core/page/services/page.service.spec.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/server/src/core/page/services/page.service.spec.ts b/apps/server/src/core/page/services/page.service.spec.ts index 2375bf3c..1bc6af63 100644 --- a/apps/server/src/core/page/services/page.service.spec.ts +++ b/apps/server/src/core/page/services/page.service.spec.ts @@ -653,11 +653,27 @@ describe('PageService', () => { }; const eventEmitter = { emit: jest.fn() }; + // movePage now runs the cycle-check + UPDATE inside executeTx(this.db), + // i.e. this.db.transaction().execute(fn => fn(trx)). A permissive + // chainable Proxy stands in for the Kysely trx so the per-space + // advisory-lock `sql``.execute(trx)` resolves and updatePage runs. + const trxStub: any = new Proxy(function () {}, { + get: (_t, p) => + p === 'then' + ? undefined + : p === 'execute' || p === 'executeTakeFirst' + ? () => Promise.resolve([]) + : () => trxStub, + }); + const db = { + transaction: () => ({ execute: (fn: any) => fn(trxStub) }), + }; + const svc = new PageService( pageRepo as any, // pageRepo {} as any, // pagePermissionRepo {} as any, // attachmentRepo - {} as any, // db + db as any, // db {} as any, // storageService {} as any, // attachmentQueue {} as any, // aiQueue