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:
@@ -6,12 +6,43 @@ import { matchDemoRoute } from "../../../apps/demo/src/mock-api.js";
|
||||
const packageJson = JSON.parse(
|
||||
readFileSync(path.resolve(process.cwd(), "package.json"), "utf8"),
|
||||
) as { version: string };
|
||||
const featureManifest = JSON.parse(
|
||||
readFileSync(path.resolve(process.cwd(), "docker/feature-manifest.json"), "utf8"),
|
||||
) as {
|
||||
bundles: {
|
||||
ocr: {
|
||||
targets: Record<string, { compressedSizeEstimate: number; extractedSizeEstimate: number }>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
async function readJson(response: Response): Promise<unknown> {
|
||||
return response.json();
|
||||
}
|
||||
|
||||
describe("demo mock API", () => {
|
||||
it("mirrors the built-in Fast tier and exact amd64 Accurate OCR estimates", async () => {
|
||||
const response = matchDemoRoute("/api/v1/features", "GET");
|
||||
const data = (await readJson(response as Response)) as {
|
||||
bundles: Array<{
|
||||
id: string;
|
||||
selectedTarget?: string;
|
||||
availableQualities?: string[];
|
||||
downloadBytes?: number;
|
||||
installedBytes?: number;
|
||||
}>;
|
||||
};
|
||||
const ocr = data.bundles.find((bundle) => bundle.id === "ocr");
|
||||
const target = featureManifest.bundles.ocr.targets["linux-amd64-cpu-py312"];
|
||||
|
||||
expect(ocr).toMatchObject({
|
||||
selectedTarget: "linux-amd64-cpu-py312",
|
||||
availableQualities: ["fast", "balanced", "best"],
|
||||
downloadBytes: target.compressedSizeEstimate,
|
||||
installedBytes: target.extractedSizeEstimate,
|
||||
});
|
||||
});
|
||||
|
||||
it("reports the same app version as the current package build", async () => {
|
||||
const response = matchDemoRoute("/api/v1/health", "GET");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user