mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
142985c6d7
* documents.restore, documents.unarchive * documents.templatize * documents.archive * documents.unpublish * documents.create, documents.update * documents.title_change event * documents.move * documents.delete * tsc, tests * tsc * Copilot feedback --------- Co-authored-by: Tom Moor <tom@getoutline.com>
58 lines
1.6 KiB
TypeScript
58 lines
1.6 KiB
TypeScript
import { createContext } from "@server/context";
|
|
import { Revision } from "@server/models";
|
|
import { buildDocument, buildUser } from "@server/test/factories";
|
|
import RevisionsProcessor from "./RevisionsProcessor";
|
|
|
|
const ip = "127.0.0.1";
|
|
|
|
describe("documents.update.debounced", () => {
|
|
test("should create a revision", async () => {
|
|
const document = await buildDocument();
|
|
|
|
const processor = new RevisionsProcessor();
|
|
await processor.perform({
|
|
name: "documents.update.debounced",
|
|
documentId: document.id,
|
|
collectionId: document.collectionId!,
|
|
teamId: document.teamId,
|
|
actorId: document.createdById,
|
|
createdAt: new Date().toISOString(),
|
|
data: { done: true },
|
|
ip,
|
|
});
|
|
const amount = await Revision.count({
|
|
where: {
|
|
documentId: document.id,
|
|
},
|
|
});
|
|
expect(amount).toBe(1);
|
|
});
|
|
|
|
test("should not create a revision if identical to previous", async () => {
|
|
const user = await buildUser();
|
|
const document = await buildDocument({
|
|
teamId: user.teamId,
|
|
userId: user.id,
|
|
});
|
|
await Revision.createFromDocument(createContext({ user }), document);
|
|
|
|
const processor = new RevisionsProcessor();
|
|
await processor.perform({
|
|
name: "documents.update.debounced",
|
|
documentId: document.id,
|
|
collectionId: document.collectionId!,
|
|
teamId: document.teamId,
|
|
actorId: document.createdById,
|
|
createdAt: new Date().toISOString(),
|
|
data: { done: true },
|
|
ip,
|
|
});
|
|
const amount = await Revision.count({
|
|
where: {
|
|
documentId: document.id,
|
|
},
|
|
});
|
|
expect(amount).toBe(1);
|
|
});
|
|
});
|