Skip to content

Commit fb15f13

Browse files
committed
test(dogfood): pin a refused upgrade through install-local leaving the installed version serving
1 parent f0ea834 commit fb15f13

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

‎packages/qa/dogfood/test/install-local-refused-package-leaves-nothing.dogfood.test.ts‎

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
// still reads;
1616
// 3. a refused upgrade of an installed package (v2's connector wears the
1717
// showcase's id) leaves v1 serving: its object, its app and the package at
18-
// version 1.0.0 read, and v2's new object does not.
18+
// version 1.0.0 read, and v2's new object does not;
19+
// 4. an upgrade the registry refuses part-way (v2's third object is one the
20+
// showcase owns) is refused 422 `PLUGIN_REGISTER_FAILED`, and v1 keeps
21+
// serving whole: the package at 1.0.0, its object with v1's label and the
22+
// field another installed package extends it with, its app; v2's new
23+
// object does not read.
1924
//
2025
// Boots a fixture stack of its own (the install-local plugin mounted), so it
2126
// stays out of `SHARED_SHOWCASE`.
@@ -37,6 +42,8 @@ const HOST_OBJECT = 'showcase_product';
3742
const FRESH_ID = 'com.dogfood.refusedfresh';
3843
const MIDWAY_ID = 'com.dogfood.refusedmidway';
3944
const UPGRADE_ID = 'com.dogfood.refusedupgrade';
45+
const MIDUP_ID = 'com.dogfood.refusedmidup';
46+
const MIDUP_EXTENDER_ID = 'com.dogfood.refusedmidupext';
4047

4148
const object = (name: string) => ({ name, label: name, fields: { title: { type: 'text', label: 'Title' } } });
4249
const app = (name: string, objectName: string) => ({
@@ -79,6 +86,18 @@ const UPGRADE_V2 = install(UPGRADE_ID, 'refusedupgrade', '2.0.0', {
7986
connectors: [stampedConnector('refusedupgrade_conn')],
8087
});
8188

89+
const MIDUP_V1 = install(MIDUP_ID, 'refusedmidup', '1.0.0', {
90+
objects: [{ ...object('refusedmidup_thing'), label: 'Midup v1' }],
91+
apps: [app('refusedmidup_app', 'refusedmidup_thing')],
92+
});
93+
const MIDUP_EXTENDER = install(MIDUP_EXTENDER_ID, 'refusedmidupext', '1.0.0', {
94+
objectExtensions: [{ extend: 'refusedmidup_thing', fields: { ext_note: { type: 'text', label: 'Extender note' } } }],
95+
});
96+
const MIDUP_V2 = install(MIDUP_ID, 'refusedmidup', '2.0.0', {
97+
objects: [{ ...object('refusedmidup_thing'), label: 'Midup v2' }, object('refusedmidup_new'), object(HOST_OBJECT)],
98+
apps: [app('refusedmidup_app', 'refusedmidup_thing')],
99+
});
100+
82101
type Answer = { status: number; body: any };
83102

84103
async function json(res: Response): Promise<Answer> {
@@ -120,6 +139,16 @@ describe('dogfood: a package the install refuses part-way leaves nothing of itse
120139
answers.upgradeObject = await get('/meta/object/refusedupgrade_thing');
121140
answers.upgradeApp = await get('/meta/app/refusedupgrade_app');
122141
answers.upgradeNew = await get('/meta/object/refusedupgrade_new');
142+
143+
// 4
144+
answers.midupV1 = await post(MIDUP_V1);
145+
answers.midupExtender = await post(MIDUP_EXTENDER);
146+
answers.midupV2 = await post(MIDUP_V2);
147+
answers.midupPackage = await get(`/packages/${MIDUP_ID}`);
148+
answers.midupObject = await get('/meta/object/refusedmidup_thing');
149+
answers.midupApp = await get('/meta/app/refusedmidup_app');
150+
answers.midupNew = await get('/meta/object/refusedmidup_new');
151+
answers.midupHostObject = await get(`/meta/object/${HOST_OBJECT}`);
123152
}, 300_000);
124153

125154
afterAll(async () => {
@@ -161,4 +190,21 @@ describe('dogfood: a package the install refuses part-way leaves nothing of itse
161190
expect(answers.upgradeApp.status).toBe(200);
162191
expect(answers.upgradeNew.status, shown(answers.upgradeNew)).toBe(404);
163192
});
193+
194+
it('4: an upgrade the registry refuses part-way leaves the installed version serving whole', () => {
195+
expect(answers.midupV1.status, shown(answers.midupV1)).toBe(200);
196+
expect(answers.midupExtender.status, shown(answers.midupExtender)).toBe(200);
197+
expect(answers.midupV2.status, shown(answers.midupV2)).toBe(422);
198+
expect(answers.midupV2.body?.error?.code).toBe('PLUGIN_REGISTER_FAILED');
199+
expect(answers.midupV2.body?.error?.message).toContain(`already owned by package "${HOST_PACKAGE_ID}"`);
200+
expect(answers.midupPackage.status, shown(answers.midupPackage)).toBe(200);
201+
expect(JSON.stringify(answers.midupPackage.body)).toContain('"version":"1.0.0"');
202+
expect(JSON.stringify(answers.midupPackage.body)).not.toContain('"version":"2.0.0"');
203+
expect(answers.midupObject.status, shown(answers.midupObject)).toBe(200);
204+
expect(answers.midupObject.body?.item?.label).toBe('Midup v1');
205+
expect(Object.keys(answers.midupObject.body?.item?.fields ?? {})).toContain('ext_note');
206+
expect(answers.midupApp.status).toBe(200);
207+
expect(answers.midupNew.status, shown(answers.midupNew)).toBe(404);
208+
expect(answers.midupHostObject.status).toBe(200);
209+
});
164210
});

0 commit comments

Comments
 (0)