Wait for bundled file updates to complete before running tests

This commit is contained in:
Simon Kornblith 2015-03-11 13:18:11 -04:00
parent 6a05e5c04b
commit 3583793571
6 changed files with 14 additions and 5 deletions

View file

@ -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);

View file

@ -108,6 +108,8 @@ if(ZoteroUnit.tests) {
if(run) {
window.onload = function() {
mocha.run();
Zotero.Schema.schemaUpdatePromise.then(function() {
mocha.run();
}).done();
};
}

View file

@ -164,5 +164,7 @@ function resetDB() {
var db = Zotero.getZoteroDatabase();
return Zotero.reinit(function() {
db.remove(false);
}).then(function() {
return Zotero.Schema.schemaUpdatePromise;
});
}

View file

@ -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() {

View file

@ -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() {

View file

@ -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() {