test: cover Adaptive WebDAV in real Obsidian

This commit is contained in:
vorotamoroz
2026-08-02 07:57:16 +00:00
parent 1fb32cb625
commit d6fd2fa4c8
9 changed files with 828 additions and 10 deletions
+23
View File
@@ -0,0 +1,23 @@
import { describe, expect, it } from "vitest";
import { parseWebDAVObjectKeys, webDAVCollectionUrl } from "./webDAV.ts";
describe("WebDAV E2E helpers", () => {
it("builds an encoded collection URL below the configured endpoint", () => {
expect(
webDAVCollectionUrl({ endpoint: "http://127.0.0.1:8088/dav/" }, "Adaptive Journal/run one/").toString()
).toBe("http://127.0.0.1:8088/dav/Adaptive%20Journal/run%20one/");
});
it("extracts only flat object keys below the exact collection", () => {
const collection = new URL("http://127.0.0.1:8088/dav/run/");
const xml = `<?xml version="1.0"?>
<d:multistatus xmlns:d="DAV:">
<d:response><d:href>/dav/run/</d:href></d:response>
<d:response><d:href>/dav/run/a1~manifest.json</d:href></d:response>
<d:response><d:href>/dav/run/a1~commit~writer~1.bin</d:href></d:response>
<d:response><d:href>/dav/run/nested/ignored.bin</d:href></d:response>
<d:response><d:href>/dav/sibling/ignored.bin</d:href></d:response>
</d:multistatus>`;
expect(parseWebDAVObjectKeys(xml, collection)).toEqual(["a1~commit~writer~1.bin", "a1~manifest.json"]);
});
});