{"draft":null,"from":165,"to":166,"files":[{"path":"src/engine/test/graph-long-text.test.ts","added":22,"removed":0,"diff":"--- a/src/engine/test/graph-long-text.test.ts\n+++ b/src/engine/test/graph-long-text.test.ts\n@@ -4,6 +4,28 @@\n import { Graph } from \"../graph.ts\";\n import { SqlState } from \"./storage-helper.ts\";\n \n+test(\"large insertion text stays lazy even when the run has few lines\", (t) => {\n+\tconst storage = new SqlState();\n+\tt.after(() => storage.db.close());\n+\tconst memory = new MemoryStore();\n+\tconst line = \"x\".repeat(100000);\n+\tnew Project(memory).init({ \"a.txt\": `${line}\\n${line}\\n${line}\\n` }, 0);\n+\tconst entry = memory.entries[0]!;\n+\tif (entry.type !== \"init\") throw Error(\"expected init\");\n+\tnew Graph({ storage }).add(entry.atom);\n+\tconst read = storage.read.bind(storage);\n+\tlet textReads = 0;\n+\tt.mock.method(storage, \"read\", (collection: string, key: string) => {\n+\t\tif (collection === \"atom-text:long:chunks\") textReads++;\n+\t\treturn read(collection, key);\n+\t});\n+\tconst atom = new Graph({ storage }).atom(\"a0\");\n+\tassert.equal(atom.inserts[0]!.lines.length, 3);\n+\tassert.equal(textReads, 0, \"reading line count must not decode the complete run\");\n+\tassert.equal(atom.inserts[0]!.lines[1], line);\n+\tassert.equal(textReads, Math.ceil(line.length / 16384), \"an indexed read decodes only the selected line\");\n+});\n+\n test(\"persistent graph stores long lines in chunks and reopens exact text\", () => {\n \tconst storage = new SqlState();\n \ttry {"}],"unmatched":[]}