Skip to content

Commit 82ae109

Browse files
committed
test(plugin-auth): route the gate pin's findOne double through the engine predicate; record the new pinned doubles
check:engine-double-contract asks a new findOne double to route through assertEngineFindOnePredicate and the RETAINED ledger to learn the three new pinned (file, verb) rows (node scripts/check-engine-double-contract.mjs --write). Claude-Session: https://claude.ai/code/session_01WkL6Eijt432S1Y7ekb6ovQ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 33520be commit 82ae109

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎packages/plugins/plugin-auth/src/default-org-bootstrap-once.test.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
3232
import { resetPlatformAdminEmailMemo } from '@objectstack/core';
33-
import { assertEngineUpdateDispatch } from '@objectstack/objectql';
33+
import { assertEngineFindOnePredicate, assertEngineUpdateDispatch } from '@objectstack/objectql';
3434
import {
3535
ensureDefaultOrganization,
3636
type EnsureDefaultOrganizationOptions,
@@ -87,9 +87,11 @@ function rig(seed: Partial<Record<string, Row[]>> = {}) {
8787
const rows = (tables[object] ?? []).filter((r) => matches(r, query?.where));
8888
return rows.slice(0, query?.limit ?? rows.length);
8989
}),
90-
findOne: vi.fn(async (object: string, query: any) =>
91-
(tables[object] ?? []).find((r) => r.id === query?.where?.id) ?? null,
92-
),
90+
findOne: vi.fn(async (object: string, query: any) => {
91+
// Pinned to ObjectQL.findOne's predicate contract (the ledger reads by id).
92+
assertEngineFindOnePredicate(object, query);
93+
return (tables[object] ?? []).find((r) => r.id === query?.where?.id) ?? null;
94+
}),
9395
insert: vi.fn(async (object: string, data: Row) => {
9496
if (object === 'sys_migration') {
9597
ledgerInserts.push(data);

‎scripts/engine-double-contract.pinned.json‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,6 +2436,11 @@
24362436
"verb": "update",
24372437
"pinned": 1
24382438
},
2439+
{
2440+
"file": "packages/plugins/organizations/src/walled-default-org-owner-bind-in-flight.pin.test.ts",
2441+
"verb": "findOne",
2442+
"pinned": 1
2443+
},
24392444
{
24402445
"file": "packages/plugins/plugin-approvals/src/admin-exemption-retired.test.ts",
24412446
"verb": "delete",
@@ -2776,6 +2781,16 @@
27762781
"verb": "update",
27772782
"pinned": 1
27782783
},
2784+
{
2785+
"file": "packages/plugins/plugin-auth/src/default-org-bootstrap-once.test.ts",
2786+
"verb": "findOne",
2787+
"pinned": 1
2788+
},
2789+
{
2790+
"file": "packages/plugins/plugin-auth/src/default-org-bootstrap-once.test.ts",
2791+
"verb": "update",
2792+
"pinned": 1
2793+
},
27792794
{
27802795
"file": "packages/plugins/plugin-auth/src/durability-swallow-repair.test.ts",
27812796
"verb": "findOne",

0 commit comments

Comments
 (0)