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) <noreply@anthropic.com>
This commit is contained in:
@@ -577,11 +577,27 @@ describe('PageService', () => {
|
|||||||
};
|
};
|
||||||
const eventEmitter = { emit: jest.fn() };
|
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(
|
const svc = new PageService(
|
||||||
pageRepo as any, // pageRepo
|
pageRepo as any, // pageRepo
|
||||||
{} as any, // pagePermissionRepo
|
{} as any, // pagePermissionRepo
|
||||||
{} as any, // attachmentRepo
|
{} as any, // attachmentRepo
|
||||||
{} as any, // db
|
db as any, // db
|
||||||
{} as any, // storageService
|
{} as any, // storageService
|
||||||
{} as any, // attachmentQueue
|
{} as any, // attachmentQueue
|
||||||
{} as any, // aiQueue
|
{} as any, // aiQueue
|
||||||
|
|||||||
Reference in New Issue
Block a user