Load synced settings (incl. tag colors) at startup
This commit is contained in:
parent
60830c27ee
commit
8e5016ae4d
17 changed files with 252 additions and 184 deletions
|
@ -150,6 +150,11 @@ describe("Zotero.Library", function() {
|
|||
yield library.saveTx();
|
||||
assert.isFalse(Zotero.Libraries.isEditable(library.libraryID));
|
||||
});
|
||||
|
||||
it("should initialize library after creation", function* () {
|
||||
let library = yield createGroup({});
|
||||
Zotero.SyncedSettings.get(library.libraryID, "tagColors");
|
||||
});
|
||||
});
|
||||
describe("#erase()", function() {
|
||||
it("should erase a group library", function* () {
|
||||
|
|
|
@ -239,10 +239,10 @@ describe("Zotero.Sync.Data.Engine", function () {
|
|||
assert.equal(Zotero.Libraries.getVersion(userLibraryID), 3);
|
||||
|
||||
// Make sure local objects exist
|
||||
var setting = yield Zotero.SyncedSettings.get(userLibraryID, "tagColors");
|
||||
var setting = Zotero.SyncedSettings.get(userLibraryID, "tagColors");
|
||||
assert.lengthOf(setting, 1);
|
||||
assert.equal(setting[0].name, 'A');
|
||||
var settingMetadata = yield Zotero.SyncedSettings.getMetadata(userLibraryID, "tagColors");
|
||||
var settingMetadata = Zotero.SyncedSettings.getMetadata(userLibraryID, "tagColors");
|
||||
assert.equal(settingMetadata.version, 2);
|
||||
assert.isTrue(settingMetadata.synced);
|
||||
|
||||
|
@ -812,7 +812,7 @@ describe("Zotero.Sync.Data.Engine", function () {
|
|||
yield engine._startDownload();
|
||||
|
||||
// Make sure objects were deleted
|
||||
assert.isFalse(yield Zotero.SyncedSettings.get(userLibraryID, 'tagColors'));
|
||||
assert.isNull(Zotero.SyncedSettings.get(userLibraryID, 'tagColors'));
|
||||
assert.isFalse(Zotero.Collections.exists(collectionID));
|
||||
assert.isFalse(Zotero.Searches.exists(searchID));
|
||||
assert.isFalse(Zotero.Items.exists(itemID));
|
||||
|
@ -901,7 +901,7 @@ describe("Zotero.Sync.Data.Engine", function () {
|
|||
yield engine._startDownload();
|
||||
|
||||
// Make sure objects weren't deleted
|
||||
assert.ok(yield Zotero.SyncedSettings.get(userLibraryID, 'tagColors'));
|
||||
assert.ok(Zotero.SyncedSettings.get(userLibraryID, 'tagColors'));
|
||||
assert.ok(Zotero.Collections.exists(collectionID));
|
||||
assert.ok(Zotero.Searches.exists(searchID));
|
||||
})
|
||||
|
@ -1212,10 +1212,10 @@ describe("Zotero.Sync.Data.Engine", function () {
|
|||
yield engine._fullSync();
|
||||
|
||||
// Check settings
|
||||
var setting = yield Zotero.SyncedSettings.get(userLibraryID, "tagColors");
|
||||
var setting = Zotero.SyncedSettings.get(userLibraryID, "tagColors");
|
||||
assert.lengthOf(setting, 1);
|
||||
assert.equal(setting[0].name, 'A');
|
||||
var settingMetadata = yield Zotero.SyncedSettings.getMetadata(userLibraryID, "tagColors");
|
||||
var settingMetadata = Zotero.SyncedSettings.getMetadata(userLibraryID, "tagColors");
|
||||
assert.equal(settingMetadata.version, 2);
|
||||
assert.isTrue(settingMetadata.synced);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ describe("Tag Selector", function () {
|
|||
var win, doc, collectionsView;
|
||||
|
||||
var clearTagColors = Zotero.Promise.coroutine(function* (libraryID) {
|
||||
var tagColors = yield Zotero.Tags.getColors(libraryID);
|
||||
var tagColors = Zotero.Tags.getColors(libraryID);
|
||||
for (let name of tagColors.keys()) {
|
||||
yield Zotero.Tags.setColor(libraryID, name, false);
|
||||
}
|
||||
|
|
|
@ -64,4 +64,38 @@ describe("Zotero.Tags", function () {
|
|||
assert.isFalse(yield Zotero.Tags.getName(tagID));
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
describe("#setColor()", function () {
|
||||
var libraryID;
|
||||
|
||||
before(function* () {
|
||||
libraryID = Zotero.Libraries.userLibraryID;
|
||||
|
||||
// Clear library tag colors
|
||||
var colors = Zotero.Tags.getColors(libraryID);
|
||||
for (let color of colors.keys()) {
|
||||
yield Zotero.Tags.setColor(libraryID, color);
|
||||
}
|
||||
});
|
||||
|
||||
it("should set color for a tag", function* () {
|
||||
var aColor = '#ABCDEF';
|
||||
var bColor = '#BCDEF0';
|
||||
yield Zotero.Tags.setColor(libraryID, "A", aColor);
|
||||
yield Zotero.Tags.setColor(libraryID, "B", bColor);
|
||||
|
||||
var o = Zotero.Tags.getColor(libraryID, "A")
|
||||
assert.equal(o.color, aColor);
|
||||
assert.equal(o.position, 0);
|
||||
var o = Zotero.Tags.getColor(libraryID, "B")
|
||||
assert.equal(o.color, bColor);
|
||||
assert.equal(o.position, 1);
|
||||
|
||||
var o = Zotero.SyncedSettings.get(libraryID, 'tagColors');
|
||||
assert.isArray(o);
|
||||
assert.lengthOf(o, 2);
|
||||
assert.sameMembers(o.map(c => c.color), [aColor, bColor]);
|
||||
});
|
||||
});
|
||||
})
|
||||
|
|
|
@ -14,17 +14,6 @@ describe("Item Tags Box", function () {
|
|||
win.close();
|
||||
});
|
||||
|
||||
function waitForTagsBox() {
|
||||
var deferred = Zotero.Promise.defer();
|
||||
var tagsbox = doc.getElementById('zotero-editpane-tags');
|
||||
var onRefresh = function (event) {
|
||||
tagsbox.removeEventListener('refresh', onRefresh);
|
||||
deferred.resolve();
|
||||
}
|
||||
tagsbox.addEventListener('refresh', onRefresh);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
describe("#notify()", function () {
|
||||
it("should update an existing tag on rename", function* () {
|
||||
var tag = Zotero.Utilities.randomString();
|
||||
|
@ -43,7 +32,6 @@ describe("Item Tags Box", function () {
|
|||
|
||||
var tabbox = doc.getElementById('zotero-view-tabbox');
|
||||
tabbox.selectedIndex = 2;
|
||||
yield waitForTagsBox();
|
||||
var tagsbox = doc.getElementById('zotero-editpane-tags');
|
||||
var rows = tagsbox.id('tagRows').getElementsByTagName('row');
|
||||
assert.equal(rows.length, 1);
|
||||
|
@ -77,7 +65,6 @@ describe("Item Tags Box", function () {
|
|||
|
||||
var tabbox = doc.getElementById('zotero-view-tabbox');
|
||||
tabbox.selectedIndex = 2;
|
||||
yield waitForTagsBox();
|
||||
var tagsbox = doc.getElementById('zotero-editpane-tags');
|
||||
var rows = tagsbox.id('tagRows').getElementsByTagName('row');
|
||||
|
||||
|
@ -108,7 +95,6 @@ describe("Item Tags Box", function () {
|
|||
|
||||
var tabbox = doc.getElementById('zotero-view-tabbox');
|
||||
tabbox.selectedIndex = 2;
|
||||
yield waitForTagsBox();
|
||||
var tagsbox = doc.getElementById('zotero-editpane-tags');
|
||||
var rows = tagsbox.id('tagRows').getElementsByTagName('row');
|
||||
assert.equal(rows.length, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue