Skip to content

Commit f72ef4f

Browse files
committed
test(objectql): the upgrade fixture redefines a picklist and extends another package's list
1 parent b0f42b5 commit f72ef4f

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

‎packages/objectql/src/package-refused-upgrade-keeps-installed.test.ts‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ const V1 = () => ({
5050
name: PKG,
5151
namespace: NS,
5252
version: '1.0.0',
53-
objects: [object('probeup_a'), object('probeup_shared', { label: 'v1 shared' }), object('probeup_old')],
53+
objects: [
54+
object('probeup_a'),
55+
object('probeup_shared', { label: 'v1 shared' }),
56+
object('probeup_old', { fields: { title: field('Title'), tier: { type: 'select', label: 'Tier', picklist: 'probeup_tier' } } }),
57+
],
5458
apps: [app('probeup_app', 'probeup_a')],
5559
pages: [{ name: 'probeup_v1_page', type: 'app' }, { name: 'probeup_v1_record', type: 'record', object: 'probeup_a', isDefault: true }],
5660
permissions: [{ name: 'probeup_v1_ps', objects: {} }],
@@ -75,6 +79,8 @@ const V2 = (fault: Record<string, unknown> = {}) => {
7579
apps: [app('probeup_app_v2', 'probeup_new')],
7680
pages: [{ name: 'probeup_v2_page', type: 'app' }, { name: 'probeup_v2_record', type: 'record', object: 'probeup_new', isDefault: true }],
7781
permissions: [{ name: 'probeup_v2_ps', objects: {} }],
82+
picklists: [{ name: 'probeup_tier', label: 'Tier', options: [{ label: 'Gold', value: 'gold' }, { label: 'Platinum', value: 'platinum' }] }],
83+
picklistExtensions: [{ extend: 'probeup_industry', options: [{ label: 'Retail', value: 'retail' }] }],
7884
datasources: [{ name: 'probeup_ds_v2', driver: 'memory' }],
7985
...rest,
8086
};
@@ -184,8 +190,8 @@ const PART_WAY: Array<{ label: string; fault: Record<string, unknown>; code: str
184190
code: 'INVALID_METADATA', status: 422,
185191
},
186192
{
187-
label: 'a picklist repeating a value an extension already adds to it',
188-
fault: { picklistExtensions: [{ extend: 'probeup_list', options: [{ label: 'X', value: 'x' }] }], picklists: [{ name: 'probeup_list', label: 'L', options: [{ label: 'X again', value: 'x' }] }] },
193+
label: 'a picklist repeating a value another package\'s extension already adds to it',
194+
fault: { picklists: [{ name: 'probeup_tier', label: 'Tier', options: [{ label: 'Gold', value: 'gold' }, { label: 'Silver', value: 'silver' }] }] },
189195
code: 'INVALID_METADATA', status: 422,
190196
},
191197
{
@@ -194,8 +200,18 @@ const PART_WAY: Array<{ label: string; fault: Record<string, unknown>; code: str
194200
code: 'INVALID_METADATA', status: 422,
195201
},
196202
{
203+
// After the body registered whole (its picklist and its extension of
204+
// the host's list included), and after a nested object whose
205+
// record-currency amount makes the registry resolve every object.
197206
label: 'the same from a nested plugin, after the body registered',
198-
fault: { plugins: [{ name: 'probeup_inner', namespace: 'probeupinner', objects: [object('probeup_inner_thing')], picklistExtensions: [{ extend: 'probeup_industry', options: [{ label: 'Fintech', value: 'finance' }] }] }] },
207+
fault: {
208+
plugins: [{
209+
name: 'probeup_inner',
210+
namespace: 'probeupinner',
211+
objects: [object('probeup_inner_line', { fields: RECORD_AMOUNT })],
212+
picklistExtensions: [{ extend: 'probeup_industry', options: [{ label: 'Fintech', value: 'finance' }] }],
213+
}],
214+
},
199215
code: 'INVALID_METADATA', status: 422,
200216
},
201217
];
@@ -213,6 +229,8 @@ describe('[#28697] an upgrade the registry refuses part-way leaves the installed
213229
expect((engine.registry.getObject('probeup_a') as any)?.label).toBe('Tenant label');
214230
expect(Object.keys((engine.registry.getObject('probeup_old') as any)?.fields ?? {})).toContain('ext_note');
215231
expect(engine.registry.getObject('probeup_new')).toBeUndefined();
232+
expect(engine.registry.resolvePicklistOptions('probeup_industry')?.map((o) => o.value)).toEqual(['finance']);
233+
expect(((engine.registry.getObject('probeup_old') as any)?.fields?.tier?.options ?? []).map((o: any) => o.value)).toEqual(['gold', 'silver']);
216234
});
217235
}
218236
});
@@ -231,6 +249,8 @@ describe('[#28697] refused-upgrade controls', () => {
231249
expect(Object.keys((registry.getObject('probeup_old') as any)?.fields ?? {})).toContain('ext_note');
232250
expect(registry.listItems('app').map((a: any) => a.name)).toContain('probeup_app_v2');
233251
expect(engine.listDatasourceDefs().map((d) => d.name)).toContain('probeup_ds_v2');
252+
expect(registry.resolvePicklistOptions('probeup_industry')?.map((o) => o.value)).toEqual(['finance', 'retail']);
253+
expect(((registry.getObject('probeup_old') as any)?.fields?.tier?.options ?? []).map((o: any) => o.value)).toEqual(['gold', 'platinum', 'silver']);
234254
expect(registry.securityCatalogNamesHeldBy(PKG, 'permission' as any)).toEqual(['probeup_v1_ps', 'probeup_v2_ps']);
235255
expect(registry.defaultRecordPageHoldersOf('probeup_new').map((h: any) => h.page)).toEqual(['probeup_v2_record']);
236256
});

0 commit comments

Comments
 (0)