Files
outline/server/queues/tasks/ExportJSONTask.test.ts
T
Tom Moor 495f2a5830 perf: Use follower for exports (#13617)
* perf: Use follower for exports

* fix: Skip empty attachment queries in JSON exports
2026-09-02 23:06:15 +00:00

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);
}
});
});