Removal of non-collaborative editing code paths (#4210)

This commit is contained in:
Tom Moor
2023-03-28 22:13:42 -04:00
committed by GitHub
parent 3108a26793
commit 7ba6a9379b
27 changed files with 45 additions and 552 deletions

View File

@@ -45,15 +45,6 @@ exports[`#documents.search should require authentication 1`] = `
}
`;
exports[`#documents.update should fail if document lastRevision does not match 1`] = `
{
"error": "invalid_request",
"message": "Document has changed since last revision",
"ok": false,
"status": 400,
}
`;
exports[`#documents.update should require authentication 1`] = `
{
"error": "authentication_required",

View File

@@ -2456,7 +2456,6 @@ describe("#documents.update", () => {
id: document.id,
title: "Updated title",
text: "Updated text",
lastRevision: document.revisionCount,
},
});
const body = await res.json();
@@ -2478,7 +2477,6 @@ describe("#documents.update", () => {
id: document.id,
title: "Updated title",
text: "Updated text",
lastRevision: document.revisionCount,
publish: true,
},
});
@@ -2503,7 +2501,6 @@ describe("#documents.update", () => {
id: document.id,
title: "Updated title",
text: "Updated text",
lastRevision: document.revisionCount,
collectionId: collection.id,
publish: true,
},
@@ -2526,7 +2523,6 @@ describe("#documents.update", () => {
id: document.id,
title: "Updated title",
text: "Updated text",
lastRevision: document.revisionCount,
collectionId: collection.id,
publish: true,
},
@@ -2551,7 +2547,6 @@ describe("#documents.update", () => {
id: template.id,
title: "Updated title",
text: "Updated text",
lastRevision: template.revisionCount,
publish: true,
},
});
@@ -2582,7 +2577,6 @@ describe("#documents.update", () => {
id: document.id,
title: "Updated title",
text: "Updated text",
lastRevision: document.revisionCount,
publish: true,
},
});
@@ -2603,27 +2597,11 @@ describe("#documents.update", () => {
id: document.id,
title: "Updated title",
text: "Updated text",
lastRevision: document.revisionCount,
},
});
expect(res.status).toEqual(403);
});
it("should fail if document lastRevision does not match", async () => {
const { user, document } = await seed();
const res = await server.post("/api/documents.update", {
body: {
token: user.getJwtToken(),
id: document.id,
text: "Updated text",
lastRevision: 123,
},
});
const body = await res.json();
expect(res.status).toEqual(400);
expect(body).toMatchSnapshot();
});
it("should update document details for children", async () => {
const { user, document, collection } = await seed();
collection.documentStructure = [
@@ -2670,7 +2648,6 @@ describe("#documents.update", () => {
token: admin.getJwtToken(),
id: document.id,
text: "Changed text",
lastRevision: document.revisionCount,
},
});
const body = await res.json();
@@ -2694,7 +2671,6 @@ describe("#documents.update", () => {
token: user.getJwtToken(),
id: document.id,
text: "Changed text",
lastRevision: document.revisionCount,
},
});
expect(res.status).toEqual(403);
@@ -2709,7 +2685,6 @@ describe("#documents.update", () => {
token: user.getJwtToken(),
id: document.id,
text: "Changed text",
lastRevision: document.revisionCount,
},
});
expect(res.status).toEqual(403);
@@ -2722,7 +2697,6 @@ describe("#documents.update", () => {
token: user.getJwtToken(),
id: document.id,
text: "Additional text",
lastRevision: document.revisionCount,
append: true,
},
});
@@ -2738,7 +2712,6 @@ describe("#documents.update", () => {
body: {
token: user.getJwtToken(),
id: document.id,
lastRevision: document.revisionCount,
title: "Updated Title",
append: true,
},
@@ -2754,7 +2727,6 @@ describe("#documents.update", () => {
body: {
token: user.getJwtToken(),
id: document.id,
lastRevision: document.revisionCount,
title: "Updated Title",
text: "",
},
@@ -2770,7 +2742,6 @@ describe("#documents.update", () => {
body: {
token: user.getJwtToken(),
id: document.id,
lastRevision: document.revisionCount,
title: document.title,
text: document.text,
},
@@ -2851,7 +2822,6 @@ describe("#documents.update", () => {
id: document.id,
title: "Updated title",
text: "Updated text",
lastRevision: document.revisionCount,
collectionId: collection.id,
publish: true,
},

View File

@@ -880,7 +880,6 @@ router.post(
text,
fullWidth,
publish,
lastRevision,
templateId,
collectionId,
append,
@@ -908,10 +907,6 @@ router.post(
authorize(user, "publish", collection);
}
if (lastRevision && lastRevision !== document.revisionCount) {
throw InvalidRequestError("Document has changed since last revision");
}
collection = await sequelize.transaction(async (transaction) => {
await documentUpdater({
document,

View File

@@ -190,9 +190,6 @@ export const DocumentsUpdateSchema = BaseSchema.extend({
/** Boolean to denote if the doc should be published */
publish: z.boolean().optional(),
/** Revision to compare against document revision count */
lastRevision: z.number().optional(),
/** Doc template Id */
templateId: z.string().uuid().nullish(),