Skip to content

Commit 7c5f3e5

Browse files
committed
test(runtime,service-automation): open the stale-summary engine doubles with the producer's dispatch predicates
The three new #28861 suites' engine doubles now open update / delete / findOne with assertEngineUpdateDispatch / assertEngineDeleteDispatch / assertEngineFindOnePredicate, so each fake refuses what ObjectQL refuses, and the pinned ledger records them (check-engine-double-contract --write). Claude-Session: https://claude.ai/code/session_01ADHkmQEc6KnPaxi9d3soLZ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 7365c82 commit 7c5f3e5

4 files changed

Lines changed: 45 additions & 1 deletion

File tree

‎packages/runtime/src/action-body-write-stale-summary.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
*/
3939

4040
import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest';
41+
import { assertEngineDeleteDispatch, assertEngineUpdateDispatch } from '@objectstack/metadata-core';
4142
import { ScopedContext, SummaryRecomputeError } from '@objectstack/objectql';
4243
import { earnedAnswerOf, withEarnedAnswer } from '@objectstack/types';
4344

@@ -86,6 +87,7 @@ function makeRig(handler: Handler) {
8687
throw new SummaryRecomputeError(FAILURES as any, { ...row });
8788
}),
8889
update: vi.fn(async (object: string, data: any, options?: any) => {
90+
assertEngineUpdateDispatch(data, options);
8991
const id = String(options?.where?.id);
9092
if (id === 'refused') throw refuse(object);
9193
const row = { ...(rows.get(id) ?? { id }), ...data };
@@ -94,6 +96,7 @@ function makeRig(handler: Handler) {
9496
throw new SummaryRecomputeError(FAILURES as any, { ...row });
9597
}),
9698
delete: vi.fn(async (object: string, options?: any) => {
99+
assertEngineDeleteDispatch(options);
97100
const id = String(options?.where?.id);
98101
if (id === 'refused') throw refuse(object);
99102
rows.delete(id);

‎packages/runtime/src/sandbox/body-write-stale-summary.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
*/
3030

3131
import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest';
32+
import { assertEngineDeleteDispatch, assertEngineUpdateDispatch } from '@objectstack/metadata-core';
3233
import { ScopedContext, SummaryRecomputeError } from '@objectstack/objectql';
3334

3435
import { actionBodyRunnerFactory, hookBodyRunnerFactory, jobBodyRunnerFactory } from './body-runner.js';
@@ -50,10 +51,12 @@ function makeEngine() {
5051
throw new SummaryRecomputeError(FAILURES as any, { ...data });
5152
}),
5253
update: vi.fn(async (_object: string, data: any, options?: any) => {
54+
assertEngineUpdateDispatch(data, options);
5355
writes.push(`update:${options?.where?.id}`);
5456
throw new SummaryRecomputeError(FAILURES as any, { id: options?.where?.id, ...data });
5557
}),
5658
delete: vi.fn(async (_object: string, options?: any) => {
59+
assertEngineDeleteDispatch(options);
5760
writes.push(`delete:${options?.where?.id}`);
5861
throw new SummaryRecomputeError(FAILURES as any, { id: options?.where?.id });
5962
}),

‎packages/services/service-automation/src/builtin/crud-stale-summary.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*/
2727

2828
import { describe, it, expect } from 'vitest';
29+
import { assertEngineDeleteDispatch, assertEngineFindOnePredicate, assertEngineUpdateDispatch } from '@objectstack/metadata-core';
2930
import { SummaryRecomputeError } from '@objectstack/objectql';
3031
import { AutomationEngine } from '../engine.js';
3132
import { registerCrudNodes } from './crud-nodes.js';
@@ -52,15 +53,17 @@ function makeData() {
5253
throw new SummaryRecomputeError(FAILURES as any, { ...fields });
5354
},
5455
async update(_object: string, fields: any, opts?: any) {
56+
assertEngineUpdateDispatch(fields, opts);
5557
writes.push(`update:${opts?.where?.id}`);
5658
throw new SummaryRecomputeError(FAILURES as any, { id: opts?.where?.id, ...fields });
5759
},
5860
async delete(_object: string, opts?: any) {
61+
assertEngineDeleteDispatch(opts);
5962
writes.push(`delete:${opts?.where?.id}`);
6063
throw new SummaryRecomputeError(FAILURES as any, { id: opts?.where?.id });
6164
},
6265
async find() { return []; },
63-
async findOne() { return null; },
66+
async findOne(object: string, query?: any) { assertEngineFindOnePredicate(object, query); return null; },
6467
};
6568
return { data, writes };
6669
}

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4556,6 +4556,16 @@
45564556
"verb": "findOne",
45574557
"pinned": 1
45584558
},
4559+
{
4560+
"file": "packages/runtime/src/action-body-write-stale-summary.test.ts",
4561+
"verb": "delete",
4562+
"pinned": 1
4563+
},
4564+
{
4565+
"file": "packages/runtime/src/action-body-write-stale-summary.test.ts",
4566+
"verb": "update",
4567+
"pinned": 1
4568+
},
45594569
{
45604570
"file": "packages/runtime/src/action-declarative-update-stale-summary.test.ts",
45614571
"verb": "update",
@@ -4821,6 +4831,16 @@
48214831
"verb": "findOne",
48224832
"pinned": 1
48234833
},
4834+
{
4835+
"file": "packages/runtime/src/sandbox/body-write-stale-summary.test.ts",
4836+
"verb": "delete",
4837+
"pinned": 1
4838+
},
4839+
{
4840+
"file": "packages/runtime/src/sandbox/body-write-stale-summary.test.ts",
4841+
"verb": "update",
4842+
"pinned": 1
4843+
},
48244844
{
48254845
"file": "packages/runtime/src/security/resolve-execution-context.forward-credential.test.ts",
48264846
"verb": "findOne",
@@ -4896,6 +4916,21 @@
48964916
"verb": "findOne",
48974917
"pinned": 1
48984918
},
4919+
{
4920+
"file": "packages/services/service-automation/src/builtin/crud-stale-summary.test.ts",
4921+
"verb": "delete",
4922+
"pinned": 1
4923+
},
4924+
{
4925+
"file": "packages/services/service-automation/src/builtin/crud-stale-summary.test.ts",
4926+
"verb": "findOne",
4927+
"pinned": 1
4928+
},
4929+
{
4930+
"file": "packages/services/service-automation/src/builtin/crud-stale-summary.test.ts",
4931+
"verb": "update",
4932+
"pinned": 1
4933+
},
48994934
{
49004935
"file": "packages/services/service-automation/src/builtin/notify-both-channels-unheld-address.integration.test.ts",
49014936
"verb": "findOne",

0 commit comments

Comments
 (0)