Skip to content

Commit 13c7ac5

Browse files
os-warrenclaude
andcommitted
test(approvals): pin the #10153 harness fake engine to ObjectQL's write dispatch
check:engine-double-contract flagged the harness double's delete()/update() as looser than the engine they stand in for. Route both through assertEngineDeleteDispatch / assertEngineUpdateDispatch and record the new pinned coverage in the retained ledger, as the gate's own remedy prescribes. Part of #10153 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PnJHU45vPJj5UQrxe946Bx
1 parent af5df84 commit 13c7ac5

2 files changed

Lines changed: 37 additions & 5 deletions

File tree

‎packages/plugins/plugin-approvals/src/manager-approver-org-screen.premise.test.ts‎

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* therefore moves that input from accepted to refused.
2323
*/
2424
import { describe, it, expect, beforeEach } from 'vitest';
25+
import { assertEngineDeleteDispatch, assertEngineUpdateDispatch } from '@objectstack/objectql';
2526
import { ApprovalService } from './approval-service.js';
2627

2728
function makeFakeEngine() {
@@ -50,14 +51,35 @@ function makeFakeEngine() {
5051
return rows.slice(0, options?.limit ?? 1000);
5152
},
5253
async insert(object: string, data: any) { ensure(object).push({ ...data }); return { ...data }; },
53-
async update(object: string, idOrData: any, _opts?: any) {
54-
const data = typeof idOrData === 'object' ? idOrData : _opts;
55-
const id = typeof idOrData === 'object' ? idOrData.id : idOrData;
56-
const t = ensure(object); const i = t.findIndex(r => r.id === id);
54+
async update(object: string, data: any, options?: any) {
55+
// Pinned to ObjectQL.update's OWN dispatch predicate — a double looser
56+
// than the engine it stands in for turns a green suite into no suite.
57+
const dispatch = assertEngineUpdateDispatch(data, options);
58+
const t = ensure(object);
59+
if (dispatch.kind === 'multi') {
60+
let n = 0;
61+
for (let i = 0; i < t.length; i++) {
62+
if (matches(t[i], options?.where)) { t[i] = { ...t[i], ...data }; n++; }
63+
}
64+
return { updated: n };
65+
}
66+
const i = t.findIndex(r => r.id === dispatch.id);
5767
if (i >= 0) t[i] = { ...t[i], ...data };
5868
return t[i];
5969
},
60-
async delete() { return {}; },
70+
async delete(object: string, options?: any) {
71+
const dispatch = assertEngineDeleteDispatch(options);
72+
const t = ensure(object);
73+
if (dispatch.kind === 'multi') {
74+
const survivors = t.filter(r => !matches(r, options?.where));
75+
const deleted = t.length - survivors.length;
76+
t.splice(0, t.length, ...survivors);
77+
return { deleted };
78+
}
79+
const i = t.findIndex(r => r.id === dispatch.id);
80+
if (i >= 0) t.splice(i, 1);
81+
return { id: dispatch.id };
82+
},
6183
registerHook() {}, unregisterHooksByPackage() { return 0; }, async fire() {},
6284
};
6385
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,16 @@
10161016
"verb": "delete",
10171017
"pinned": 1
10181018
},
1019+
{
1020+
"file": "packages/plugins/plugin-approvals/src/manager-approver-org-screen.premise.test.ts",
1021+
"verb": "delete",
1022+
"pinned": 1
1023+
},
1024+
{
1025+
"file": "packages/plugins/plugin-approvals/src/manager-approver-org-screen.premise.test.ts",
1026+
"verb": "update",
1027+
"pinned": 1
1028+
},
10191029
{
10201030
"file": "packages/plugins/plugin-approvals/src/record-reader-visibility.test.ts",
10211031
"verb": "delete",

0 commit comments

Comments
 (0)