fix: Handle public attachments in Markdown export, closes #6161

This commit is contained in:
Tom Moor
2023-11-16 22:09:51 -05:00
parent 6177d6f3cb
commit 7b4bedae59
4 changed files with 49 additions and 8 deletions

View File

@@ -16,7 +16,7 @@ describe("ImportMarkdownZipTask", () => {
"..",
"test",
"fixtures",
"outline.zip"
"outline-markdown.zip"
),
cleanup: async () => {},
};
@@ -36,6 +36,37 @@ describe("ImportMarkdownZipTask", () => {
expect(response.attachments.size).toEqual(6);
}, 10000);
it("should import the documents, public attachments", async () => {
const fileOperation = await buildFileOperation();
Object.defineProperty(fileOperation, "handle", {
get() {
return {
path: path.resolve(
__dirname,
"..",
"..",
"test",
"fixtures",
"outline-markdown-public.zip"
),
cleanup: async () => {},
};
},
});
jest.spyOn(FileOperation, "findByPk").mockResolvedValue(fileOperation);
const props = {
fileOperationId: fileOperation.id,
};
const task = new ImportMarkdownZipTask();
const response = await task.perform(props);
expect(response.collections.size).toEqual(1);
expect(response.documents.size).toEqual(2);
expect(response.attachments.size).toEqual(1);
}, 10000);
it("should throw an error with corrupt zip", async () => {
const fileOperation = await buildFileOperation();
Object.defineProperty(fileOperation, "handle", {