mirror of
https://github.com/outline/outline.git
synced 2026-11-22 05:51:43 +03:00
* perf: Use follower for exports * fix: Skip empty attachment queries in JSON exports
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import fs from "fs-extra";
|
|
import { vi } from "vitest";
|
|
import { Attachment } from "@server/models";
|
|
import {
|
|
buildCollection,
|
|
buildDocument,
|
|
buildFileOperation,
|
|
buildTeam,
|
|
buildUser,
|
|
} from "@server/test/factories";
|
|
import ExportJSONTask from "./ExportJSONTask";
|
|
|
|
describe("ExportJSONTask", () => {
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
it("should not query attachments when no attachment IDs are present", async () => {
|
|
const team = await buildTeam();
|
|
const user = await buildUser({ teamId: team.id });
|
|
const collection = await buildCollection({
|
|
teamId: team.id,
|
|
userId: user.id,
|
|
description: "No attachments",
|
|
});
|
|
const document = await buildDocument({
|
|
teamId: team.id,
|
|
userId: user.id,
|
|
collectionId: collection.id,
|
|
text: "No attachments",
|
|
});
|
|
await collection.addDocumentToStructure(document);
|
|
const fileOperation = await buildFileOperation({
|
|
teamId: team.id,
|
|
userId: user.id,
|
|
});
|
|
const findAll = vi.spyOn(Attachment, "findAll");
|
|
|
|
const filePath = await new ExportJSONTask().exportCollections(
|
|
[collection],
|
|
fileOperation
|
|
);
|
|
|
|
try {
|
|
expect(findAll).not.toHaveBeenCalled();
|
|
} finally {
|
|
await fs.remove(filePath);
|
|
}
|
|
});
|
|
});
|