This commit is contained in:
Tom Moor 2021-03-22 22:23:03 -07:00
parent 059fca27b3
commit 8d8bde4b8b
2 changed files with 21 additions and 4 deletions

View File

@ -45,9 +45,9 @@ export default async function documentMover({
const [
documentJson,
fromIndex,
] = await collection.removeDocumentInStructure(document, {
] = (await collection.removeDocumentInStructure(document, {
save: false,
});
})) || [undefined, index];
// if we're reordering from within the same parent
// the original and destination collection are the same,

View File

@ -1,5 +1,5 @@
/* eslint-disable flowtype/require-valid-file-annotation */
import { buildDocument, buildCollection } from "../test/factories";
// @flow
import { buildDocument, buildCollection, buildUser } from "../test/factories";
import { flushdb, seed } from "../test/support";
import documentMover from "./documentMover";
@ -22,6 +22,23 @@ describe("documentMover", () => {
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 () => {
const { document, user, collection } = await seed();
const newDocument = await buildDocument({