Skip to content

Commit db4ce28

Browse files
committed
test(runtime): pin New similar on a flow whose override is live (red)
The clone door copies the engine's body for the name, which with a live override is the pair's item declaring overrides; the copy keeps that block under a new name and the save gate refuses it. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbYmYA3GtqMUGHGQkR8
1 parent 7dae3b3 commit db4ce28

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

‎packages/runtime/src/domains/automation-flow-clone-custom-package.test.ts‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,58 @@ describe('[#28149] the default target: the copy lands in <base>.custom, switched
249249
}, 60_000);
250250
});
251251

252+
describe('[#29650, ADR-0146 D2/D4] New similar while the source\'s override is live', () => {
253+
/**
254+
* Customize the base's flow the way Studio does: ensure the pair, save the
255+
* pair's item under the base's name DECLARING the override, and arm it in
256+
* place of the base (ADR-0146 D9 item 1), so the engine's map holds the
257+
* override's body for the name, which is what `getFlow` answers the door.
258+
*/
259+
async function customize(rig: Awaited<ReturnType<typeof boot>>) {
260+
const override = {
261+
...flowOf(SOURCE),
262+
label: 'Lead follow-up (customized)',
263+
description: 'Edited in Studio after Customize.',
264+
overrides: { package: BASE.id, basedOn: BASE.version },
265+
};
266+
await rig.protocol.ensureCustomizationPackage({ basePackageId: BASE.id });
267+
await rig.protocol.saveMetaItem({ type: 'flow', name: SOURCE, item: override, packageId: PAIR } as any);
268+
rig.flows.set(SOURCE, override);
269+
return override;
270+
}
271+
272+
it('the copy is the pair\'s own item: 200, no `overrides` block, stored in the pair', async () => {
273+
const rig = await boot();
274+
const override = await customize(rig);
275+
// The override really is live and stored, so this measures a strip, not an absence.
276+
expect((await rig.rows(SOURCE)).map((r) => [r.package_id, r.item.overrides])).toEqual([[PAIR, override.overrides]]);
277+
278+
const answer = await rig.clone(SOURCE, { name: 'acme_lead_followup', label: 'Lead follow-up (ACME)' });
279+
280+
expect(answer.status, JSON.stringify(answer.body)).toBe(200);
281+
expect(answer.data.packageId).toBe(PAIR);
282+
expect(answer.data.flow).not.toHaveProperty('overrides');
283+
const copyRows = await rig.rows('acme_lead_followup');
284+
expect(copyRows.map((r) => r.package_id)).toEqual([PAIR]);
285+
expect(copyRows[0].item).not.toHaveProperty('overrides');
286+
expect(rig.flows.get('acme_lead_followup')).not.toHaveProperty('overrides');
287+
expect(answer.data.flow.status).toBe(FLOW_CLONE_STATUS);
288+
}, 60_000);
289+
290+
it('copies what the source serves: the override\'s definition, and the override stays as it was', async () => {
291+
const rig = await boot();
292+
const override = await customize(rig);
293+
294+
const answer = await rig.clone(SOURCE, { name: 'acme_lead_followup', label: 'Lead follow-up (ACME)' });
295+
296+
expect(answer.status, JSON.stringify(answer.body)).toBe(200);
297+
expect(answer.data.flow.description).toBe(override.description);
298+
// The override is untouched: still the one row in the pair, still declaring.
299+
expect((await rig.rows(SOURCE)).map((r) => [r.package_id, r.item.overrides])).toEqual([[PAIR, override.overrides]]);
300+
expect(rig.flows.get(SOURCE)).toEqual(override);
301+
}, 60_000);
302+
});
303+
252304
describe('[#28149] an explicit target: `package`', () => {
253305
it('a writable package that depends on the base takes the copy', async () => {
254306
const rig = await boot();

0 commit comments

Comments
 (0)