diff --git a/record-bin/src/utils/lambdaLessCapture.test.ts b/record-bin/src/utils/lambdaLessCapture.test.ts index b8c05943..468b0345 100644 --- a/record-bin/src/utils/lambdaLessCapture.test.ts +++ b/record-bin/src/utils/lambdaLessCapture.test.ts @@ -45,6 +45,7 @@ type Request = { queryParams?: { filter: { ids: string }; nested: boolean; + version?: string; page: { limit: number; offset: number }; }; body?: { data: ReturnType }; @@ -63,8 +64,13 @@ function setup( batches.push({ count: ids.length, nested: queryParams.nested }); expect(queryParams.page.limit).toBe(ids.length); expect(queryParams.page.offset).toBe(0); + // Mirror the legacy list default, which omits never-published records. + const visibleIds = + queryParams.version === 'current' + ? ids + : ids.filter((id) => !id.startsWith('draft-')); return { - data: ids + data: visibleIds .map((id) => overrides.read ? overrides.read(id, queryParams.nested) @@ -180,6 +186,12 @@ describe('pre-deletion capture', () => { allowDeletion: false, }); }); + it('captures never-published records on projects listing published versions by default', async () => { + const mock = setup(); + const result = await run(['draft-1']); + expect(result.allowDeletion).toBe(true); + expect(mock.archive).toHaveLength(1); + }); it('rejects sources without version metadata', async () => { setup({ read: (id) => ({ ...source(id), meta: {} }) }); expect((await run(['one'])).allowDeletion).toBe(false); diff --git a/record-bin/src/utils/lambdaLessCapture.ts b/record-bin/src/utils/lambdaLessCapture.ts index f46bc930..678ea628 100644 --- a/record-bin/src/utils/lambdaLessCapture.ts +++ b/record-bin/src/utils/lambdaLessCapture.ts @@ -186,6 +186,8 @@ class CaptureOperation { queryParams: { filter: { ids: batch.join(',') }, nested, + // Projects without the improved items listing default to `published`, omitting drafts. + version: 'current', page: { limit: batch.length, offset: 0 }, }, });