fix: Templates should not be visible in collection structure
This commit is contained in:
@ -1441,6 +1441,28 @@ describe("#documents.restore", () => {
|
||||
expect(body.data.archivedAt).toEqual(null);
|
||||
});
|
||||
|
||||
it("should not add restored templates to collection structure", async () => {
|
||||
const user = await buildUser();
|
||||
const collection = await buildCollection({ teamId: user.teamId });
|
||||
const template = await buildDocument({
|
||||
teamId: user.teamId,
|
||||
collectionId: collection.id,
|
||||
template: true,
|
||||
});
|
||||
await template.archive(user.id);
|
||||
|
||||
const res = await server.post("/api/documents.restore", {
|
||||
body: { token: user.getJwtToken(), id: template.id },
|
||||
});
|
||||
const body = await res.json();
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
expect(body.data.archivedAt).toEqual(null);
|
||||
|
||||
await collection.reload();
|
||||
expect(collection.documentStructure).toEqual(null);
|
||||
});
|
||||
|
||||
it("should restore archived when previous parent is archived", async () => {
|
||||
const { user, document } = await seed();
|
||||
const childDocument = await buildDocument({
|
||||
@ -1748,6 +1770,37 @@ describe("#documents.update", () => {
|
||||
expect(body.data.text).toBe("Updated text");
|
||||
});
|
||||
|
||||
it("should not add template to collection structure when publishing", async () => {
|
||||
const user = await buildUser();
|
||||
const collection = await buildCollection({ teamId: user.teamId });
|
||||
const template = await buildDocument({
|
||||
teamId: user.teamId,
|
||||
collectionId: collection.id,
|
||||
template: true,
|
||||
publishedAt: null,
|
||||
});
|
||||
|
||||
const res = await server.post("/api/documents.update", {
|
||||
body: {
|
||||
token: user.getJwtToken(),
|
||||
id: template.id,
|
||||
title: "Updated title",
|
||||
text: "Updated text",
|
||||
lastRevision: template.revision,
|
||||
publish: true,
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
expect(body.data.title).toBe("Updated title");
|
||||
expect(body.data.text).toBe("Updated text");
|
||||
expect(body.data.publishedAt).toBeTruthy();
|
||||
|
||||
await collection.reload();
|
||||
expect(collection.documentStructure).toBe(null);
|
||||
});
|
||||
|
||||
it("should allow publishing document in private collection", async () => {
|
||||
const { user, collection, document } = await seed();
|
||||
document.publishedAt = null;
|
||||
|
Reference in New Issue
Block a user