Fetch top-level items before other items when syncing
This commit is contained in:
parent
cd41609761
commit
f05b98ba20
4 changed files with 160 additions and 54 deletions
|
@ -152,13 +152,23 @@ describe("Zotero.Sync.Data.Engine", function () {
|
|||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/items?format=versions&includeTrashed=1",
|
||||
url: "users/1/items/top?format=versions&includeTrashed=1",
|
||||
status: 200,
|
||||
headers: headers,
|
||||
json: {
|
||||
"AAAAAAAA": 3
|
||||
}
|
||||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/items?format=versions&includeTrashed=1",
|
||||
status: 200,
|
||||
headers: headers,
|
||||
json: {
|
||||
"AAAAAAAA": 3,
|
||||
"BBBBBBBB": 3
|
||||
}
|
||||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/collections?format=json&collectionKey=AAAAAAAA",
|
||||
|
@ -199,6 +209,21 @@ describe("Zotero.Sync.Data.Engine", function () {
|
|||
})
|
||||
]
|
||||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/items?format=json&itemKey=BBBBBBBB&includeTrashed=1",
|
||||
status: 200,
|
||||
headers: headers,
|
||||
json: [
|
||||
makeItemJSON({
|
||||
key: "BBBBBBBB",
|
||||
version: 3,
|
||||
itemType: "note",
|
||||
parentItem: "AAAAAAAA",
|
||||
note: "This is a note."
|
||||
})
|
||||
]
|
||||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/deleted?since=0",
|
||||
|
@ -235,6 +260,13 @@ describe("Zotero.Sync.Data.Engine", function () {
|
|||
assert.equal(obj.getField('title'), 'A');
|
||||
assert.equal(obj.version, 3);
|
||||
assert.isTrue(obj.synced);
|
||||
var parentItemID = obj.id;
|
||||
|
||||
obj = yield Zotero.Items.getByLibraryAndKeyAsync(userLibraryID, "BBBBBBBB");
|
||||
assert.equal(obj.getNote(), 'This is a note.');
|
||||
assert.equal(obj.parentItemID, parentItemID);
|
||||
assert.equal(obj.version, 3);
|
||||
assert.isTrue(obj.synced);
|
||||
})
|
||||
|
||||
it("should upload new full items and subsequent patches", function* () {
|
||||
|
@ -680,6 +712,15 @@ describe("Zotero.Sync.Data.Engine", function () {
|
|||
});
|
||||
json = {};
|
||||
json[objects.item.key] = 5;
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/items/top?format=versions&includeTrashed=1",
|
||||
status: 200,
|
||||
headers: headers,
|
||||
json: json
|
||||
});
|
||||
json = {};
|
||||
json[objects.item.key] = 5;
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/items?format=versions&includeTrashed=1",
|
||||
|
@ -751,6 +792,13 @@ describe("Zotero.Sync.Data.Engine", function () {
|
|||
headers: headers,
|
||||
json: {}
|
||||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/items/top?format=versions&since=5&includeTrashed=1",
|
||||
status: 200,
|
||||
headers: headers,
|
||||
json: {}
|
||||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/deleted?since=5",
|
||||
|
@ -826,6 +874,13 @@ describe("Zotero.Sync.Data.Engine", function () {
|
|||
headers: headers,
|
||||
json: {}
|
||||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/items/top?format=versions&since=5&includeTrashed=1",
|
||||
status: 200,
|
||||
headers: headers,
|
||||
json: {}
|
||||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/items?format=versions&since=5&includeTrashed=1",
|
||||
|
@ -895,6 +950,13 @@ describe("Zotero.Sync.Data.Engine", function () {
|
|||
headers: headers,
|
||||
json: {}
|
||||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/items/top?format=versions&since=5&includeTrashed=1",
|
||||
status: 200,
|
||||
headers: headers,
|
||||
json: {}
|
||||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/items?format=versions&since=5&includeTrashed=1",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue