Fix test breakage after 5ff2a59f87
And remove all instances of `publicationsLibraryID`
This commit is contained in:
parent
5ff2a59f87
commit
6d18b46165
8 changed files with 41 additions and 142 deletions
|
@ -5,7 +5,7 @@ describe("Zotero.Sync.Runner", function () {
|
|||
|
||||
var apiKey = Zotero.Utilities.randomString(24);
|
||||
var baseURL = "http://local.zotero/";
|
||||
var userLibraryID, publicationsLibraryID, runner, caller, server, stub, spy;
|
||||
var userLibraryID, runner, caller, server, stub, spy;
|
||||
|
||||
var responses = {
|
||||
keyInfo: {
|
||||
|
@ -120,7 +120,6 @@ describe("Zotero.Sync.Runner", function () {
|
|||
});
|
||||
|
||||
userLibraryID = Zotero.Libraries.userLibraryID;
|
||||
publicationsLibraryID = Zotero.Libraries.publicationsLibraryID;
|
||||
|
||||
Zotero.HTTP.mock = sinon.FakeXMLHttpRequest;
|
||||
server = sinon.fakeServer.create();
|
||||
|
@ -200,10 +199,10 @@ describe("Zotero.Sync.Runner", function () {
|
|||
var libraries = yield runner.checkLibraries(
|
||||
runner.getAPIClient({ apiKey }), false, responses.keyInfo.fullAccess.json
|
||||
);
|
||||
assert.lengthOf(libraries, 4);
|
||||
assert.lengthOf(libraries, 3);
|
||||
assert.sameMembers(
|
||||
libraries,
|
||||
[userLibraryID, publicationsLibraryID, group1.libraryID, group2.libraryID]
|
||||
[userLibraryID, group1.libraryID, group2.libraryID]
|
||||
);
|
||||
})
|
||||
|
||||
|
@ -234,10 +233,10 @@ describe("Zotero.Sync.Runner", function () {
|
|||
runner.getAPIClient({ apiKey }),
|
||||
false,
|
||||
responses.keyInfo.fullAccess.json,
|
||||
[userLibraryID, publicationsLibraryID]
|
||||
[userLibraryID]
|
||||
);
|
||||
assert.lengthOf(libraries, 2);
|
||||
assert.sameMembers(libraries, [userLibraryID, publicationsLibraryID]);
|
||||
assert.lengthOf(libraries, 1);
|
||||
assert.sameMembers(libraries, [userLibraryID]);
|
||||
|
||||
var libraries = yield runner.checkLibraries(
|
||||
runner.getAPIClient({ apiKey }),
|
||||
|
@ -318,8 +317,8 @@ describe("Zotero.Sync.Runner", function () {
|
|||
responses.keyInfo.fullAccess.json
|
||||
);
|
||||
|
||||
assert.lengthOf(libraries, 3);
|
||||
assert.sameMembers(libraries, [userLibraryID, publicationsLibraryID, syncedGroup.libraryID]);
|
||||
assert.lengthOf(libraries, 2);
|
||||
assert.sameMembers(libraries, [userLibraryID, syncedGroup.libraryID]);
|
||||
});
|
||||
|
||||
it("should unarchive library if available remotely", function* () {
|
||||
|
@ -346,10 +345,10 @@ describe("Zotero.Sync.Runner", function () {
|
|||
responses.keyInfo.fullAccess.json
|
||||
);
|
||||
|
||||
assert.lengthOf(libraries, 4);
|
||||
assert.lengthOf(libraries, 3);
|
||||
assert.sameMembers(
|
||||
libraries,
|
||||
[userLibraryID, publicationsLibraryID, syncedGroup.libraryID, archivedGroup.libraryID]
|
||||
[userLibraryID, syncedGroup.libraryID, archivedGroup.libraryID]
|
||||
);
|
||||
assert.isFalse(archivedGroup.archived);
|
||||
});
|
||||
|
@ -370,11 +369,11 @@ describe("Zotero.Sync.Runner", function () {
|
|||
runner.getAPIClient({ apiKey }),
|
||||
false,
|
||||
responses.keyInfo.fullAccess.json,
|
||||
[userLibraryID, publicationsLibraryID, group.libraryID]
|
||||
[userLibraryID, group.libraryID]
|
||||
);
|
||||
|
||||
assert.lengthOf(libraries, 3);
|
||||
assert.sameMembers(libraries, [userLibraryID, publicationsLibraryID, group.libraryID]);
|
||||
assert.lengthOf(libraries, 2);
|
||||
assert.sameMembers(libraries, [userLibraryID, group.libraryID]);
|
||||
});
|
||||
|
||||
it("should update outdated group metadata", function* () {
|
||||
|
@ -405,10 +404,10 @@ describe("Zotero.Sync.Runner", function () {
|
|||
|
||||
assert.ok(stub.calledTwice);
|
||||
stub.restore();
|
||||
assert.lengthOf(libraries, 4);
|
||||
assert.lengthOf(libraries, 3);
|
||||
assert.sameMembers(
|
||||
libraries,
|
||||
[userLibraryID, publicationsLibraryID, group1.libraryID, group2.libraryID]
|
||||
[userLibraryID, group1.libraryID, group2.libraryID]
|
||||
);
|
||||
|
||||
assert.equal(group1.name, groupData1.json.data.name);
|
||||
|
@ -474,7 +473,7 @@ describe("Zotero.Sync.Runner", function () {
|
|||
var libraries = yield runner.checkLibraries(
|
||||
runner.getAPIClient({ apiKey }), false, responses.keyInfo.fullAccess.json
|
||||
);
|
||||
assert.lengthOf(libraries, 4);
|
||||
assert.lengthOf(libraries, 3);
|
||||
var groupData1 = responses.groups.ownerGroup;
|
||||
var group1 = Zotero.Groups.get(groupData1.json.id);
|
||||
var groupData2 = responses.groups.memberGroup;
|
||||
|
@ -483,7 +482,7 @@ describe("Zotero.Sync.Runner", function () {
|
|||
assert.ok(group2);
|
||||
assert.sameMembers(
|
||||
libraries,
|
||||
[userLibraryID, publicationsLibraryID, group1.libraryID, group2.libraryID]
|
||||
[userLibraryID, group1.libraryID, group2.libraryID]
|
||||
);
|
||||
assert.equal(group1.name, groupData1.json.data.name);
|
||||
assert.isTrue(group1.editable);
|
||||
|
@ -505,8 +504,8 @@ describe("Zotero.Sync.Runner", function () {
|
|||
var libraries = yield runner.checkLibraries(
|
||||
runner.getAPIClient({ apiKey }), false, responses.keyInfo.fullAccess.json
|
||||
);
|
||||
assert.lengthOf(libraries, 3);
|
||||
assert.sameMembers(libraries, [userLibraryID, publicationsLibraryID, group2.libraryID]);
|
||||
assert.lengthOf(libraries, 2);
|
||||
assert.sameMembers(libraries, [userLibraryID, group2.libraryID]);
|
||||
assert.isFalse(Zotero.Groups.exists(groupData1.json.id));
|
||||
assert.isTrue(Zotero.Groups.exists(groupData2.json.id));
|
||||
})
|
||||
|
@ -541,8 +540,8 @@ describe("Zotero.Sync.Runner", function () {
|
|||
runner.getAPIClient({ apiKey }), false, responses.keyInfo.fullAccess.json
|
||||
);
|
||||
assert.equal(called, 2);
|
||||
assert.lengthOf(libraries, 2);
|
||||
assert.sameMembers(libraries, [userLibraryID, publicationsLibraryID]);
|
||||
assert.lengthOf(libraries, 1);
|
||||
assert.sameMembers(libraries, [userLibraryID]);
|
||||
// Groups should still exist but be read-only and archived
|
||||
[group1, group2].forEach((group) => {
|
||||
assert.isTrue(Zotero.Groups.exists(group.id));
|
||||
|
@ -698,43 +697,6 @@ describe("Zotero.Sync.Runner", function () {
|
|||
},
|
||||
json: []
|
||||
});
|
||||
// My Publications
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/publications/settings",
|
||||
status: 200,
|
||||
headers: {
|
||||
"Last-Modified-Version": 10
|
||||
},
|
||||
json: []
|
||||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/publications/items/top?format=versions&includeTrashed=1",
|
||||
status: 200,
|
||||
headers: {
|
||||
"Last-Modified-Version": 10
|
||||
},
|
||||
json: []
|
||||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/publications/items?format=versions&includeTrashed=1",
|
||||
status: 200,
|
||||
headers: {
|
||||
"Last-Modified-Version": 10
|
||||
},
|
||||
json: []
|
||||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/publications/deleted?since=0",
|
||||
status: 200,
|
||||
headers: {
|
||||
"Last-Modified-Version": 10
|
||||
},
|
||||
json: []
|
||||
});
|
||||
// Group library 1
|
||||
setResponse({
|
||||
method: "GET",
|
||||
|
@ -855,15 +817,6 @@ describe("Zotero.Sync.Runner", function () {
|
|||
},
|
||||
json: {}
|
||||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/publications/fulltext?format=versions",
|
||||
status: 200,
|
||||
headers: {
|
||||
"Last-Modified-Version": 10
|
||||
},
|
||||
json: {}
|
||||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "groups/1623562/fulltext?format=versions",
|
||||
|
@ -892,10 +845,6 @@ describe("Zotero.Sync.Runner", function () {
|
|||
Zotero.Libraries.getVersion(userLibraryID),
|
||||
5
|
||||
);
|
||||
assert.equal(
|
||||
Zotero.Libraries.getVersion(publicationsLibraryID),
|
||||
10
|
||||
);
|
||||
assert.equal(
|
||||
Zotero.Libraries.getVersion(Zotero.Groups.getLibraryIDFromGroupID(1623562)),
|
||||
15
|
||||
|
@ -952,7 +901,7 @@ describe("Zotero.Sync.Runner", function () {
|
|||
onError: e => { throw e },
|
||||
});
|
||||
|
||||
assert.equal(stub.callCount, 4);
|
||||
assert.equal(stub.callCount, 3);
|
||||
stub.restore();
|
||||
});
|
||||
})
|
||||
|
@ -1035,9 +984,9 @@ describe("Zotero.Sync.Runner", function () {
|
|||
});
|
||||
|
||||
it("should show the sync error icon on error", function* () {
|
||||
let pubLib = Zotero.Libraries.get(publicationsLibraryID);
|
||||
pubLib.libraryVersion = 5;
|
||||
yield pubLib.save();
|
||||
let library = Zotero.Libraries.userLibrary;
|
||||
library.libraryVersion = 5;
|
||||
yield library.save();
|
||||
|
||||
setResponse('keyInfo.fullAccess');
|
||||
setResponse('userGroups.groupVersionsEmpty');
|
||||
|
@ -1053,25 +1002,6 @@ describe("Zotero.Sync.Runner", function () {
|
|||
INVALID: true // TODO: Find a cleaner error
|
||||
}
|
||||
});
|
||||
// No publications changes
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/publications/settings?since=5",
|
||||
status: 304,
|
||||
headers: {
|
||||
"Last-Modified-Version": 5
|
||||
},
|
||||
json: {}
|
||||
});
|
||||
setResponse({
|
||||
method: "GET",
|
||||
url: "users/1/publications/fulltext?format=versions",
|
||||
status: 200,
|
||||
headers: {
|
||||
"Last-Modified-Version": 5
|
||||
},
|
||||
json: {}
|
||||
});
|
||||
|
||||
spy = sinon.spy(runner, "updateIcons");
|
||||
yield runner.sync();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue