Skip to content

Commit da5e499

Browse files
committed
test(runtime): judge the legacy pair's reads and removal on a row an earlier version stored
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2dM9PvPPB9BMVdhf2R
1 parent f446e8a commit da5e499

1 file changed

Lines changed: 26 additions & 11 deletions

File tree

‎packages/runtime/src/domains/meta-legacy-pair-served.test.ts‎

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,18 @@ async function boot() {
118118
}, res);
119119
return { status: res.statusCode, body: res.body };
120120
};
121-
return { engine, protocol, read, remove };
121+
/**
122+
* The legacy pair's declared override as an earlier version stored it: the
123+
* row itself, written straight to the store, so the reads and the removal
124+
* below are judged on a row no write gate of this version admitted.
125+
*/
126+
const seedLegacyOverride = (type: string, body: Record<string, unknown>) =>
127+
engine.insert('sys_metadata', {
128+
name: body.name, type, namespace: 'default', package_id: LEGACY_PAIR, scope: 'platform', strategy: 'merge',
129+
state: 'active', version: 1,
130+
metadata: JSON.stringify({ ...body, overrides: { package: MODULE, basedOn: '6.1.0' } }),
131+
}, { context: { isSystem: true } } as any);
132+
return { engine, protocol, read, remove, seedLegacyOverride };
122133
}
123134

124135
const itemOf = (body: any) => body?.data?.item ?? body?.data ?? body;
@@ -131,18 +142,25 @@ const listedLabel = (body: any) => {
131142
const effectiveLabel = (body: any) => (body?.data ?? body)?.effective?.label;
132143

133144
describe('[#29594] merge question 12: a legacy per-package pair of an App\'s module is honoured as before', () => {
145+
it('the pair still saves a declared override of the module\'s item (the write gate admits it)', async () => {
146+
const { protocol, read } = await boot();
147+
await protocol.saveMetaItem({
148+
type: 'dashboard', name: BOARD, packageId: LEGACY_PAIR,
149+
item: { ...board(CUSTOMIZED), overrides: { package: MODULE, basedOn: '6.1.0' } },
150+
});
151+
const byName = await read(`/meta/dashboard/${BOARD}`, { package: MODULE });
152+
expect([byName.status, labelOf(byName.body)]).toEqual([200, CUSTOMIZED]);
153+
}, 60_000);
154+
134155
it('its declared override is served at the module\'s address (by name, list, layered); it removes it, and the module\'s item is served again', async () => {
135-
const { protocol, read, remove } = await boot();
156+
const { read, remove, seedLegacyOverride } = await boot();
136157

137158
// Precondition: the module ships the board.
138159
const shipped = await read(`/meta/dashboard/${BOARD}`, { package: MODULE });
139160
expect([shipped.status, labelOf(shipped.body)], JSON.stringify(shipped.body).slice(0, 400)).toEqual([200, SHIPPED]);
140161

141162
// The legacy pair holds its declared override of the module's board.
142-
await protocol.saveMetaItem({
143-
type: 'dashboard', name: BOARD, packageId: LEGACY_PAIR,
144-
item: { ...board(CUSTOMIZED), overrides: { package: MODULE, basedOn: '6.1.0' } },
145-
});
163+
await seedLegacyOverride('dashboard', board(CUSTOMIZED));
146164

147165
const byName = await read(`/meta/dashboard/${BOARD}`, { package: MODULE });
148166
const list = await read('/meta/dashboard', { package: MODULE });
@@ -167,11 +185,8 @@ describe('[#29594] merge question 12: a legacy per-package pair of an App\'s mod
167185
}, 60_000);
168186

169187
it('a doc (no overlay channel) the legacy pair overrides is served, and its removal passes the sealed-removal refusal as the pair\'s own', async () => {
170-
const { protocol, read, remove } = await boot();
171-
await protocol.saveMetaItem({
172-
type: 'doc', name: GUIDE, packageId: LEGACY_PAIR,
173-
item: { ...guide(CUSTOMIZED), overrides: { package: MODULE, basedOn: '6.1.0' } },
174-
});
188+
const { read, remove, seedLegacyOverride } = await boot();
189+
await seedLegacyOverride('doc', guide(CUSTOMIZED));
175190
const byName = await read(`/meta/doc/${GUIDE}`, { package: MODULE });
176191
expect([byName.status, labelOf(byName.body)], JSON.stringify(byName.body).slice(0, 400)).toEqual([200, CUSTOMIZED]);
177192

0 commit comments

Comments
 (0)