fix(documents): surface signedFromDocumentId + hub cleanup
Three follow-ups from Task 15 code review: 1. (Important) The aggregated files API now LEFT JOINs against documents to surface signedFromDocumentId per file row. The "view signing details" button on EntityFolderView's Files section now passes the workflow id to SigningDetailsDialog instead of the file id. Previously the button always 404'd and the dialog hung in the loading state. Drops the v1 filename-prefix heuristic. 2. (Minor) Drop dead initialTab prop + DocumentsHubTab import — leftover from the pre-refactor tab strip. 3. (Minor) FlatFolderListing remounts on folder switch via a key prop, restoring the pre-refactor typeFilter reset behaviour. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -114,6 +114,16 @@ describe('files service · listFilesAggregatedByEntity', () => {
|
||||
const yachtGroup = result.groups.find((g) => g.label.startsWith('FROM YACHT'));
|
||||
expect(yachtGroup?.source).toBe('yacht');
|
||||
});
|
||||
|
||||
it('file rows carry signedFromDocumentId=null when no workflow references them', async () => {
|
||||
const result = await listFilesAggregatedByEntity(portId, 'client', clientId);
|
||||
const directGroup = result.groups.find((g) => g.label === 'DIRECTLY ATTACHED');
|
||||
expect(directGroup).toBeDefined();
|
||||
for (const f of directGroup!.files) {
|
||||
expect(f).toHaveProperty('signedFromDocumentId');
|
||||
expect(f.signedFromDocumentId).toBeNull();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('caps each group at 20 rows + surfaces total', () => {
|
||||
@@ -213,6 +223,45 @@ describe('files service · listFilesAggregatedByEntity', () => {
|
||||
expect(result.groups).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('signedFromDocumentId reverse-link', () => {
|
||||
let portId: string;
|
||||
let clientId: string;
|
||||
|
||||
beforeEach(async () => {
|
||||
const port = await makePort();
|
||||
portId = port.id;
|
||||
|
||||
const client = await makeClient({ portId });
|
||||
clientId = client.id;
|
||||
});
|
||||
|
||||
it('surfaces signedFromDocumentId when a workflow references the file', async () => {
|
||||
const fileRow = await insertFile(portId, { clientId });
|
||||
|
||||
// Insert a document row with signedFileId pointing at the file
|
||||
const [doc] = await db
|
||||
.insert(documents)
|
||||
.values({
|
||||
portId,
|
||||
clientId,
|
||||
documentType: 'contract',
|
||||
title: 'Signed Contract',
|
||||
status: 'completed',
|
||||
signedFileId: fileRow.id,
|
||||
createdBy: TEST_USER_ID,
|
||||
})
|
||||
.returning();
|
||||
|
||||
const result = await listFilesAggregatedByEntity(portId, 'client', clientId);
|
||||
const directGroup = result.groups.find((g) => g.label === 'DIRECTLY ATTACHED');
|
||||
expect(directGroup).toBeDefined();
|
||||
|
||||
const linkedFile = directGroup!.files.find((f) => f.id === fileRow.id);
|
||||
expect(linkedFile).toBeDefined();
|
||||
expect(linkedFile!.signedFromDocumentId).toBe(doc!.id);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// ─── listInflightWorkflowsAggregatedByEntity ─────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user