mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: make OCR portable and reliable across AMD64 and ARM64 (#519)
* fix: make OCR portable and reliable * fix: harden OCR installation portability * fix: pin OCR partials across downloads * fix: make OCR execution reliably asynchronous * fix: harden OCR portability and docs routes * fix: preserve decoder and docs safeguards
This commit is contained in:
@@ -13,6 +13,11 @@ vi.mock("@fastify/static", () => ({ default: "fastify-static-plugin" }));
|
||||
const mockMultipartPlugin = vi.fn();
|
||||
vi.mock("@fastify/multipart", () => ({ default: mockMultipartPlugin }));
|
||||
|
||||
const multipartPartsMock = vi.hoisted(() => vi.fn());
|
||||
vi.mock("../../../apps/api/src/lib/multipart-parts.js", () => ({
|
||||
multipartParts: multipartPartsMock,
|
||||
}));
|
||||
|
||||
vi.mock("node:fs", async (importOriginal) => {
|
||||
const actual = (await importOriginal()) as Record<string, unknown>;
|
||||
return {
|
||||
@@ -170,4 +175,22 @@ describe("registerUpload", () => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("forwards route-specific limits through the request.parts replacement", async () => {
|
||||
let hook: ((request: unknown) => Promise<void>) | undefined;
|
||||
const app = {
|
||||
register: vi.fn().mockResolvedValue(undefined),
|
||||
addHook: vi.fn((_name, handler) => {
|
||||
hook = handler;
|
||||
}),
|
||||
};
|
||||
await registerUpload(app as never);
|
||||
const iterator = {};
|
||||
multipartPartsMock.mockReturnValueOnce(iterator);
|
||||
const request = { isMultipart: () => true, parts: vi.fn() };
|
||||
|
||||
await hook?.(request);
|
||||
expect(request.parts({ limits: { fileSize: 1234, files: 2 } })).toBe(iterator);
|
||||
expect(multipartPartsMock).toHaveBeenCalledWith(request, { fileSize: 1234, files: 2 });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user