Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion record-bin/src/utils/lambdaLessCapture.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Request = {
queryParams?: {
filter: { ids: string };
nested: boolean;
version?: string;
page: { limit: number; offset: number };
};
body?: { data: ReturnType<typeof source> };
Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions record-bin/src/utils/lambdaLessCapture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
},
});
Expand Down