test(contract): seed a deleted document so Recently deleted answers with a row

The GET contract run requires every list operation to answer at least
once with a row, and the new list of deleted documents had nothing to
list. The seed now ingests a second document and tombstones it the way
the delete route does.
This commit is contained in:
Marc-André Bombeck committed 2026-10-24 22:39:19 +02:00
1 parent 8649e0413f
commit ffe41941f1
1 file changed
+31
+31
View File
@@ -708,6 +708,37 @@ export async function seedContractAccount(
});
if (ingested.kind === "stored") ids.document = ingested.document.id;
else failures.push(`document: ingest answered ${ingested.kind}`);
// A second document, deleted the way the delete route tombstones one, so
// Recently deleted answers with a row.
const deleted = await ingestDocument({
userId: CONTRACT_USER_ID,
scoped: false,
ipAddress: null,
bytes: Buffer.concat([pdf, Buffer.from("% deleted\n")]),
filename: "deleted.pdf",
title: "Deleted letter",
kind: null,
documentDate: dayKey(daysAgo(12)),
episodeIds: [],
encounterIds: [],
sourceSystem: null,
sourceId: null,
sourceInstance: null,
aiDeferred: true,
sourceKeyChecked: false,
limits: { maxFileBytes: 10 * 1024 * 1024, quotaBytes: 100 * 1024 * 1024 },
documentAi: async () => ({
available: false,
reason: "no_provider",
onDeviceAllowed: false,
}),
});
if (deleted.kind === "stored") {
await prisma.inboundDocument.update({
where: { id: deleted.document.id },
data: { deletedAt: daysAgo(2) },
});
} else failures.push(`deleted document: ingest answered ${deleted.kind}`);
// A chat about that document, as the document sheet starts one.
if (ids.document) {
const documentChat = await createConversation({