mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
Copy fullWidth property when duplicating documents (#11980)
* Add fullWidth property copying to document duplication Agent-Logs-Url: https://github.com/wmTJc9IK0Q/outline/sessions/6f30db31-b386-4c3d-8f04-db4dacfc2cdc Co-authored-by: wmTJc9IK0Q <171362836+wmTJc9IK0Q@users.noreply.github.com> * Fix lint errors in tests Agent-Logs-Url: https://github.com/wmTJc9IK0Q/outline/sessions/6f30db31-b386-4c3d-8f04-db4dacfc2cdc Co-authored-by: wmTJc9IK0Q <171362836+wmTJc9IK0Q@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove unnecessary declaration --------- Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -200,4 +200,64 @@ describe("documentDuplicator", () => {
|
||||
);
|
||||
expect(duplicatedChild?.sourceMetadata?.fileName).toEqual("child.md");
|
||||
});
|
||||
|
||||
it("should copy fullWidth property when duplicating document", async () => {
|
||||
const user = await buildUser();
|
||||
const original = await buildDocument({
|
||||
userId: user.id,
|
||||
teamId: user.teamId,
|
||||
fullWidth: true,
|
||||
});
|
||||
|
||||
const response = await withAPIContext(user, (ctx) =>
|
||||
documentDuplicator(ctx, {
|
||||
document: original,
|
||||
collection: original.collection,
|
||||
})
|
||||
);
|
||||
|
||||
expect(response).toHaveLength(1);
|
||||
expect(response[0].fullWidth).toBe(true);
|
||||
});
|
||||
|
||||
it("should copy fullWidth property to child documents when duplicating recursively", async () => {
|
||||
const user = await buildUser();
|
||||
const collection = await buildCollection({
|
||||
teamId: user.teamId,
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
const original = await buildDocument({
|
||||
userId: user.id,
|
||||
teamId: user.teamId,
|
||||
fullWidth: true,
|
||||
collectionId: collection.id,
|
||||
});
|
||||
|
||||
await buildDocument({
|
||||
userId: user.id,
|
||||
teamId: user.teamId,
|
||||
parentDocumentId: original.id,
|
||||
fullWidth: true,
|
||||
collectionId: collection.id,
|
||||
});
|
||||
|
||||
const response = await withAPIContext(user, (ctx) =>
|
||||
documentDuplicator(ctx, {
|
||||
document: original,
|
||||
collection: original.collection,
|
||||
recursive: true,
|
||||
})
|
||||
);
|
||||
|
||||
expect(response).toHaveLength(2);
|
||||
|
||||
// Check parent document
|
||||
const duplicatedParent = response.find((doc) => !doc.parentDocumentId);
|
||||
expect(duplicatedParent?.fullWidth).toBe(true);
|
||||
|
||||
// Check child document
|
||||
const duplicatedChild = response.find((doc) => doc.parentDocumentId);
|
||||
expect(duplicatedChild?.fullWidth).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,6 +35,7 @@ export default async function documentDuplicator(
|
||||
parentDocumentId,
|
||||
icon: document.icon,
|
||||
color: document.color,
|
||||
fullWidth: document.fullWidth,
|
||||
title: title ?? document.title,
|
||||
content: ProsemirrorHelper.removeMarks(
|
||||
DocumentHelper.toProsemirror(document),
|
||||
@@ -85,6 +86,7 @@ export default async function documentDuplicator(
|
||||
parentDocumentId: duplicatedDocument.id,
|
||||
icon: childDocument.icon,
|
||||
color: childDocument.color,
|
||||
fullWidth: childDocument.fullWidth,
|
||||
title: childDocument.title,
|
||||
content: ProsemirrorHelper.removeMarks(
|
||||
DocumentHelper.toProsemirror(childDocument),
|
||||
|
||||
@@ -5634,6 +5634,69 @@ describe("#documents.memberships", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("#documents.duplicate", () => {
|
||||
it("should require authentication", async () => {
|
||||
const res = await server.post("/api/documents.duplicate");
|
||||
expect(res.status).toEqual(401);
|
||||
});
|
||||
|
||||
it("should duplicate a document with fullWidth property", async () => {
|
||||
const user = await buildUser();
|
||||
const document = await buildDocument({
|
||||
userId: user.id,
|
||||
teamId: user.teamId,
|
||||
fullWidth: true,
|
||||
});
|
||||
|
||||
const res = await server.post("/api/documents.duplicate", {
|
||||
body: {
|
||||
token: user.getJwtToken(),
|
||||
id: document.id,
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
expect(body.data.documents).toHaveLength(1);
|
||||
expect(body.data.documents[0].fullWidth).toBe(true);
|
||||
});
|
||||
|
||||
it("should duplicate child documents with fullWidth property when recursive=true", async () => {
|
||||
const user = await buildUser();
|
||||
const collection = await buildCollection({
|
||||
userId: user.id,
|
||||
teamId: user.teamId,
|
||||
});
|
||||
const parent = await buildDocument({
|
||||
userId: user.id,
|
||||
teamId: user.teamId,
|
||||
collectionId: collection.id,
|
||||
fullWidth: true,
|
||||
});
|
||||
await buildDocument({
|
||||
userId: user.id,
|
||||
teamId: user.teamId,
|
||||
collectionId: collection.id,
|
||||
parentDocumentId: parent.id,
|
||||
fullWidth: true,
|
||||
});
|
||||
|
||||
const res = await server.post("/api/documents.duplicate", {
|
||||
body: {
|
||||
token: user.getJwtToken(),
|
||||
id: parent.id,
|
||||
recursive: true,
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
expect(body.data.documents).toHaveLength(2);
|
||||
expect(body.data.documents[0].fullWidth).toBe(true);
|
||||
expect(body.data.documents[1].fullWidth).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#documents.empty_trash", () => {
|
||||
it("should require authentication", async () => {
|
||||
const res = await server.post("/api/documents.empty_trash");
|
||||
|
||||
Reference in New Issue
Block a user