forked from r.muellner/velum-raycast
fix: stream large project texts and scope API capabilities
Analyze UTF-8 text files as bounded batches of complete lines and reassemble only approved spans without loading entire files. Preserve line endings, BOM, Unicode offsets and source-change checks. Scope capability checks to selected file types, report missing features and HTTP failures, and retain the required Office image-policy handling. Cover large files, chunk boundaries, mappings and failure cleanup with regression tests.
This commit is contained in:
@@ -140,3 +140,23 @@ it("verweigert das stumme Zerschneiden eines überlangen Worts", () => {
|
||||
"ohne Trennstelle",
|
||||
);
|
||||
});
|
||||
|
||||
it("zerlegt HTTP 413 ohne bestehende Zuordnungen oder Dateigrenzen zu verlieren", async () => {
|
||||
const [batch] = makeTextBatches([{ key: "a", text: "Anna" }, { key: "b", text: "Berta" }]);
|
||||
let calls = 0;
|
||||
const result = await analyzeProjectBatch(batch, {}, ["PERSON"], {}, async (text, mapping) => {
|
||||
calls++; if (text.includes("Anna") && text.includes("Berta")) throw new Error("Velum API request failed: 413 Payload Too Large");
|
||||
return response(text, mapping);
|
||||
}, "Test");
|
||||
expect(calls).toBe(3); expect(Object.keys(result.mapping)).toHaveLength(2);
|
||||
});
|
||||
it("wiederholt Authentifizierungs- und Validierungsfehler nicht", async () => {
|
||||
const [batch] = makeTextBatches([{ key: "a", text: "Anna" }, { key: "b", text: "Berta" }]);
|
||||
for (const status of [401, 403, 422]) {
|
||||
let calls = 0;
|
||||
await expect(analyzeProjectBatch(batch, {}, ["PERSON"], {}, async () => {
|
||||
calls++; throw new Error(`Velum API request failed: ${status}`);
|
||||
}, "Test")).rejects.toThrow(String(status));
|
||||
expect(calls).toBe(1);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user