feat(documents): hide completed workflows from folder views
When listDocuments is called with folderId set (including folderId=null for root-only), exclude status='completed' rows. The signed-PDF file appears in the Files section with a "view signing details" link; the workflow row would just be noise alongside the file. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -184,6 +184,10 @@ export async function listDocuments(
|
||||
} else {
|
||||
filters.push(eq(documents.folderId, query.folderId));
|
||||
}
|
||||
// When viewing a specific folder, hide completed workflows — they surface
|
||||
// via their resulting signed-PDF file row in the Files section, not the
|
||||
// Signing section.
|
||||
filters.push(ne(documents.status, 'completed'));
|
||||
}
|
||||
if (sentSince) filters.push(gte(documents.createdAt, new Date(sentSince)));
|
||||
if (sentUntil) filters.push(lte(documents.createdAt, new Date(sentUntil)));
|
||||
|
||||
@@ -126,4 +126,38 @@ describe('documents.listDocuments folder filtering', () => {
|
||||
const titles = (res.data as Array<{ title: string }>).map((d) => d.title);
|
||||
expect(titles).toEqual(['At Root']);
|
||||
});
|
||||
|
||||
it('hides completed workflows when folderId is set', async () => {
|
||||
const folder = await createFolder(portId, testUserId, { name: 'ClientFolder', parentId: null });
|
||||
await db.insert(documents).values([
|
||||
{
|
||||
portId,
|
||||
documentType: 'eoi',
|
||||
title: 'In flight',
|
||||
createdBy: testUserId,
|
||||
folderId: folder.id,
|
||||
status: 'sent',
|
||||
},
|
||||
{
|
||||
portId,
|
||||
documentType: 'eoi',
|
||||
title: 'Completed workflow',
|
||||
createdBy: testUserId,
|
||||
folderId: folder.id,
|
||||
status: 'completed',
|
||||
},
|
||||
]);
|
||||
|
||||
const res = await listDocuments(portId, {
|
||||
page: 1,
|
||||
limit: 50,
|
||||
order: 'desc',
|
||||
includeArchived: false,
|
||||
includeDescendants: false,
|
||||
folderId: folder.id,
|
||||
});
|
||||
const titles = (res.data as Array<{ title: string }>).map((d) => d.title);
|
||||
expect(titles).toContain('In flight');
|
||||
expect(titles).not.toContain('Completed workflow');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user