Skip to content

Commit 2becfd6

Browse files
fix(cloud-connection): uninstalling a composed app through install-local uninstalls every package body it installed (#34418)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> Fixes #34396 Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么**:install-local 卸载一个组合包(一个 `type: app` 包加若干 `type: module` 包,ADR-0130 D4)时,按"安装时的同一个单元"卸载:安装登记的每个子包都会被撤下,扩展了其他子包对象的模块先撤,被扩展的应用后撤。 - **为什么改**:某个模块用 `objectExtensions` 扩展了应用自己的对象时,卸载应用返回 409 要求"先卸载模块",但模块没有自己的安装记录(404),包接口又把它当只读(422),结果什么都删不掉,只能去主机上删缓存文件再重启。 - **风险与回滚**:低。单包安装的卸载路径不变(原有 withdrawal 测试与新增对照测试钉住);来自另一次安装的扩展依旧被 409 拒绝且不动任何东西。回滚即 revert 本 PR。 - **先看**:`packages/cloud-connection/src/marketplace-install-local-plugin.ts` 的 `planUnitWithdrawal` 与 `handleUninstall` 中逐成员撤下的那段;`marketplace-install-local-composed-uninstall.test.ts`。 - **两分钟验证**:`pnpm --filter @objectstack/cloud-connection exec vitest run src/marketplace-install-local-composed-uninstall.test.ts`,预期 8 条全过;把插件文件换回 main 版本再跑,预期 4 条以 409 RESOURCE_CONFLICT 失败。 - **需要你做的**:无,席位落地。 ## What changes `DELETE /api/v1/marketplace/install-local/:manifestId` now uninstalls the unit the install entry installed. - **The unit.** The ledger entry's stored body is read the way the rehydrate reads it. A `packages[]` artifact yields every member id, in the reverse of the install's dependency order (`orderHydrationBatch`). A single-package entry yields its own id alone, so that path is unchanged. - **The decision, before anything moves.** The registry's one predicate, `assertPackageUninstallable`, is asked of every member while the whole unit is still registered. A new pure helper, `planUnitWithdrawal`, reads each refusal's `extenders` and `customizationPackageId`: - If every cause is another member of the same unit, the refusal sets the order instead of refusing: those members are withdrawn first, so extending modules go before the package they extend. - A cause outside the unit refuses the whole uninstall with the registry's own `409 RESOURCE_CONFLICT` sentence, as before. That includes a package of a different install and a pair this install did not deliver. So does a refusal that carries no readable causes, and a cycle of members that extend each other. - **The withdrawal.** For each member, in the planned order, the door captures the declared permission names and then withdraws the member, all synchronously with no `await` after the ledger removal. Then it withdraws each withdrawn member's object copies, restores the copies its extensions rewrote, and runs each member's uninstall cleanups under its own package id. Artifact handlers are unbound once, under the entry's id, which is where the install bound them. The `metadata:reloaded` re-sync is announced once, and only when at least one member was withdrawn. The `package_uninstall` ledger row is written once for the entry. - The uninstall guards (`runUninstallGuards`) are asked of every member, not only the entry's id. - The response shape is unchanged. `cleanups` holds the outcomes of every member, in order. No `packages/objectql` file changed: the registry's predicate and its refusal fields are read as they are. The claim's file surface allowed the split registry modules, and none needed an edit. ## Tests New `packages/cloud-connection/src/marketplace-install-local-composed-uninstall.test.ts` runs on a real `ObjectKernel` with `ObjectQLPlugin`. It installs through the door, then uninstalls. - Reporter's doors: the module's own `DELETE` answers `404 RESOURCE_NOT_FOUND`, and `isWritablePackage` answers false for it. That predicate is the one behind the package door's `422 WRITABLE_PACKAGE_REQUIRED`. Both stay true after the fix, by design. - The composed uninstall answers 200, withdraws all three members with the module before the app, and leaves no contributor on the app's object. - The module goes first even when the artifact lists it ahead of the app. Here the base order puts the app first, so this case exercises the planner. - A reinstall after the uninstall registers the unit again. - An extension from a different install: the uninstall answers `409 RESOURCE_CONFLICT` naming that package, and nothing of the unit moves. The control: after that install is uninstalled, the unit's uninstall answers 200. - A single-package install withdraws only itself. A single package extended by another install still gets the registry's 409. <details><summary>Red leg (plugin at the merged main parent cfcba53) and green leg, HEAD c965590</summary> - Red: `Tests 4 failed | 4 passed (8)`. Each failure is the reporter's refusal: `{"code":"RESOURCE_CONFLICT","message":"Uninstall the package that extends an object of \"com.probe.suite\" first (com.probe.suite.carbon), then uninstall \"com.probe.suite\" again: ... (objectExtensions, ADR-0029). ..."}: expected 409 to be 200`. - The mutation was proven on disk: the file hash equalled `cfcba53920:` + path, and `planUnitWithdrawal` occurred 0 times. The restore went through `git checkout HEAD --`, was proven by an empty `git diff HEAD`, and the hash matched the HEAD blob. - Green: `Test Files 1 passed (1) · Tests 8 passed (8)`. - Whole package, `pnpm --filter @objectstack/cloud-connection test`: `Test Files 84 passed (84) · Tests 1235 passed (1235)`. This includes the existing `marketplace-install-local-uninstall-withdrawal.test.ts` pins of the single-package order and the 409. - `pnpm --filter @objectstack/cloud-connection typecheck`: exit 0. `tsconfig.test.json` lists the new test file. </details> ## Acceptance notes - **Mixed refusal text.** If a member is extended both by another member and by a foreign package, the 409 is the registry's sentence for that member, so it also names the same-unit module among the packages to uninstall first. The decision is right (refused), but that part of the prescription has no door of its own. The sentence is the registry's, and this PR leaves it untouched. - **Same-unit dependent rules.** The uninstall guards are asked per member and cannot tell a same-unit dependent from a foreign one. Suppose a member's field, added through `objectExtensions`, is read by an active validation rule of another member of the same artifact. The runtime's dependent-rule guard would then refuse that member's uninstall. Not measured on a real artifact. The reporter's shape (a module adding fields to the app's objects) does not hit it. - **Partial withdrawal note.** The pre-check refuses everything the registry would refuse. A withdrawal that still throws for some other cause leaves that member registered, and the response `note` speaks of "the package". The operator log names the members that were withdrawn. - **Overlaps.** Before the PR, `git merge-tree` ran against the open PRs that touch `marketplace-install-local-plugin.ts`: #34403 (`claude/issue-34336-composed-bundle-seeds`) and #34316 (`claude/area-A5-33922`). Both merged with no conflict. ## Verification Local subset, at HEAD c965590. The CI-owned farm is read from this PR's check-runs. - `pnpm --filter '@objectstack/cloud-connection^...' build` (the dependency closure) ran under `os-verify-lock.sh` and ended with `VERDICT command-exit 0`. - The gate families `dispatch-gates.mjs --commands` derived for this diff: 71 derived, 70 run at exit 0, and `--ran` reconciles `71 derived, 70 run, 0 NOT-MEASURED, 1 UNRUN`. - The unrun family is `pnpm check:dual-build-cjs-loads`, NOT MEASURED locally: `PREREQUISITE NOT MET — this gate reads built output, and some package has no dist/` (39 packages unbuilt in this worktree). CI's `Lint & Repo Gates` runs it. - No exported symbol was renamed or deleted, so `check-platform-checklist --changed-from` is not owed. - No full dogfood run is owed: the title has no `!` and no `(narrowing)` arm. --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5pHNFS9mn8hS13iGyL)_ <!-- signed: repo:objectstack#1 · os-project-manager · session_01FEkQ5pHNFS9mn8hS13iGyL --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8c6ddc5 commit 2becfd6

3 files changed

Lines changed: 475 additions & 29 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/cloud-connection': patch
3+
---
4+
5+
fix(cloud-connection): uninstalling a composed app through install-local uninstalls every package body it installed
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A composed release artifact (ADR-0130 D4: one `type: app` package and `type: module` packages) installs through `POST /api/v1/marketplace/install-local` as one install entry that registers every package body. When one module declared `objectExtensions` on the app's objects, the app could not be uninstalled: `DELETE /api/v1/marketplace/install-local/APP_ID` answered `409 RESOURCE_CONFLICT` and told the operator to uninstall the module first, but the module has no install entry of its own (`404 RESOURCE_NOT_FOUND`) and the package door refuses it as read-only (`422 WRITABLE_PACKAGE_REQUIRED`). Nothing could be removed, and the only way out was deleting the cached manifest on the host and restarting.
11+
12+
The install entry's uninstall now removes the same unit its install registered. Every member is withdrawn from the running kernel, and an extension that one member contributes to another member's object decides the order instead of refusing the uninstall: the extending module goes first, then the package it extends. Each member's uninstall cleanups run for its own package id, so the permission sets of a module go with it.
13+
14+
What does not change:
15+
16+
- An extension or a paired customization package from a different install still refuses the uninstall with the registry's own `409 RESOURCE_CONFLICT`, naming that package, and nothing is removed.
17+
- A single-package install is withdrawn alone, as before.
18+
- A module of a composed artifact still has no install entry of its own and is still read-only. It is uninstalled through its artifact's entry.
Lines changed: 299 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* [ADR-0130 D4] `DELETE /api/v1/marketplace/install-local/:manifestId` of a
5+
* COMPOSED artifact uninstalls the unit its install was: every package body
6+
* the install registered, extending modules before the package they extend.
7+
*
8+
* ## The defect, read before the fix
9+
*
10+
* A composed artifact (one `type: app` package and `type: module` packages, a
11+
* module declaring `objectExtensions` on the app's objects) installs through
12+
* this door as ONE ledger entry, under the artifact's id, and registers every
13+
* body. Its uninstall asked the registry about the app alone, and the registry
14+
* refused (`409 RESOURCE_CONFLICT`, ADR-0029): the module extends an object the
15+
* app owns. The prescribed first step had no door: the module has no ledger
16+
* entry of its own (`404 RESOURCE_NOT_FOUND`), and the package door refuses a
17+
* read-only installed package (`422 WRITABLE_PACKAGE_REQUIRED`, asked through
18+
* `isWritablePackage`). Nothing could be removed.
19+
*
20+
* What this file pins, on a REAL engine and `manifest` service (an
21+
* `ObjectKernel` with `ObjectQLPlugin`):
22+
*
23+
* - the reporter's three doors, as they answered; the module's own two still
24+
* answer so after the fix, by design — the unit is uninstalled through its
25+
* install entry;
26+
* - the composed uninstall answers 200 and withdraws every member, the
27+
* extending module first, whatever order the artifact lists its bodies in;
28+
* - an extension from a DIFFERENT install still refuses the app's uninstall,
29+
* with the registry's own `409` naming that package, and nothing moves;
30+
* - a single-package install withdraws itself alone, as before.
31+
*/
32+
33+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
34+
import { existsSync, mkdtempSync, rmSync } from 'node:fs';
35+
import { tmpdir } from 'node:os';
36+
import { join } from 'node:path';
37+
// The plugin reaches `@objectstack/runtime` through a lazy `import()`; its first
38+
// load is paid here, at module top, never inside a clocked `it`.
39+
import '@objectstack/runtime';
40+
import { ObjectKernel } from '@objectstack/core';
41+
import { ObjectQLPlugin, type ObjectQL } from '@objectstack/objectql';
42+
import { isWritablePackage } from '@objectstack/metadata-protocol';
43+
import { MarketplaceInstallLocalPlugin } from './marketplace-install-local-plugin.js';
44+
import { LocalManifestSource } from './local-manifest-source.js';
45+
import { installerAuthService, withInstallerGrants } from './install-local-principal.fixtures.js';
46+
47+
type Bag = Record<string, any>;
48+
type Handler = (c: any) => Promise<any>;
49+
50+
const ROUTE = '/api/v1/marketplace/install-local';
51+
const APP = 'com.probe.suite';
52+
const MODULE = 'com.probe.suite.carbon';
53+
const OTHER_MODULE = 'com.probe.suite.reports';
54+
const ADDON = 'com.probe.addon';
55+
const OBJECT = 'probesuite_account';
56+
57+
const appBody = (): Bag => ({
58+
id: APP, name: 'probesuite', namespace: 'probesuite', version: '1.0.0', type: 'app',
59+
objects: [{ name: OBJECT, label: 'Account', fields: { name: { type: 'text' } } }],
60+
});
61+
const moduleBody = (): Bag => ({
62+
id: MODULE, name: 'probecarbon', namespace: 'probecarbon', version: '1.0.0', type: 'module',
63+
objectExtensions: [{ extend: OBJECT, fields: { carbon_score: { type: 'number' } } }],
64+
});
65+
/** A module of the same artifact that extends nothing. */
66+
const otherModuleBody = (): Bag => ({
67+
id: OTHER_MODULE, name: 'probereports', namespace: 'probereports', version: '1.0.0', type: 'module',
68+
});
69+
/**
70+
* The composed artifact: the app's body, an extending module, a module that
71+
* extends nothing. `moduleFirst` lists the extending module ahead of the app,
72+
* so the artifact's own order cannot be what puts it first on the way out.
73+
*/
74+
const composed = (opts: { moduleFirst?: boolean } = {}): Bag => ({
75+
...appBody(),
76+
packages: opts.moduleFirst
77+
? [{ manifest: moduleBody() }, { manifest: appBody() }, { manifest: otherModuleBody() }]
78+
: [{ manifest: appBody() }, { manifest: moduleBody() }, { manifest: otherModuleBody() }],
79+
});
80+
/** A package of a DIFFERENT install extending the app's object. */
81+
const addonBody = (): Bag => ({
82+
id: ADDON, name: 'probeaddon', namespace: 'probeaddon', version: '1.0.0', type: 'app',
83+
objectExtensions: [{ extend: OBJECT, fields: { addon_flag: { type: 'boolean' } } }],
84+
});
85+
86+
let dir: string;
87+
const kernels: ObjectKernel[] = [];
88+
beforeEach(() => { dir = mkdtempSync(join(tmpdir(), 'mil-composed-uninstall-')); });
89+
afterEach(async () => {
90+
while (kernels.length) {
91+
const k = kernels.pop()!;
92+
if (k.getState() === 'running') await k.shutdown();
93+
}
94+
rmSync(dir, { recursive: true, force: true });
95+
vi.restoreAllMocks();
96+
});
97+
98+
/** The plugin over a REAL engine and `manifest` service, booted to `kernel:ready`. */
99+
async function bootPlugin() {
100+
const kernel = new ObjectKernel({ logger: { level: 'silent' }, gracefulShutdown: false } as never);
101+
kernels.push(kernel);
102+
await kernel.use(new ObjectQLPlugin());
103+
await kernel.bootstrap();
104+
const ql = kernel.getService<ObjectQL>('objectql');
105+
ql.registry.logLevel = 'silent';
106+
const withdrawn: string[] = [];
107+
const uninstallPackage = ql.registry.uninstallPackage.bind(ql.registry);
108+
vi.spyOn(ql.registry, 'uninstallPackage').mockImplementation((id: string, options?: { keepBootSeed?: boolean }) => {
109+
withdrawn.push(id);
110+
return uninstallPackage(id, options);
111+
});
112+
const routes = new Map<string, Handler>();
113+
const rawApp = {
114+
get: (p: string, h: Handler) => routes.set(`GET ${p}`, h),
115+
post: (p: string, h: Handler) => routes.set(`POST ${p}`, h),
116+
delete: (p: string, h: Handler) => routes.set(`DELETE ${p}`, h),
117+
};
118+
const hooks = new Map<string, () => Promise<void>>();
119+
const services: Record<string, unknown> = {
120+
manifest: kernel.getService('manifest'),
121+
auth: installerAuthService(),
122+
objectql: withInstallerGrants({
123+
convertPackageBodyForward: (b: unknown) => ql.convertPackageBodyForward(b),
124+
registry: ql.registry,
125+
syncSchemas: async () => undefined,
126+
}),
127+
};
128+
const logger = { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() };
129+
const ctx = {
130+
hook: (e: string, h: () => Promise<void>) => hooks.set(e, h),
131+
getService: (name: string) => {
132+
if (name === 'http-server') return { getRawApp: () => rawApp };
133+
if (!(name in services)) throw new Error(`no ${name}`);
134+
return services[name];
135+
},
136+
logger,
137+
trigger: async () => undefined,
138+
};
139+
const plugin = new MarketplaceInstallLocalPlugin({ controlPlaneUrl: 'off', storageDir: dir });
140+
// Side readers that need services this harness does not carry; what is pinned is the registry and the ledger.
141+
const p = plugin as unknown as Record<string, unknown>;
142+
p.bindArtifactHandlers = async () => undefined;
143+
p.applySideEffects = async () => ({ seeded: { mode: 'none' } });
144+
p.maybeHealSampleData = async () => ({ seeded: { mode: 'none' } });
145+
await plugin.start(ctx as never);
146+
await hooks.get('kernel:ready')?.();
147+
const request = (manifestId?: string, body?: Bag) => {
148+
const json = vi.fn((payload: any, status?: number) => ({ payload, status: status ?? 200 }));
149+
return {
150+
req: {
151+
url: `http://localhost:3000${ROUTE}${manifestId ? `/${manifestId}` : ''}`,
152+
raw: new Request('http://localhost:3000/x'),
153+
json: async () => body ?? {},
154+
param: (name: string) => (name === 'manifestId' ? manifestId : undefined),
155+
},
156+
json,
157+
};
158+
};
159+
const install = async (manifest: Bag) => routes.get(`POST ${ROUTE}`)!(request(undefined, { manifest }));
160+
const uninstall = async (manifestId: string) => routes.get(`DELETE ${ROUTE}/:manifestId`)!(request(manifestId));
161+
const ledgerIds = () => new LocalManifestSource(dir).list().entries.map((e) => e.manifestId).sort();
162+
const registered = (id: string) => ql.registry.getPackage(id) !== undefined;
163+
const extenders = () => ql.registry.getObjectContributors(OBJECT)
164+
.filter((c) => c.ownership === 'extend').map((c) => String(c.packageId)).sort();
165+
const warnings = () => logger.warn.mock.calls.map((c: unknown[]) => String(c[0]));
166+
return { ql, install, uninstall, ledgerIds, registered, extenders, withdrawn, warnings };
167+
}
168+
169+
async function installComposed(opts: { moduleFirst?: boolean } = {}) {
170+
const booted = await bootPlugin();
171+
const installed = await booted.install(composed(opts));
172+
expect(installed.status, JSON.stringify(installed.payload)).toBe(200);
173+
// ONE install entry, under the artifact's id, for three registered bodies.
174+
expect(booted.ledgerIds()).toEqual([APP]);
175+
expect([APP, MODULE, OTHER_MODULE].map(booted.registered)).toEqual([true, true, true]);
176+
expect(booted.extenders()).toEqual([MODULE]);
177+
return booted;
178+
}
179+
180+
describe('[ADR-0130 D4] an install-local uninstall of a composed artifact uninstalls the unit its install was', () => {
181+
it('the module\'s own doors: no install entry of its own (404) and read-only (422\'s predicate) — and nothing moved', async () => {
182+
const booted = await installComposed();
183+
184+
const own = await booted.uninstall(MODULE);
185+
186+
expect(own.status, JSON.stringify(own.payload)).toBe(404);
187+
expect(own.payload.error.code).toBe('RESOURCE_NOT_FOUND');
188+
// `DELETE /api/v1/packages/:id` answers `422 WRITABLE_PACKAGE_REQUIRED`
189+
// exactly when this predicate is false: the installed module is not a
190+
// writable base, so the package door is not its way out.
191+
expect(isWritablePackage(booted.ql, MODULE)).toBe(false);
192+
expect(booted.ledgerIds()).toEqual([APP]);
193+
expect([APP, MODULE, OTHER_MODULE].map(booted.registered)).toEqual([true, true, true]);
194+
expect(booted.withdrawn).toEqual([]);
195+
});
196+
197+
it('DELETE of the install entry answers 200 and withdraws every member, the extending module before the app it extends', async () => {
198+
const booted = await installComposed();
199+
const warnedBefore = booted.warnings().length;
200+
201+
const res = await booted.uninstall(APP);
202+
203+
expect(res.status, JSON.stringify(res.payload)).toBe(200);
204+
expect(res.payload.success).toBe(true);
205+
expect(booted.ledgerIds()).toEqual([]);
206+
expect([APP, MODULE, OTHER_MODULE].map(booted.registered)).toEqual([false, false, false]);
207+
expect(booted.withdrawn).toHaveLength(3);
208+
expect(booted.withdrawn.indexOf(MODULE)).toBeLessThan(booted.withdrawn.indexOf(APP));
209+
expect(booted.ql.registry.getObjectContributors(OBJECT)).toEqual([]);
210+
// Every withdrawal succeeded, so none is reported as a failed outcome.
211+
expect(res.payload.data.cleanups).toEqual([]);
212+
// The uninstall itself warns of nothing (the install's own warnings are not this test's).
213+
expect(booted.warnings().slice(warnedBefore)).toEqual([]);
214+
});
215+
216+
it('the extending module goes first even when the artifact lists it ahead of the app', async () => {
217+
const booted = await installComposed({ moduleFirst: true });
218+
219+
const res = await booted.uninstall(APP);
220+
221+
expect(res.status, JSON.stringify(res.payload)).toBe(200);
222+
expect([APP, MODULE, OTHER_MODULE].map(booted.registered)).toEqual([false, false, false]);
223+
expect(booted.withdrawn.indexOf(MODULE)).toBeLessThan(booted.withdrawn.indexOf(APP));
224+
});
225+
226+
it('a reinstall after the uninstall registers the unit again — the recovery the stuck uninstall blocked', async () => {
227+
const booted = await installComposed();
228+
expect((await booted.uninstall(APP)).status).toBe(200);
229+
230+
const again = await booted.install(composed());
231+
232+
expect(again.status, JSON.stringify(again.payload)).toBe(200);
233+
expect(booted.ledgerIds()).toEqual([APP]);
234+
expect([APP, MODULE, OTHER_MODULE].map(booted.registered)).toEqual([true, true, true]);
235+
});
236+
});
237+
238+
describe('[ADR-0029] an extension from a DIFFERENT install still refuses the app\'s uninstall', () => {
239+
it('409 with the registry\'s refusal naming the other install\'s package; nothing of the unit moves', async () => {
240+
const booted = await installComposed();
241+
const addon = await booted.install(addonBody());
242+
expect(addon.status, JSON.stringify(addon.payload)).toBe(200);
243+
expect(booted.extenders()).toEqual([ADDON, MODULE]);
244+
245+
const res = await booted.uninstall(APP);
246+
247+
expect(res.status, JSON.stringify(res.payload)).toBe(409);
248+
expect(res.payload.success).toBe(false);
249+
expect(res.payload.error.code).toBe('RESOURCE_CONFLICT');
250+
expect(res.payload.error.message).toContain(ADDON);
251+
expect(booted.ledgerIds()).toEqual([ADDON, APP]);
252+
expect([APP, MODULE, OTHER_MODULE, ADDON].map(booted.registered)).toEqual([true, true, true, true]);
253+
expect(booted.extenders()).toEqual([ADDON, MODULE]);
254+
expect(booted.withdrawn).toEqual([]);
255+
});
256+
257+
it('CONTROL: once the other install is uninstalled, the unit\'s uninstall goes through', async () => {
258+
const booted = await installComposed();
259+
expect((await booted.install(addonBody())).status).toBe(200);
260+
expect((await booted.uninstall(APP)).status).toBe(409);
261+
262+
expect((await booted.uninstall(ADDON)).status).toBe(200);
263+
const res = await booted.uninstall(APP);
264+
265+
expect(res.status, JSON.stringify(res.payload)).toBe(200);
266+
expect(booted.ledgerIds()).toEqual([]);
267+
expect([APP, MODULE, OTHER_MODULE, ADDON].map(booted.registered)).toEqual([false, false, false, false]);
268+
});
269+
});
270+
271+
describe('a single-package install withdraws itself alone, as before', () => {
272+
it('one body, one withdrawal; a package of another install stays', async () => {
273+
const booted = await bootPlugin();
274+
expect((await booted.install(appBody())).status).toBe(200);
275+
expect((await booted.install(otherModuleBody())).status).toBe(200);
276+
277+
const res = await booted.uninstall(APP);
278+
279+
expect(res.status, JSON.stringify(res.payload)).toBe(200);
280+
expect(booted.withdrawn).toEqual([APP]);
281+
expect(booted.ledgerIds()).toEqual([OTHER_MODULE]);
282+
expect([APP, OTHER_MODULE].map(booted.registered)).toEqual([false, true]);
283+
expect(existsSync(join(dir, `${APP}.json`))).toBe(false);
284+
});
285+
286+
it('extended by another install: the registry\'s 409, as before', async () => {
287+
const booted = await bootPlugin();
288+
expect((await booted.install(appBody())).status).toBe(200);
289+
expect((await booted.install(addonBody())).status).toBe(200);
290+
291+
const res = await booted.uninstall(APP);
292+
293+
expect(res.status, JSON.stringify(res.payload)).toBe(409);
294+
expect(res.payload.error.code).toBe('RESOURCE_CONFLICT');
295+
expect(res.payload.error.message).toContain(ADDON);
296+
expect(booted.withdrawn).toEqual([]);
297+
expect(booted.registered(APP)).toBe(true);
298+
});
299+
});

0 commit comments

Comments
 (0)