Fix test breakage after 5ff2a59f87
And remove all instances of `publicationsLibraryID`
This commit is contained in:
parent
5ff2a59f87
commit
6d18b46165
|
@ -70,6 +70,7 @@ var ZoteroAdvancedSearch = new function() {
|
||||||
isLibrary: function () { return false; },
|
isLibrary: function () { return false; },
|
||||||
isCollection: function () { return false; },
|
isCollection: function () { return false; },
|
||||||
isSearch: function () { return true; },
|
isSearch: function () { return true; },
|
||||||
|
isPublications: () => false,
|
||||||
isFeed: () => false,
|
isFeed: () => false,
|
||||||
isShare: function () { return false; },
|
isShare: function () { return false; },
|
||||||
isTrash: function () { return false; }
|
isTrash: function () { return false; }
|
||||||
|
|
|
@ -630,7 +630,10 @@ var Zotero_Browser = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Zotero.isConnector) {
|
if (!Zotero.isConnector) {
|
||||||
if (libraryID === Zotero.Libraries.publicationsLibraryID) {
|
if (ZoteroPane.collectionsView
|
||||||
|
&& ZoteroPane.collectionsView
|
||||||
|
&& ZoteroPane.collectionsView.selectedTreeRow
|
||||||
|
&& ZoteroPane.collectionsView.selectedTreeRow.isPublications()) {
|
||||||
Zotero_Browser.progress.Translation.cannotAddToPublications();
|
Zotero_Browser.progress.Translation.cannotAddToPublications();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ Zotero.URI = new function () {
|
||||||
* @return {Zotero.Library|false}
|
* @return {Zotero.Library|false}
|
||||||
*/
|
*/
|
||||||
this.getPathLibrary = function (path) {
|
this.getPathLibrary = function (path) {
|
||||||
let matches = path.match(/^\/\/?users\/(\d+)(\/publications)?/);
|
let matches = path.match(/^\/\/?users\/(\d+));
|
||||||
if (matches) {
|
if (matches) {
|
||||||
let userID = matches[1];
|
let userID = matches[1];
|
||||||
let currentUserID = Zotero.Users.getCurrentUserID();
|
let currentUserID = Zotero.Users.getCurrentUserID();
|
||||||
|
@ -132,9 +132,6 @@ Zotero.URI = new function () {
|
||||||
+ `(${userID} != ${currentUserID})`);
|
+ `(${userID} != ${currentUserID})`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (matches[2]) {
|
|
||||||
return Zotero.Libraries.get(Zotero.Libraries.publicationsLibraryID);
|
|
||||||
}
|
|
||||||
return Zotero.Libraries.userLibrary;
|
return Zotero.Libraries.userLibrary;
|
||||||
}
|
}
|
||||||
matches = path.match(/^\/groups\/(\d+)/);
|
matches = path.match(/^\/groups\/(\d+)/);
|
||||||
|
@ -365,9 +362,7 @@ Zotero.URI = new function () {
|
||||||
let library;
|
let library;
|
||||||
if (uriParts[1] == 'users') {
|
if (uriParts[1] == 'users') {
|
||||||
let type = uriParts[4];
|
let type = uriParts[4];
|
||||||
if (type == 'publications') {
|
if (!type) {
|
||||||
library = Zotero.Libraries.get(Zotero.Libraries.publicationsLibraryID);
|
|
||||||
} else if (!type) {
|
|
||||||
// Handles local and synced libraries
|
// Handles local and synced libraries
|
||||||
library = Zotero.Libraries.get(Zotero.Libraries.userLibraryID);
|
library = Zotero.Libraries.get(Zotero.Libraries.userLibraryID);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -190,7 +190,7 @@ describe("Zotero_Browser", function () {
|
||||||
yield deferred.promise;
|
yield deferred.promise;
|
||||||
|
|
||||||
yield loadZoteroPane(win);
|
yield loadZoteroPane(win);
|
||||||
yield selectLibrary(win, Zotero.Libraries.publicationsLibraryID);
|
yield win.ZoteroPane.collectionsView.selectByID("P" + Zotero.Libraries.userLibraryID);
|
||||||
|
|
||||||
var promise = waitForDialog(function (dialog) {
|
var promise = waitForDialog(function (dialog) {
|
||||||
assert.include(
|
assert.include(
|
||||||
|
@ -212,7 +212,7 @@ describe("Zotero_Browser", function () {
|
||||||
yield deferred.promise;
|
yield deferred.promise;
|
||||||
|
|
||||||
yield loadZoteroPane(win);
|
yield loadZoteroPane(win);
|
||||||
yield selectLibrary(win, Zotero.Libraries.publicationsLibraryID);
|
yield win.ZoteroPane.collectionsView.selectByID("P" + Zotero.Libraries.userLibraryID);
|
||||||
|
|
||||||
var promise = waitForDialog(function (dialog) {
|
var promise = waitForDialog(function (dialog) {
|
||||||
assert.include(
|
assert.include(
|
||||||
|
|
|
@ -5,7 +5,6 @@ describe("Zotero.Libraries", function() {
|
||||||
before(function* () {
|
before(function* () {
|
||||||
builtInLibraries = [
|
builtInLibraries = [
|
||||||
Zotero.Libraries.userLibraryID,
|
Zotero.Libraries.userLibraryID,
|
||||||
Zotero.Libraries.publicationsLibraryID
|
|
||||||
];
|
];
|
||||||
|
|
||||||
group = yield createGroup({ name: groupName });
|
group = yield createGroup({ name: groupName });
|
||||||
|
@ -16,11 +15,6 @@ describe("Zotero.Libraries", function() {
|
||||||
assert(Number.isInteger(Zotero.Libraries.userLibraryID), ".userLibraryID is an integer");
|
assert(Number.isInteger(Zotero.Libraries.userLibraryID), ".userLibraryID is an integer");
|
||||||
assert.isAbove(Zotero.Libraries.userLibraryID, 0);
|
assert.isAbove(Zotero.Libraries.userLibraryID, 0);
|
||||||
});
|
});
|
||||||
it("should provide publications library ID as .publicationsLibraryID", function() {
|
|
||||||
assert.isDefined(Zotero.Libraries.publicationsLibraryID);
|
|
||||||
assert(Number.isInteger(Zotero.Libraries.publicationsLibraryID), ".publicationsLibraryID is an integer");
|
|
||||||
assert.isAbove(Zotero.Libraries.publicationsLibraryID, 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("#getAll()", function() {
|
describe("#getAll()", function() {
|
||||||
it("should return an array of Zotero.Library instances", function() {
|
it("should return an array of Zotero.Library instances", function() {
|
||||||
|
@ -43,7 +37,6 @@ describe("Zotero.Libraries", function() {
|
||||||
|
|
||||||
// Check sort
|
// Check sort
|
||||||
assert.equal(ids[0], Zotero.Libraries.userLibraryID);
|
assert.equal(ids[0], Zotero.Libraries.userLibraryID);
|
||||||
assert.equal(ids[1], Zotero.Libraries.publicationsLibraryID);
|
|
||||||
|
|
||||||
var last = "";
|
var last = "";
|
||||||
var collation = Zotero.getLocaleCollation();
|
var collation = Zotero.getLocaleCollation();
|
||||||
|
@ -76,7 +69,6 @@ describe("Zotero.Libraries", function() {
|
||||||
describe("#getName()", function() {
|
describe("#getName()", function() {
|
||||||
it("should return correct library name for built-in libraries", function() {
|
it("should return correct library name for built-in libraries", function() {
|
||||||
assert.equal(Zotero.Libraries.getName(Zotero.Libraries.userLibraryID), Zotero.getString('pane.collections.library'), "user library name is correct");
|
assert.equal(Zotero.Libraries.getName(Zotero.Libraries.userLibraryID), Zotero.getString('pane.collections.library'), "user library name is correct");
|
||||||
assert.equal(Zotero.Libraries.getName(Zotero.Libraries.publicationsLibraryID), Zotero.getString('pane.collections.publications'), "publications library name is correct");
|
|
||||||
});
|
});
|
||||||
it("should return correct name for a group library", function() {
|
it("should return correct name for a group library", function() {
|
||||||
assert.equal(Zotero.Libraries.getName(group.libraryID), groupName);
|
assert.equal(Zotero.Libraries.getName(group.libraryID), groupName);
|
||||||
|
@ -88,7 +80,6 @@ describe("Zotero.Libraries", function() {
|
||||||
describe("#getType()", function() {
|
describe("#getType()", function() {
|
||||||
it("should return correct library type for built-in libraries", function() {
|
it("should return correct library type for built-in libraries", function() {
|
||||||
assert.equal(Zotero.Libraries.getType(Zotero.Libraries.userLibraryID), 'user', "user library type is correct");
|
assert.equal(Zotero.Libraries.getType(Zotero.Libraries.userLibraryID), 'user', "user library type is correct");
|
||||||
assert.equal(Zotero.Libraries.getType(Zotero.Libraries.publicationsLibraryID), 'publications', "publications library type is correct");
|
|
||||||
});
|
});
|
||||||
it("should return correct library type for a group library", function() {
|
it("should return correct library type for a group library", function() {
|
||||||
assert.equal(Zotero.Libraries.getType(group.libraryID), 'group');
|
assert.equal(Zotero.Libraries.getType(group.libraryID), 'group');
|
||||||
|
@ -101,9 +92,6 @@ describe("Zotero.Libraries", function() {
|
||||||
it("should always return true for user library", function() {
|
it("should always return true for user library", function() {
|
||||||
assert.isTrue(Zotero.Libraries.isEditable(Zotero.Libraries.userLibraryID));
|
assert.isTrue(Zotero.Libraries.isEditable(Zotero.Libraries.userLibraryID));
|
||||||
});
|
});
|
||||||
it("should always return true for publications library", function() {
|
|
||||||
assert.isTrue(Zotero.Libraries.isEditable(Zotero.Libraries.publicationsLibraryID));
|
|
||||||
});
|
|
||||||
it("should return correct state for a group library", function* () {
|
it("should return correct state for a group library", function* () {
|
||||||
group.editable = true;
|
group.editable = true;
|
||||||
yield group.saveTx();
|
yield group.saveTx();
|
||||||
|
@ -209,7 +197,6 @@ describe("Zotero.Libraries", function() {
|
||||||
describe("#hasTrash()", function() {
|
describe("#hasTrash()", function() {
|
||||||
it("should return true for all library types", function() {
|
it("should return true for all library types", function() {
|
||||||
assert.isTrue(Zotero.Libraries.hasTrash(Zotero.Libraries.userLibraryID));
|
assert.isTrue(Zotero.Libraries.hasTrash(Zotero.Libraries.userLibraryID));
|
||||||
assert.isTrue(Zotero.Libraries.hasTrash(Zotero.Libraries.publicationsLibraryID));
|
|
||||||
assert.isTrue(Zotero.Libraries.hasTrash(group.libraryID));
|
assert.isTrue(Zotero.Libraries.hasTrash(group.libraryID));
|
||||||
});
|
});
|
||||||
it("should throw for invalid library ID", function() {
|
it("should throw for invalid library ID", function() {
|
||||||
|
|
|
@ -92,12 +92,9 @@ describe("Zotero.Library", function() {
|
||||||
assert.equal((yield Zotero.DB.valueQueryAsync("SELECT filesEditable FROM libraries WHERE libraryID=?", library.libraryID)), 0)
|
assert.equal((yield Zotero.DB.valueQueryAsync("SELECT filesEditable FROM libraries WHERE libraryID=?", library.libraryID)), 0)
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not be settable for user and publications libraries", function* () {
|
it("should not be settable for user libraries", function* () {
|
||||||
let library = Zotero.Libraries.get(Zotero.Libraries.userLibraryID);
|
let library = Zotero.Libraries.get(Zotero.Libraries.userLibraryID);
|
||||||
assert.throws(function() {library.editable = false}, /^Cannot change _libraryEditable for user library$/, "does not allow setting user library as not editable");
|
assert.throws(function() {library.editable = false}, /^Cannot change _libraryEditable for user library$/, "does not allow setting user library as not editable");
|
||||||
|
|
||||||
library = Zotero.Libraries.get(Zotero.Libraries.publicationsLibraryID);
|
|
||||||
assert.throws(function() {library.editable = false}, /^Cannot change _libraryEditable for publications library$/, "does not allow setting publications library as not editable");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -106,10 +103,6 @@ describe("Zotero.Library", function() {
|
||||||
assert.isTrue(Zotero.Libraries.userLibrary.filesEditable);
|
assert.isTrue(Zotero.Libraries.userLibrary.filesEditable);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should always return true for publications library", function() {
|
|
||||||
assert.isTrue(Zotero.Libraries.get(Zotero.Libraries.publicationsLibraryID).filesEditable);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should return files editable status", function() {
|
it("should return files editable status", function() {
|
||||||
let library = Zotero.Libraries.get(Zotero.Libraries.userLibraryID);
|
let library = Zotero.Libraries.get(Zotero.Libraries.userLibraryID);
|
||||||
assert.isTrue(library.filesEditable, 'user library is files editable');
|
assert.isTrue(library.filesEditable, 'user library is files editable');
|
||||||
|
@ -127,12 +120,9 @@ describe("Zotero.Library", function() {
|
||||||
assert.isFalse(Zotero.Libraries.isFilesEditable(library.libraryID), "sets files editable in cache to false");
|
assert.isFalse(Zotero.Libraries.isFilesEditable(library.libraryID), "sets files editable in cache to false");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not be settable for user and publications libraries", function* () {
|
it("should not be settable for user libraries", function* () {
|
||||||
let library = Zotero.Libraries.get(Zotero.Libraries.userLibraryID);
|
let library = Zotero.Libraries.get(Zotero.Libraries.userLibraryID);
|
||||||
assert.throws(function() {library.filesEditable = false}, /^Cannot change _libraryFilesEditable for user library$/, "does not allow setting user library as not files editable");
|
assert.throws(function() {library.filesEditable = false}, /^Cannot change _libraryFilesEditable for user library$/, "does not allow setting user library as not files editable");
|
||||||
|
|
||||||
library = Zotero.Libraries.get(Zotero.Libraries.publicationsLibraryID);
|
|
||||||
assert.throws(function() {library.filesEditable = false}, /^Cannot change _libraryFilesEditable for publications library$/, "does not allow setting publications library as not files editable");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -153,12 +143,9 @@ describe("Zotero.Library", function() {
|
||||||
assert.equal((yield Zotero.DB.valueQueryAsync("SELECT archived FROM libraries WHERE libraryID=?", library.libraryID)), 0)
|
assert.equal((yield Zotero.DB.valueQueryAsync("SELECT archived FROM libraries WHERE libraryID=?", library.libraryID)), 0)
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not be settable for user and publications libraries", function* () {
|
it("should not be settable for user libraries", function* () {
|
||||||
let library = Zotero.Libraries.get(Zotero.Libraries.userLibraryID);
|
let library = Zotero.Libraries.get(Zotero.Libraries.userLibraryID);
|
||||||
assert.throws(() => library.archived = true, /^Cannot change _libraryArchived for user library$/, "does not allow setting user library as archived");
|
assert.throws(() => library.archived = true, /^Cannot change _libraryArchived for user library$/, "does not allow setting user library as archived");
|
||||||
|
|
||||||
library = Zotero.Libraries.get(Zotero.Libraries.publicationsLibraryID);
|
|
||||||
assert.throws(() => library.archived = true, /^Cannot change _libraryArchived for publications library$/, "does not allow setting publications library as archived");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should only be settable on read-only library", function* () {
|
it("should only be settable on read-only library", function* () {
|
||||||
|
@ -231,9 +218,6 @@ describe("Zotero.Library", function() {
|
||||||
it("should not allow erasing permanent libraries", function* () {
|
it("should not allow erasing permanent libraries", function* () {
|
||||||
let library = Zotero.Libraries.get(Zotero.Libraries.userLibraryID);
|
let library = Zotero.Libraries.get(Zotero.Libraries.userLibraryID);
|
||||||
yield assert.isRejected(library.eraseTx(), /^Error: Cannot erase library of type 'user'$/, "does not allow erasing user library");
|
yield assert.isRejected(library.eraseTx(), /^Error: Cannot erase library of type 'user'$/, "does not allow erasing user library");
|
||||||
|
|
||||||
library = Zotero.Libraries.get(Zotero.Libraries.publicationsLibraryID);
|
|
||||||
yield assert.isRejected(library.eraseTx(), /^Error: Cannot erase library of type 'publications'$/, "does not allow erasing publications library");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not allow erasing unsaved libraries", function* () {
|
it("should not allow erasing unsaved libraries", function* () {
|
||||||
|
|
|
@ -649,7 +649,7 @@ describe("Zotero.Sync.Data.Local", function() {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should roll back partial object changes on error", function* () {
|
it("should roll back partial object changes on error", function* () {
|
||||||
var libraryID = Zotero.Libraries.publicationsLibraryID;
|
var libraryID = Zotero.Libraries.userLibraryID;
|
||||||
var key1 = "AAAAAAAA";
|
var key1 = "AAAAAAAA";
|
||||||
var key2 = "BBBBBBBB";
|
var key2 = "BBBBBBBB";
|
||||||
var json = [
|
var json = [
|
||||||
|
@ -669,9 +669,8 @@ describe("Zotero.Sync.Data.Local", function() {
|
||||||
data: {
|
data: {
|
||||||
key: key2,
|
key: key2,
|
||||||
version: 1,
|
version: 1,
|
||||||
itemType: "journalArticle",
|
itemType: "invalidType",
|
||||||
title: "Test B",
|
title: "Test B"
|
||||||
deleted: true // Not allowed in My Publications
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -693,7 +692,7 @@ describe("Zotero.Sync.Data.Local", function() {
|
||||||
|
|
||||||
before(function* () {
|
before(function* () {
|
||||||
lib1 = Zotero.Libraries.userLibraryID;
|
lib1 = Zotero.Libraries.userLibraryID;
|
||||||
lib2 = Zotero.Libraries.publicationsLibraryID;
|
lib2 = (yield getGroup()).libraryID;
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function* () {
|
beforeEach(function* () {
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
|
|
||||||
var apiKey = Zotero.Utilities.randomString(24);
|
var apiKey = Zotero.Utilities.randomString(24);
|
||||||
var baseURL = "http://local.zotero/";
|
var baseURL = "http://local.zotero/";
|
||||||
var userLibraryID, publicationsLibraryID, runner, caller, server, stub, spy;
|
var userLibraryID, runner, caller, server, stub, spy;
|
||||||
|
|
||||||
var responses = {
|
var responses = {
|
||||||
keyInfo: {
|
keyInfo: {
|
||||||
|
@ -120,7 +120,6 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
userLibraryID = Zotero.Libraries.userLibraryID;
|
userLibraryID = Zotero.Libraries.userLibraryID;
|
||||||
publicationsLibraryID = Zotero.Libraries.publicationsLibraryID;
|
|
||||||
|
|
||||||
Zotero.HTTP.mock = sinon.FakeXMLHttpRequest;
|
Zotero.HTTP.mock = sinon.FakeXMLHttpRequest;
|
||||||
server = sinon.fakeServer.create();
|
server = sinon.fakeServer.create();
|
||||||
|
@ -200,10 +199,10 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
var libraries = yield runner.checkLibraries(
|
var libraries = yield runner.checkLibraries(
|
||||||
runner.getAPIClient({ apiKey }), false, responses.keyInfo.fullAccess.json
|
runner.getAPIClient({ apiKey }), false, responses.keyInfo.fullAccess.json
|
||||||
);
|
);
|
||||||
assert.lengthOf(libraries, 4);
|
assert.lengthOf(libraries, 3);
|
||||||
assert.sameMembers(
|
assert.sameMembers(
|
||||||
libraries,
|
libraries,
|
||||||
[userLibraryID, publicationsLibraryID, group1.libraryID, group2.libraryID]
|
[userLibraryID, group1.libraryID, group2.libraryID]
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -234,10 +233,10 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
runner.getAPIClient({ apiKey }),
|
runner.getAPIClient({ apiKey }),
|
||||||
false,
|
false,
|
||||||
responses.keyInfo.fullAccess.json,
|
responses.keyInfo.fullAccess.json,
|
||||||
[userLibraryID, publicationsLibraryID]
|
[userLibraryID]
|
||||||
);
|
);
|
||||||
assert.lengthOf(libraries, 2);
|
assert.lengthOf(libraries, 1);
|
||||||
assert.sameMembers(libraries, [userLibraryID, publicationsLibraryID]);
|
assert.sameMembers(libraries, [userLibraryID]);
|
||||||
|
|
||||||
var libraries = yield runner.checkLibraries(
|
var libraries = yield runner.checkLibraries(
|
||||||
runner.getAPIClient({ apiKey }),
|
runner.getAPIClient({ apiKey }),
|
||||||
|
@ -318,8 +317,8 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
responses.keyInfo.fullAccess.json
|
responses.keyInfo.fullAccess.json
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.lengthOf(libraries, 3);
|
assert.lengthOf(libraries, 2);
|
||||||
assert.sameMembers(libraries, [userLibraryID, publicationsLibraryID, syncedGroup.libraryID]);
|
assert.sameMembers(libraries, [userLibraryID, syncedGroup.libraryID]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should unarchive library if available remotely", function* () {
|
it("should unarchive library if available remotely", function* () {
|
||||||
|
@ -346,10 +345,10 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
responses.keyInfo.fullAccess.json
|
responses.keyInfo.fullAccess.json
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.lengthOf(libraries, 4);
|
assert.lengthOf(libraries, 3);
|
||||||
assert.sameMembers(
|
assert.sameMembers(
|
||||||
libraries,
|
libraries,
|
||||||
[userLibraryID, publicationsLibraryID, syncedGroup.libraryID, archivedGroup.libraryID]
|
[userLibraryID, syncedGroup.libraryID, archivedGroup.libraryID]
|
||||||
);
|
);
|
||||||
assert.isFalse(archivedGroup.archived);
|
assert.isFalse(archivedGroup.archived);
|
||||||
});
|
});
|
||||||
|
@ -370,11 +369,11 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
runner.getAPIClient({ apiKey }),
|
runner.getAPIClient({ apiKey }),
|
||||||
false,
|
false,
|
||||||
responses.keyInfo.fullAccess.json,
|
responses.keyInfo.fullAccess.json,
|
||||||
[userLibraryID, publicationsLibraryID, group.libraryID]
|
[userLibraryID, group.libraryID]
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.lengthOf(libraries, 3);
|
assert.lengthOf(libraries, 2);
|
||||||
assert.sameMembers(libraries, [userLibraryID, publicationsLibraryID, group.libraryID]);
|
assert.sameMembers(libraries, [userLibraryID, group.libraryID]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should update outdated group metadata", function* () {
|
it("should update outdated group metadata", function* () {
|
||||||
|
@ -405,10 +404,10 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
|
|
||||||
assert.ok(stub.calledTwice);
|
assert.ok(stub.calledTwice);
|
||||||
stub.restore();
|
stub.restore();
|
||||||
assert.lengthOf(libraries, 4);
|
assert.lengthOf(libraries, 3);
|
||||||
assert.sameMembers(
|
assert.sameMembers(
|
||||||
libraries,
|
libraries,
|
||||||
[userLibraryID, publicationsLibraryID, group1.libraryID, group2.libraryID]
|
[userLibraryID, group1.libraryID, group2.libraryID]
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(group1.name, groupData1.json.data.name);
|
assert.equal(group1.name, groupData1.json.data.name);
|
||||||
|
@ -474,7 +473,7 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
var libraries = yield runner.checkLibraries(
|
var libraries = yield runner.checkLibraries(
|
||||||
runner.getAPIClient({ apiKey }), false, responses.keyInfo.fullAccess.json
|
runner.getAPIClient({ apiKey }), false, responses.keyInfo.fullAccess.json
|
||||||
);
|
);
|
||||||
assert.lengthOf(libraries, 4);
|
assert.lengthOf(libraries, 3);
|
||||||
var groupData1 = responses.groups.ownerGroup;
|
var groupData1 = responses.groups.ownerGroup;
|
||||||
var group1 = Zotero.Groups.get(groupData1.json.id);
|
var group1 = Zotero.Groups.get(groupData1.json.id);
|
||||||
var groupData2 = responses.groups.memberGroup;
|
var groupData2 = responses.groups.memberGroup;
|
||||||
|
@ -483,7 +482,7 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
assert.ok(group2);
|
assert.ok(group2);
|
||||||
assert.sameMembers(
|
assert.sameMembers(
|
||||||
libraries,
|
libraries,
|
||||||
[userLibraryID, publicationsLibraryID, group1.libraryID, group2.libraryID]
|
[userLibraryID, group1.libraryID, group2.libraryID]
|
||||||
);
|
);
|
||||||
assert.equal(group1.name, groupData1.json.data.name);
|
assert.equal(group1.name, groupData1.json.data.name);
|
||||||
assert.isTrue(group1.editable);
|
assert.isTrue(group1.editable);
|
||||||
|
@ -505,8 +504,8 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
var libraries = yield runner.checkLibraries(
|
var libraries = yield runner.checkLibraries(
|
||||||
runner.getAPIClient({ apiKey }), false, responses.keyInfo.fullAccess.json
|
runner.getAPIClient({ apiKey }), false, responses.keyInfo.fullAccess.json
|
||||||
);
|
);
|
||||||
assert.lengthOf(libraries, 3);
|
assert.lengthOf(libraries, 2);
|
||||||
assert.sameMembers(libraries, [userLibraryID, publicationsLibraryID, group2.libraryID]);
|
assert.sameMembers(libraries, [userLibraryID, group2.libraryID]);
|
||||||
assert.isFalse(Zotero.Groups.exists(groupData1.json.id));
|
assert.isFalse(Zotero.Groups.exists(groupData1.json.id));
|
||||||
assert.isTrue(Zotero.Groups.exists(groupData2.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
|
runner.getAPIClient({ apiKey }), false, responses.keyInfo.fullAccess.json
|
||||||
);
|
);
|
||||||
assert.equal(called, 2);
|
assert.equal(called, 2);
|
||||||
assert.lengthOf(libraries, 2);
|
assert.lengthOf(libraries, 1);
|
||||||
assert.sameMembers(libraries, [userLibraryID, publicationsLibraryID]);
|
assert.sameMembers(libraries, [userLibraryID]);
|
||||||
// Groups should still exist but be read-only and archived
|
// Groups should still exist but be read-only and archived
|
||||||
[group1, group2].forEach((group) => {
|
[group1, group2].forEach((group) => {
|
||||||
assert.isTrue(Zotero.Groups.exists(group.id));
|
assert.isTrue(Zotero.Groups.exists(group.id));
|
||||||
|
@ -698,43 +697,6 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
},
|
},
|
||||||
json: []
|
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
|
// Group library 1
|
||||||
setResponse({
|
setResponse({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
@ -855,15 +817,6 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
},
|
},
|
||||||
json: {}
|
json: {}
|
||||||
});
|
});
|
||||||
setResponse({
|
|
||||||
method: "GET",
|
|
||||||
url: "users/1/publications/fulltext?format=versions",
|
|
||||||
status: 200,
|
|
||||||
headers: {
|
|
||||||
"Last-Modified-Version": 10
|
|
||||||
},
|
|
||||||
json: {}
|
|
||||||
});
|
|
||||||
setResponse({
|
setResponse({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: "groups/1623562/fulltext?format=versions",
|
url: "groups/1623562/fulltext?format=versions",
|
||||||
|
@ -892,10 +845,6 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
Zotero.Libraries.getVersion(userLibraryID),
|
Zotero.Libraries.getVersion(userLibraryID),
|
||||||
5
|
5
|
||||||
);
|
);
|
||||||
assert.equal(
|
|
||||||
Zotero.Libraries.getVersion(publicationsLibraryID),
|
|
||||||
10
|
|
||||||
);
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
Zotero.Libraries.getVersion(Zotero.Groups.getLibraryIDFromGroupID(1623562)),
|
Zotero.Libraries.getVersion(Zotero.Groups.getLibraryIDFromGroupID(1623562)),
|
||||||
15
|
15
|
||||||
|
@ -952,7 +901,7 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
onError: e => { throw e },
|
onError: e => { throw e },
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.equal(stub.callCount, 4);
|
assert.equal(stub.callCount, 3);
|
||||||
stub.restore();
|
stub.restore();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -1035,9 +984,9 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the sync error icon on error", function* () {
|
it("should show the sync error icon on error", function* () {
|
||||||
let pubLib = Zotero.Libraries.get(publicationsLibraryID);
|
let library = Zotero.Libraries.userLibrary;
|
||||||
pubLib.libraryVersion = 5;
|
library.libraryVersion = 5;
|
||||||
yield pubLib.save();
|
yield library.save();
|
||||||
|
|
||||||
setResponse('keyInfo.fullAccess');
|
setResponse('keyInfo.fullAccess');
|
||||||
setResponse('userGroups.groupVersionsEmpty');
|
setResponse('userGroups.groupVersionsEmpty');
|
||||||
|
@ -1053,25 +1002,6 @@ describe("Zotero.Sync.Runner", function () {
|
||||||
INVALID: true // TODO: Find a cleaner error
|
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");
|
spy = sinon.spy(runner, "updateIcons");
|
||||||
yield runner.sync();
|
yield runner.sync();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user