Skip to content

Commit 900af32

Browse files
committed
test(objectql): pin the copied permission set's field keys on fields the object copy leaves named as stored
Claude-Session: https://claude.ai/code/session_01YRp5z4kK6vgYkrdH97ztsy Co-authored-by: Claude <noreply@anthropic.com>
1 parent bddb263 commit 900af32

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

‎packages/objectql/src/protocol-duplicate-package-permission-field-keys.test.ts‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,23 @@ const HIDDEN = { readable: false, editable: false };
122122
const LOCKED = { readable: true, editable: false };
123123
const OPEN = { readable: true, editable: true };
124124

125-
/** A prefixed object with a field that spells the object's own name. */
125+
/**
126+
* A prefixed object with a field that spells the renamed bare object's name.
127+
*
128+
* ⛔ No field here spells a PREFIXED object's name. The object copy's
129+
* free-text rewrite renames such a field's `name` but not its `fields` key, so
130+
* the save door's FLS lint (which reads the `name`) refuses the copied set while
131+
* the data plane still addresses the column by its key — a separate defect,
132+
* not this rule's.
133+
*/
126134
const customerBody = {
127135
name: 'dupsrc_customer', label: 'Customer', sharingModel: 'private',
128136
fields: {
129137
full_name: { name: 'full_name', type: 'text', label: 'Full name' },
130-
dupsrc_customer: { name: 'dupsrc_customer', type: 'text', label: 'Customer code' },
138+
ticket: { name: 'ticket', type: 'text', label: 'Ticket reference' },
131139
},
132140
};
133-
/** An object whose name lacks the `dupsrc_` prefix, likewise. */
141+
/** An object whose name lacks the `dupsrc_` prefix, with a field that spells its own name. */
134142
const ticketBody = {
135143
name: 'ticket', label: 'Ticket', sharingModel: 'private',
136144
fields: {
@@ -152,7 +160,7 @@ const flsBody = {
152160
},
153161
fields: {
154162
'dupsrc_customer.full_name': HIDDEN,
155-
'dupsrc_customer.dupsrc_customer': LOCKED,
163+
'dupsrc_customer.ticket': LOCKED,
156164
'ticket.title': HIDDEN,
157165
'ticket.ticket': OPEN,
158166
'dupext_account.name': LOCKED,
@@ -235,11 +243,12 @@ describe('ADR-0070 D4 — duplicatePackage re-points a copied permission set\'s
235243
it('only the object part moves: a field part that spells the object\'s name stays', async () => {
236244
const fields = await duplicate();
237245

238-
expect(fields['dupdst_customer.dupsrc_customer']).toEqual(LOCKED);
246+
// The field part spells the key's own object, and another renamed object.
239247
expect(fields['dupdst_ticket.ticket']).toEqual(OPEN);
248+
expect(fields['dupdst_customer.ticket']).toEqual(LOCKED);
240249
// NEGATIVE CONTROL: the field part was not renamed with the object.
241-
expect(fields).not.toHaveProperty(['dupdst_customer.dupdst_customer']);
242250
expect(fields).not.toHaveProperty(['dupdst_ticket.dupdst_ticket']);
251+
expect(fields).not.toHaveProperty(['dupdst_customer.dupdst_ticket']);
243252
});
244253

245254
it('a key naming an object outside the package keeps its name, and the source set is untouched', async () => {
@@ -248,8 +257,8 @@ describe('ADR-0070 D4 — duplicatePackage re-points a copied permission set\'s
248257
// NEGATIVE CONTROL: an object the package does not hold is not renamed.
249258
expect(fields['dupext_account.name']).toEqual(LOCKED);
250259
expect(Object.keys(fields).sort()).toEqual([
251-
'dupdst_customer.dupsrc_customer',
252260
'dupdst_customer.full_name',
261+
'dupdst_customer.ticket',
253262
'dupdst_ticket.ticket',
254263
'dupdst_ticket.title',
255264
'dupext_account.name',

0 commit comments

Comments
 (0)