closes #1784
This commit is contained in:
@ -45,9 +45,9 @@ export default async function documentMover({
|
|||||||
const [
|
const [
|
||||||
documentJson,
|
documentJson,
|
||||||
fromIndex,
|
fromIndex,
|
||||||
] = await collection.removeDocumentInStructure(document, {
|
] = (await collection.removeDocumentInStructure(document, {
|
||||||
save: false,
|
save: false,
|
||||||
});
|
})) || [undefined, index];
|
||||||
|
|
||||||
// if we're reordering from within the same parent
|
// if we're reordering from within the same parent
|
||||||
// the original and destination collection are the same,
|
// the original and destination collection are the same,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable flowtype/require-valid-file-annotation */
|
// @flow
|
||||||
import { buildDocument, buildCollection } from "../test/factories";
|
import { buildDocument, buildCollection, buildUser } from "../test/factories";
|
||||||
import { flushdb, seed } from "../test/support";
|
import { flushdb, seed } from "../test/support";
|
||||||
import documentMover from "./documentMover";
|
import documentMover from "./documentMover";
|
||||||
|
|
||||||
@ -22,6 +22,23 @@ describe("documentMover", () => {
|
|||||||
expect(response.documents.length).toEqual(1);
|
expect(response.documents.length).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not error when not in source collection documentStructure", async () => {
|
||||||
|
const user = await buildUser();
|
||||||
|
const collection = await buildCollection({ teamId: user.teamId });
|
||||||
|
const document = await buildDocument({ collectionId: collection.id });
|
||||||
|
await document.archive();
|
||||||
|
|
||||||
|
const response = await documentMover({
|
||||||
|
user,
|
||||||
|
document,
|
||||||
|
collectionId: collection.id,
|
||||||
|
ip,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response.collections.length).toEqual(1);
|
||||||
|
expect(response.documents.length).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
it("should move with children", async () => {
|
it("should move with children", async () => {
|
||||||
const { document, user, collection } = await seed();
|
const { document, user, collection } = await seed();
|
||||||
const newDocument = await buildDocument({
|
const newDocument = await buildDocument({
|
||||||
|
Reference in New Issue
Block a user