Support deleted property for collections and searches

This lays the groundwork for moving collections and searches to the
trash instead of deleting them outright. We're not doing that yet, so
the `deleted` property will never be set (except for items), but this
will allow clients from this point forward to sync collections and
searches with that property for when it's used in the future. For now,
such objects will just be hidden from the collections pane as if they
had been deleted.
This commit is contained in:
Dan Stillman 2021-01-13 00:40:13 -05:00
parent 5a4d78578b
commit e45ca4edad
16 changed files with 346 additions and 136 deletions

View file

@ -168,7 +168,31 @@ describe("Zotero.Collection", function() {
collection2.parentKey = collection3.key;
yield collection2.saveTx();
assert.isFalse(collection1.hasChildCollections());
})
});
it("should return false if all child collections are moved to trash", async function () {
var collection1 = await createDataObject('collection');
var collection2 = await createDataObject('collection', { parentID: collection1.id });
var collection3 = await createDataObject('collection', { parentID: collection1.id });
assert.isTrue(collection1.hasChildCollections());
collection2.deleted = true;
await collection2.saveTx();
assert.isTrue(collection1.hasChildCollections());
collection3.deleted = true;
await collection3.saveTx();
assert.isFalse(collection1.hasChildCollections());
});
it("should return true if child collection is in trash and includeTrashed is true", async function () {
var collection1 = await createDataObject('collection');
var collection2 = await createDataObject('collection', { parentID: collection1.id });
assert.isTrue(collection1.hasChildCollections(true));
collection2.deleted = true;
await collection2.saveTx();
assert.isTrue(collection1.hasChildCollections(true));
});
})
describe("#getChildCollections()", function () {