Skip to content

Commit f082789

Browse files
committed
test(objectql): fixtures declare the fields their readonlyWhen and validation rules read
Claude-Session: https://claude.ai/code/session_017ErfyP2Rx7XWHJA27QjyUi Co-authored-by: Claude <noreply@anthropic.com>
1 parent 10d7f33 commit f082789

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎packages/objectql/src/engine.test.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,10 @@ describe('ObjectQL Engine', () => {
14061406
name: 'invoice',
14071407
fields: {
14081408
amount: { type: 'number', readonlyWhen: 'record.locked == true' },
1409+
// [#21613] Declared: the rules below read them, and a
1410+
// write's prior read now carries the declared fields only.
1411+
locked: { type: 'boolean' },
1412+
limit: { type: 'number' },
14091413
},
14101414
validations: [{ type: 'cross_field', name: 'amount_cap', message: 'amount exceeds limit', condition: 'record.amount > record.limit', fields: ['amount'] }],
14111415
} as any);
@@ -1466,7 +1470,9 @@ describe('ObjectQL Engine', () => {
14661470
it('reports a readonlyWhen-locked field on a single-id update (reason readonly_when)', async () => {
14671471
vi.mocked(SchemaRegistry.getObject).mockReturnValue({
14681472
name: 'invoice',
1469-
fields: { amount: { type: 'number', readonlyWhen: 'record.locked == true' } },
1473+
// [#21613] `locked` is declared: the prior read the rule
1474+
// reads carries the declared fields only.
1475+
fields: { amount: { type: 'number', readonlyWhen: 'record.locked == true' }, locked: { type: 'boolean' } },
14701476
} as any);
14711477
vi.mocked(mockDriver.findOne).mockResolvedValue({ id: '1', locked: true, amount: 100 } as any);
14721478

@@ -1483,7 +1489,9 @@ describe('ObjectQL Engine', () => {
14831489
it('reports bulk-path strips too (multi update — locked in ≥1 matched row)', async () => {
14841490
vi.mocked(SchemaRegistry.getObject).mockReturnValue({
14851491
name: 'invoice',
1486-
fields: { amount: { type: 'number', readonlyWhen: 'record.locked == true' } },
1492+
// [#21613] `locked` is declared: the prior read the rule
1493+
// reads carries the declared fields only.
1494+
fields: { amount: { type: 'number', readonlyWhen: 'record.locked == true' }, locked: { type: 'boolean' } },
14871495
} as any);
14881496
vi.mocked(mockDriver.find).mockResolvedValue([
14891497
{ id: 'a', locked: false, amount: 10 },

‎packages/objectql/src/plugin.integration.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,6 +1725,9 @@ describe('ObjectQLPlugin - Metadata Service Integration', () => {
17251725
fields: {
17261726
status: { name: 'status', label: 'Status', type: 'text' },
17271727
amount: { name: 'amount', label: 'Amount', type: 'number', readonlyWhen: "record.status == 'paid'" } as any,
1728+
// [#21613] Declared: the rule reads it off the prior read, which
1729+
// carries the declared fields only.
1730+
limit: { name: 'limit', label: 'Limit', type: 'number' },
17281731
},
17291732
validations: [{ type: 'cross_field', name: 'amount_cap', message: 'amount exceeds limit', condition: 'record.amount > record.limit', fields: ['amount'] }] as any,
17301733
},

0 commit comments

Comments
 (0)