V1-V6 收口移动视口与 PDF 发票上传
这个提交包含在:
@@ -193,9 +193,9 @@ describe("invoicePool upload route", () => {
|
||||
|
||||
try {
|
||||
const requestPayload = buildMultipartRequest({
|
||||
filename: "invoice.png",
|
||||
contentType: "image/png",
|
||||
content: "mock-image",
|
||||
filename: "invoice.pdf",
|
||||
contentType: "application/pdf",
|
||||
content: "%PDF-1.4 mock invoice",
|
||||
fields: [["ocr_type", "vat"]],
|
||||
});
|
||||
|
||||
@@ -234,6 +234,43 @@ describe("invoicePool upload route", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects image invoice uploads because formal invoice OCR only accepts PDF", async () => {
|
||||
const { app, prisma, tempDir } = await buildApp();
|
||||
|
||||
try {
|
||||
const requestPayload = buildMultipartRequest({
|
||||
filename: "invoice.png",
|
||||
contentType: "image/png",
|
||||
content: "mock-image",
|
||||
fields: [["ocr_type", "vat"]],
|
||||
});
|
||||
|
||||
const response = await app.inject({
|
||||
method: "POST",
|
||||
url: "/api/invoice-pool/upload",
|
||||
headers: {
|
||||
authorization: "Bearer test",
|
||||
...requestPayload.headers,
|
||||
},
|
||||
payload: requestPayload.payload,
|
||||
});
|
||||
|
||||
expect(response.statusCode).toBe(400);
|
||||
expect(response.json().error).toEqual(
|
||||
expect.objectContaining({
|
||||
code: "VALID_001",
|
||||
message: "请上传 PDF 发票文件",
|
||||
details: { file: "pdf_invoice_required" },
|
||||
}),
|
||||
);
|
||||
expect(prisma.invoicePool.create).not.toHaveBeenCalled();
|
||||
expect(prisma.auditLog.create).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
await app.close();
|
||||
await fs.rm(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("reuses same-owner existing invoice instead of creating a duplicate file record", async () => {
|
||||
const existingInvoiceId = "22222222-2222-4222-8222-222222222222";
|
||||
const { app, prisma, tempDir } = await buildApp({
|
||||
|
||||
在新工单中引用
屏蔽一个用户