Notes/spec/etapi/import.ts

32 lines
889 B
TypeScript
Raw Normal View History

import etapi from "../support/etapi.js";
import fs from "fs";
import path from "path";
2024-07-19 00:18:35 +03:00
import { fileURLToPath } from "url";
2024-05-03 21:18:20 +02:00
etapi.describeEtapi("import", () => {
2024-05-08 23:59:11 +02:00
// temporarily skip this test since test-export.zip is missing
xit("import", async () => {
2024-07-19 00:18:35 +03:00
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
2024-05-03 21:18:20 +02:00
const zipFileBuffer = fs.readFileSync(
2024-12-22 15:45:54 +02:00
path.resolve(scriptDir, "test-export.zip")
2024-05-03 21:18:20 +02:00
);
const response = await etapi.postEtapiContent(
2024-12-22 15:45:54 +02:00
"notes/root/import",
zipFileBuffer
2024-05-03 21:18:20 +02:00
);
expect(response.status).toEqual(201);
const { note, branch } = await response.json();
expect(note.title).toEqual("test-export");
expect(branch.parentNoteId).toEqual("root");
const content = await (
2024-12-22 15:45:54 +02:00
await etapi.getEtapiContent(`notes/${note.noteId}/content`)
2024-05-03 21:18:20 +02:00
).text();
expect(content).toContain("test export content");
});
});