Skip to content

Commit 6679098

Browse files
committed
fix(test): reconstruct the v16 baseline via engine-owned, not the retired literal (#3355)
The equivalence pins built their v16 side by passing `managedBy: 'system'` to `resolveCrudAffordances` — but v17 deletes that row from `CRUD_AFFORDANCE_DEFAULTS`, so the lookup fell through to the `platform` default and reconstructed a baseline with `import: true`. The pins caught it (that is what they are for): the `expect(v16).toEqual(V16_EXPECTED)` guard failed rather than the comparison silently passing against a wrong baseline. ADR-0103 D5 gave `engine-owned` the byte-identical locked row `system` carried in v16, so it is an exact stand-in, and the V16_EXPECTED assertion keeps it honest. Also adds the NodeNext `.js` extensions the new test files needed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012C2cd7tL8QDoZ2QKN3djJ5
1 parent e5c06cd commit 6679098

4 files changed

Lines changed: 51 additions & 12 deletions

File tree

‎packages/platform-objects/src/identity/sys-user-preference.managed-by.test.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,19 @@
1616

1717
import { describe, expect, it } from 'vitest';
1818
import { resolveCrudAffordances } from '@objectstack/spec/data';
19-
import { SysUserPreference } from './sys-user-preference.object';
19+
import { SysUserPreference } from './sys-user-preference.object.js';
2020

2121
const V16_EXPECTED = { create: true, import: false, edit: true, delete: true, exportCsv: true };
2222
const V17_EXPECTED = { create: true, import: true, edit: true, delete: true, exportCsv: true };
2323

24-
const asV16 = { managedBy: 'system', userActions: { create: true, edit: true, delete: true } };
24+
/**
25+
* The v16 shape, reconstructed via `engine-owned` — which ADR-0103 D5 gave the
26+
* byte-identical locked default row `system` carried in v16. The retired literal
27+
* cannot be used: v17 deleted its row from `CRUD_AFFORDANCE_DEFAULTS`, so it would
28+
* fall through to the `platform` default and reconstruct the wrong baseline. The
29+
* `toEqual(V16_EXPECTED)` assertion below keeps the stand-in honest.
30+
*/
31+
const asV16 = { managedBy: 'engine-owned', userActions: { create: true, edit: true, delete: true } };
2532

2633
describe('#3355 — sys_user_preference moves to `system-data` with its affordances intact', () => {
2734
it('declares the new bucket and no longer carries a redundant `userActions` block', () => {

‎packages/plugins/plugin-approvals/src/sys-approval-delegation.object.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ import { SysApprovalDelegation } from './sys-approval-delegation.object';
2727
describe('#3355 — sys_approval_delegation moves to `system-data` with its affordances intact', () => {
2828
const V16_EXPECTED = { create: true, import: false, edit: true, delete: true, exportCsv: true };
2929
const V17_EXPECTED = { create: true, import: true, edit: true, delete: true, exportCsv: true };
30-
const asV16 = { managedBy: 'system', userActions: { create: true, edit: true, delete: true } };
30+
/**
31+
* The v16 shape, reconstructed via `engine-owned` — which ADR-0103 D5 gave the
32+
* byte-identical locked default row `system` carried in v16. The retired
33+
* literal cannot be used: v17 deleted its row from `CRUD_AFFORDANCE_DEFAULTS`,
34+
* so it would fall through to the `platform` default and reconstruct the wrong
35+
* baseline. The `toEqual(V16_EXPECTED)` assertion below keeps it honest.
36+
*/
37+
const asV16 = { managedBy: 'engine-owned', userActions: { create: true, edit: true, delete: true } };
3138

3239
it('declares the new bucket and no longer carries a redundant `userActions` block', () => {
3340
expect(SysApprovalDelegation.managedBy).toBe('system-data');

‎packages/plugins/plugin-security/src/objects/managed-by-system-data.test.ts‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,31 @@
2626

2727
import { describe, expect, it } from 'vitest';
2828
import { resolveCrudAffordances } from '@objectstack/spec/data';
29-
import { SysUserPosition } from './sys-user-position.object';
30-
import { SysUserPermissionSet } from './sys-user-permission-set.object';
31-
import { SysPositionPermissionSet } from './sys-position-permission-set.object';
29+
import { SysUserPosition } from './sys-user-position.object.js';
30+
import { SysUserPermissionSet } from './sys-user-permission-set.object.js';
31+
import { SysPositionPermissionSet } from './sys-position-permission-set.object.js';
3232

3333
/** What each object resolved to in v16: LOCKED `system` + `userActions: {c,e,d}`. */
3434
const V16_EXPECTED = { create: true, import: false, edit: true, delete: true, exportCsv: true };
3535

3636
/** What each object resolves to in v17: the `system-data` default, no `userActions`. */
3737
const V17_EXPECTED = { create: true, import: true, edit: true, delete: true, exportCsv: true };
3838

39-
/** The v16 declaration shape, reconstructed so the equivalence is computed, not asserted twice. */
39+
/**
40+
* The v16 declaration shape, reconstructed so the equivalence is COMPUTED rather
41+
* than asserted twice.
42+
*
43+
* It is spelled `engine-owned`, not `system`, on purpose: v17 deleted the `system`
44+
* row from `CRUD_AFFORDANCE_DEFAULTS`, so passing the retired literal would fall
45+
* through to the `platform` default and quietly reconstruct the wrong baseline
46+
* (that mistake is what this comment exists to prevent — it read green-ish and was
47+
* wrong). ADR-0103 D5 gave `engine-owned` the byte-identical locked row `system`
48+
* carried in v16 — `{create,import,edit,delete: false, exportCsv: true}` — so it is
49+
* an exact stand-in for the old bucket default. `expect(v16).toEqual(V16_EXPECTED)`
50+
* below is the check that this stand-in stayed honest.
51+
*/
4052
const asV16 = (obj: { userActions?: unknown }) => ({
41-
managedBy: 'system',
53+
managedBy: 'engine-owned',
4254
userActions: obj.userActions ?? { create: true, edit: true, delete: true },
4355
});
4456

‎packages/services/service-messaging/src/objects/managed-by-system-data.test.ts‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,28 @@
1515

1616
import { describe, expect, it } from 'vitest';
1717
import { resolveCrudAffordances } from '@objectstack/spec/data';
18-
import { NotificationTemplate } from './notification-template.object';
19-
import { NotificationSubscription } from './notification-subscription.object';
20-
import { NotificationPreference } from './notification-preference.object';
18+
import { NotificationTemplate } from './notification-template.object.js';
19+
import { NotificationSubscription } from './notification-subscription.object.js';
20+
import { NotificationPreference } from './notification-preference.object.js';
2121

2222
const V16_EXPECTED = { create: true, import: false, edit: true, delete: true, exportCsv: true };
2323
const V17_EXPECTED = { create: true, import: true, edit: true, delete: true, exportCsv: true };
2424

25+
/**
26+
* The v16 declaration shape, reconstructed so the equivalence is COMPUTED rather
27+
* than asserted twice.
28+
*
29+
* It is spelled `engine-owned`, not `system`, on purpose: v17 deleted the `system`
30+
* row from `CRUD_AFFORDANCE_DEFAULTS`, so passing the retired literal would fall
31+
* through to the `platform` default and quietly reconstruct the wrong baseline
32+
* (that mistake is what this comment exists to prevent — it read green-ish and was
33+
* wrong). ADR-0103 D5 gave `engine-owned` the byte-identical locked row `system`
34+
* carried in v16 — `{create,import,edit,delete: false, exportCsv: true}` — so it is
35+
* an exact stand-in for the old bucket default. `expect(v16).toEqual(V16_EXPECTED)`
36+
* below is the check that this stand-in stayed honest.
37+
*/
2538
const asV16 = (obj: { userActions?: unknown }) => ({
26-
managedBy: 'system',
39+
managedBy: 'engine-owned',
2740
userActions: obj.userActions ?? { create: true, edit: true, delete: true },
2841
});
2942

0 commit comments

Comments
 (0)