|
30 | 30 | // reverting it through the showcase's own path removes the overlay. That is |
31 | 31 | // the undo of an ADR-0131 D6 customization, which `POST /packages/:id/revert` |
32 | 32 | // also answers for a read-only package (stored rows first), so the commit |
33 | | -// doors take no read-only guard; the last case pins it. |
| 33 | +// doors take no read-only guard. |
| 34 | +// |
| 35 | +// [#28905, ADR-0146 D1] That draft naming the read-only showcase itself is |
| 36 | +// refused now (`403 NOT_OVERRIDABLE`, naming its `.custom` pair), so a fresh |
| 37 | +// boot can no longer give the showcase such a commit; one recorded before |
| 38 | +// keeps its revert, as the commit doors still take no read-only guard. The |
| 39 | +// last case pins the refusal, then the same customization written where D1 |
| 40 | +// puts it, the showcase's pair: its commit reverts through the pair's own |
| 41 | +// path, and through no other. |
34 | 42 |
|
35 | 43 | import { describe, it, expect, beforeAll, afterAll } from 'vitest'; |
36 | 44 | import { type VerifyStack } from '@objectstack/verify'; |
37 | 45 | import { bootShowcase } from './showcase-boot.js'; |
| 46 | +import { declaredOverride, ensurePair, inPair } from './customization-pair.js'; |
38 | 47 |
|
39 | 48 | const SHOWCASE = 'com.example.showcase'; |
40 | 49 | const OVERLAY = 'showcase_task.default'; |
@@ -154,26 +163,33 @@ describe('dogfood: package commit revert and rollback act only on a commit of th |
154 | 163 | expect(await isServed('cmtpb_first')).toBe(true); |
155 | 164 | }); |
156 | 165 |
|
157 | | - it('control: a read-only package\'s overlay commit reverts through its own path, and through no other', async () => { |
158 | | - const saved = await call('PUT', `/meta/view/${OVERLAY}?mode=draft&package=${SHOWCASE}`, { |
| 166 | + it('control: the showcase\'s customization commit, in its pair, reverts through the pair\'s own path, and through no other', async () => { |
| 167 | + const view = { |
159 | 168 | name: OVERLAY, object: 'showcase_task', viewKind: 'list', label: 'Overlay probe', |
160 | 169 | config: { type: 'grid', columns: [{ field: 'title' }] }, |
161 | | - }); |
| 170 | + }; |
| 171 | + // [#28905] The draft naming the read-only showcase itself is closed, naming its pair. |
| 172 | + const named = await call('PUT', `/meta/view/${OVERLAY}?mode=draft&package=${SHOWCASE}`, view); |
| 173 | + expect(named.status, JSON.stringify(named.json)).toBe(403); |
| 174 | + expect(JSON.stringify(named.json)).toContain(`?package=${SHOWCASE}.custom`); |
| 175 | + |
| 176 | + const pair = await ensurePair(stack, admin, SHOWCASE); |
| 177 | + const saved = await call('PUT', inPair(`/meta/view/${OVERLAY}?mode=draft`, SHOWCASE), declaredOverride(view, SHOWCASE, '0.1.0')); |
162 | 178 | expect(saved.status, JSON.stringify(saved.json)).toBe(200); |
163 | | - const published = await call('POST', `/packages/${SHOWCASE}/publish-drafts`, {}); |
| 179 | + const published = await call('POST', `/packages/${pair}/publish-drafts`, {}); |
164 | 180 | expect(published.status, JSON.stringify(published.json)).toBe(200); |
165 | | - const before = await commitsOf(SHOWCASE); |
| 181 | + const before = await commitsOf(pair); |
166 | 182 | expect(before[0]).toMatchObject({ operation: 'apply', id: published.json?.data?.commitId }); |
167 | 183 |
|
168 | 184 | const cross = await call('POST', `/packages/${B}/commits/${before[0].id}/revert`, {}); |
169 | 185 | expect(cross.status, JSON.stringify(cross.json)).toBe(404); |
170 | | - expect(await commitsOf(SHOWCASE)).toEqual(before); |
| 186 | + expect(await commitsOf(pair)).toEqual(before); |
171 | 187 |
|
172 | | - const res = await call('POST', `/packages/${SHOWCASE}/commits/${before[0].id}/revert`, {}); |
| 188 | + const res = await call('POST', `/packages/${pair}/commits/${before[0].id}/revert`, {}); |
173 | 189 | expect(res.status, JSON.stringify(res.json)).toBe(200); |
174 | 190 | expect(res.json?.data).toMatchObject({ |
175 | 191 | success: true, revertedCount: 1, reverted: [{ type: 'view', name: OVERLAY, action: 'removed' }], |
176 | 192 | }); |
177 | | - expect(await commitsOf(SHOWCASE)).toHaveLength(before.length + 1); |
| 193 | + expect(await commitsOf(pair)).toHaveLength(before.length + 1); |
178 | 194 | }); |
179 | 195 | }); |
0 commit comments