commit 35837935713c32ae3c36c80eb5e92160a3e392c1
parent 6a05e5c04ba785b54d8047b29c577460cce87508
Author: Simon Kornblith <simon@simonster.com>
Date: Wed, 11 Mar 2015 13:18:11 -0400
Wait for bundled file updates to complete before running tests
Diffstat:
6 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js
@@ -27,6 +27,9 @@ Zotero.Schema = new function(){
this.skipDefaultData = false;
this.dbInitialized = false;
this.goToChangeLog = false;
+
+ var _schemaUpdateDeferred = Q.defer();
+ this.schemaUpdatePromise = _schemaUpdateDeferred.promise;
var _dbVersions = [];
var _schemaVersions = [];
@@ -121,7 +124,9 @@ Zotero.Schema = new function(){
// 'user' is for pre-1.0b2 'user' table
if (!dbVersion && !this.getDBVersion('schema') && !this.getDBVersion('user')){
Zotero.debug('Database does not exist -- creating\n');
- _initializeSchema();
+ _initializeSchema().then(function() {
+ _schemaUpdateDeferred.resolve(true);
+ });
return true;
}
@@ -219,6 +224,7 @@ Zotero.Schema = new function(){
Zotero.Schema.updateBundledFiles(null, false, true)
.finally(function () {
Zotero.UnresponsiveScriptIndicator.enable();
+ _schemaUpdateDeferred.resolve(true);
})
.done();
}, 5000);
@@ -1507,7 +1513,7 @@ Zotero.Schema = new function(){
throw(e);
}
- Zotero.Schema.updateBundledFiles(null, null, true)
+ return Zotero.Schema.updateBundledFiles(null, null, true)
.catch(function (e) {
Zotero.debug(e);
Zotero.logError(e);
diff --git a/test/content/runtests.js b/test/content/runtests.js
@@ -108,6 +108,8 @@ if(ZoteroUnit.tests) {
if(run) {
window.onload = function() {
- mocha.run();
+ Zotero.Schema.schemaUpdatePromise.then(function() {
+ mocha.run();
+ }).done();
};
}
\ No newline at end of file
diff --git a/test/content/support.js b/test/content/support.js
@@ -164,5 +164,7 @@ function resetDB() {
var db = Zotero.getZoteroDatabase();
return Zotero.reinit(function() {
db.remove(false);
+ }).then(function() {
+ return Zotero.Schema.schemaUpdatePromise;
});
}
\ No newline at end of file
diff --git a/test/tests/lookup.js b/test/tests/lookup.js
@@ -13,7 +13,6 @@ describe("Add Item by Identifier", function() {
// make sure they're available before we run the tests)
return loadZoteroPane().then(function(w) {
win = w;
- return Zotero.Schema.updateBundledFiles('translators', null, false);
});
});
after(function() {
diff --git a/test/tests/recognizePDF.js b/test/tests/recognizePDF.js
@@ -8,7 +8,6 @@ describe("PDF Recognition", function() {
// translators
return Q.all([loadZoteroPane().then(function(w) {
win = w;
- return Zotero.Schema.updateBundledFiles('translators', null, false);
}), installPDFTools()]);
});
afterEach(function() {
diff --git a/test/tests/support.js b/test/tests/support.js
@@ -1,6 +1,7 @@
describe("Support Functions for Unit Testing", function() {
describe("resetDB", function() {
it("should restore the DB to factory settings", function() {
+ this.timeout(10000);
var quickstart = Zotero.Items.erase(1);
assert.equal(Zotero.Items.get(1), false);
return resetDB().then(function() {