From 8f0ed56ae2fd2128b1d9ea49c06c4815e7d141ff Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 29 Nov 2016 03:52:07 -0500 Subject: [PATCH] Test fixes after 5bceebf56cc --- chrome/content/zotero/xpcom/storage/storageLocal.js | 1 - chrome/content/zotero/xpcom/sync/syncEngine.js | 2 +- test/content/runtests.js | 2 ++ test/tests/syncEngineTest.js | 5 +++-- test/tests/webdavTest.js | 13 +++++-------- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/chrome/content/zotero/xpcom/storage/storageLocal.js b/chrome/content/zotero/xpcom/storage/storageLocal.js index 0affc6bda..6ed7aba50 100644 --- a/chrome/content/zotero/xpcom/storage/storageLocal.js +++ b/chrome/content/zotero/xpcom/storage/storageLocal.js @@ -40,7 +40,6 @@ Zotero.Sync.Storage.Local = { case 'user': case 'publications': case 'feed': - Zotero.debug("Storage Mode: " + Zotero.Prefs.get("sync.storage.protocol")); return Zotero.Prefs.get("sync.storage.protocol") == 'webdav' ? 'webdav' : 'zfs'; case 'group': diff --git a/chrome/content/zotero/xpcom/sync/syncEngine.js b/chrome/content/zotero/xpcom/sync/syncEngine.js index d4d5f9c4f..a2e43d185 100644 --- a/chrome/content/zotero/xpcom/sync/syncEngine.js +++ b/chrome/content/zotero/xpcom/sync/syncEngine.js @@ -936,7 +936,7 @@ Zotero.Sync.Data.Engine.prototype._uploadObjects = Zotero.Promise.coroutine(func objectType, o.id, { - // Only storage properties ('mtime', 'md5') for WebDAV files + // Only include storage properties ('mtime', 'md5') for WebDAV files skipStorageProperties: objectType == 'item' ? Zotero.Sync.Storage.Local.getModeForLibrary(this.library.libraryID) diff --git a/test/content/runtests.js b/test/content/runtests.js index e45f042e9..2631466c3 100644 --- a/test/content/runtests.js +++ b/test/content/runtests.js @@ -198,6 +198,7 @@ mocha.setup({ before(function () { // Store all prefs set in runtests.sh + Components.utils.import("resource://zotero/config.js"); var prefBranch = Services.prefs.getBranch(ZOTERO_CONFIG.PREF_BRANCH); ZoteroUnit.customPrefs = {}; prefBranch.getChildList("", {}) @@ -209,6 +210,7 @@ before(function () { * Clear all prefs, and reset those set in runtests.sh to original values */ function resetPrefs() { + Components.utils.import("resource://zotero/config.js"); var prefBranch = Services.prefs.getBranch(ZOTERO_CONFIG.PREF_BRANCH); prefBranch.getChildList("", {}).forEach(key => { var origVal = ZoteroUnit.customPrefs[key]; diff --git a/test/tests/syncEngineTest.js b/test/tests/syncEngineTest.js index 88a519cdb..ed37c7f3d 100644 --- a/test/tests/syncEngineTest.js +++ b/test/tests/syncEngineTest.js @@ -829,7 +829,7 @@ describe("Zotero.Sync.Data.Engine", function () { }) - it("shouldn't include storage properties for attachments in ZFS libraries", function* () { + it("shouldn't include mtime and md5 for attachments in ZFS libraries", function* () { ({ engine, client, caller } = yield setup()); var library = Zotero.Libraries.userLibrary; @@ -938,13 +938,14 @@ describe("Zotero.Sync.Data.Engine", function () { }); - it("should upload synced storage properties", function* () { + it("should include mtime and md5 synced to WebDAV in WebDAV libraries", function* () { ({ engine, client, caller } = yield setup()); var library = Zotero.Libraries.userLibrary; var lastLibraryVersion = 2; library.libraryVersion = lastLibraryVersion; yield library.saveTx(); + Zotero.Sync.Storage.Local.setModeForLibrary(library.id, 'webdav'); var item = new Zotero.Item('attachment'); item.attachmentLinkMode = 'imported_file'; diff --git a/test/tests/webdavTest.js b/test/tests/webdavTest.js index 9cc224a0b..d4c5a8c39 100644 --- a/test/tests/webdavTest.js +++ b/test/tests/webdavTest.js @@ -54,14 +54,6 @@ describe("Zotero.Sync.Storage.Mode.WebDAV", function () { assert.equal(request.requestHeaders["Zotero-API-Key"], apiKey); } - before(function* () { - controller = new Zotero.Sync.Storage.Mode.WebDAV; - Zotero.Prefs.set("sync.storage.scheme", davScheme); - Zotero.Prefs.set("sync.storage.url", davHostPath); - Zotero.Prefs.set("sync.storage.username", davUsername); - controller.password = davPassword; - }) - beforeEach(function* () { yield resetDB({ thisArg: this, @@ -79,6 +71,11 @@ describe("Zotero.Sync.Storage.Mode.WebDAV", function () { yield Zotero.Users.setCurrentUsername("testuser"); Zotero.Sync.Storage.Local.setModeForLibrary(Zotero.Libraries.userLibraryID, 'webdav'); + controller = new Zotero.Sync.Storage.Mode.WebDAV; + Zotero.Prefs.set("sync.storage.scheme", davScheme); + Zotero.Prefs.set("sync.storage.url", davHostPath); + Zotero.Prefs.set("sync.storage.username", davUsername); + controller.password = davPassword; // Set download-on-sync by default Zotero.Sync.Storage.Local.downloadOnSync(