Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions packages/plugins/plugin-auth/src/member-role-canonical.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,7 @@ import {
callerCarriesCreatorRole,
} from './remove-member-permission-guard.js';
import { BUILTIN_MEMBERSHIP_ROLES } from '@objectstack/spec/identity';
import type { IDataEngine } from '@objectstack/spec/contracts';

// ---------------------------------------------------------------------------
// The vendor's three owner-tests, extracted from the installed package
Expand DownExpand Up@@ -383,13 +384,29 @@ describe('#8317 — write-path canonicalisation hooks', () => {
// The one-off pass
// ---------------------------------------------------------------------------

/** The test-only handles this double hangs off the contract it implements. */
type MemoryEngineHandles = {
rows: Array<Record<string, unknown>>;
calls: Array<{ object: string; patch: any; options: any }>;
};

/**
* Memory engine for the migration. `update` is pinned to ObjectQL's own
* dispatch predicate (#4550/#5480): a fake looser than the real engine turns a
* green suite into no suite at all on exactly the write this pass performs.
*
* It DECLARES `IDataEngine` so `check:engine-double-contract` can see that pin
* and ratchet it (#11626's declaration route). The double spells one engine
* sibling (`find`), which is below the inference threshold, so before the
* declaration the `assertEngineUpdateDispatch` call above was real protection
* that no ledger row named — drop it tomorrow and nothing reddens. The
* intersection is what keeps this honest rather than padded: the contract is
* asserted, and `rows`/`calls` stay declared as what they are, test handles.
*/
function makeMemoryEngine(rows: Array<Record<string, unknown>>) {
const calls: Array<{ object: string; patch: any; options: any }> = [];
function makeMemoryEngine(
rows: MemoryEngineHandles['rows'],
): IDataEngine & MemoryEngineHandles {
const calls: MemoryEngineHandles['calls'] = [];
return {
rows,
calls,
Expand All@@ -406,7 +423,7 @@ function makeMemoryEngine(rows: Array<Record<string, unknown>>) {
Object.assign(row, patch);
return { ...row };
},
};
} as unknown as IDataEngine & MemoryEngineHandles;
}

describe('#8317 — the one-off convergent pass', () => {
Expand Down
5 changes: 5 additions & 0 deletions scripts/engine-double-contract.pinned.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -1326,6 +1326,11 @@
"verb": "update",
"pinned": 1
},
{
"file": "packages/plugins/plugin-auth/src/member-role-canonical.test.ts",
"verb": "update",
"pinned": 1
},
{
"file": "packages/plugins/plugin-auth/src/org-create-posture-gate.test.ts",
"verb": "delete",
Expand Down
Loading