Files
outline/server/queues/tasks/DocumentUpdateTextTask.test.ts
Tom Moor 24ffffcf8a fix: Index the body of new documents without waiting for the debounce (#14337)
* fix: Index the body of new documents without waiting for the debounce

* fix: Write only derived columns when updating document text

* test: Fix event type in DocumentUpdateTextTask test
2026-10-25 17:56:58 -04:00

55 lines
1.7 KiB
TypeScript

import { Document } from "@server/models";
import { buildDocument } from "@server/test/factories";
import DocumentUpdateTextTask from "./DocumentUpdateTextTask";
describe("DocumentUpdateTextTask", () => {
it("should update the text from the content", async () => {
const document = await buildDocument({ text: "Original" });
await Document.update(
{ text: "" },
{ where: { id: document.id }, hooks: false }
);
const task = new DocumentUpdateTextTask();
await task.perform({
name: "documents.update",
documentId: document.id,
collectionId: document.collectionId!,
teamId: document.teamId,
actorId: document.createdById,
createdAt: new Date().toISOString(),
ip: "127.0.0.1",
});
const updated = await Document.unscoped().findByPk(document.id, {
rejectOnEmpty: true,
});
expect(updated.text).toEqual("Original");
});
it("should not change the revision count", async () => {
const document = await buildDocument({ text: "Original" });
const { revisionCount, updatedAt } = await Document.unscoped().findByPk(
document.id,
{ rejectOnEmpty: true }
);
const task = new DocumentUpdateTextTask();
await task.perform({
name: "documents.update",
documentId: document.id,
collectionId: document.collectionId!,
teamId: document.teamId,
actorId: document.createdById,
createdAt: new Date().toISOString(),
ip: "127.0.0.1",
});
const updated = await Document.unscoped().findByPk(document.id, {
rejectOnEmpty: true,
});
expect(updated.revisionCount).toEqual(revisionCount);
expect(updated.updatedAt).toEqual(updatedAt);
});
});