{"draft":null,"from":45,"to":318,"files":[{"path":"server/test/push-snapshot-batch.test.ts","added":34,"removed":0,"diff":"--- /dev/null\n+++ b/server/test/push-snapshot-batch.test.ts\n@@ -0,0 +1,34 @@\n+import assert from \"node:assert/strict\";\n+import { test } from \"node:test\";\n+import { answer } from \"../../worker/project/http.ts\";\n+import { EngineProject } from \"../src/engine-project.ts\";\n+import { pushSnapshot } from \"../src/push-snapshot.ts\";\n+import { memoryStorage } from \"./helpers.ts\";\n+\n+test(\"push batches cap file count and text while preserving exact lazy contents\", (t) => {\n+\tconst storage = memoryStorage();\n+\tt.after(() => storage.db.close());\n+\tconst project = EngineProject.open(storage);\n+\tconst files = Object.fromEntries(Array.from({ length: 130 }, (_, i) => [`f${i}`, `${i}\\n`]));\n+\tassert.equal(answer(project, \"init\", undefined, { files }).status, 200);\n+\tlet batches = 0;\n+\tconst snapshot = pushSnapshot(\n+\t\tproject.sharedPushMetadata(),\n+\t\t() => {\n+\t\t\tthrow Error(\"single read forbidden\");\n+\t\t},\n+\t\t(version, paths) => {\n+\t\t\tbatches++;\n+\t\t\treturn project.fileTextsAt(version, paths);\n+\t\t},\n+\t);\n+\tassert.equal(batches, 0);\n+\tassert.deepEqual({ ...snapshot.files }, files);\n+\tassert.equal(batches, 3);\n+\tconst large = \"x\".repeat(70000) + \"\\n\";\n+\tassert.equal(answer(project, \"record\", \"writer\", { files: { large } }).status, 200);\n+\tassert.equal(answer(project, \"publish\", \"writer\", { message: \"Large file\" }).status, 200);\n+\tconst batch = project.fileTextsAt(1, [\"large\", \"f0\"]);\n+\tassert.deepEqual(Object.keys(batch), [\"large\"]);\n+\tassert.equal(batch.large, large);\n+});"}],"unmatched":[]}