Wait for bundled file updates to complete before running tests
This commit is contained in:
parent
6a05e5c04b
commit
3583793571
6 changed files with 14 additions and 5 deletions
|
@ -27,6 +27,9 @@ Zotero.Schema = new function(){
|
||||||
this.skipDefaultData = false;
|
this.skipDefaultData = false;
|
||||||
this.dbInitialized = false;
|
this.dbInitialized = false;
|
||||||
this.goToChangeLog = false;
|
this.goToChangeLog = false;
|
||||||
|
|
||||||
|
var _schemaUpdateDeferred = Q.defer();
|
||||||
|
this.schemaUpdatePromise = _schemaUpdateDeferred.promise;
|
||||||
|
|
||||||
var _dbVersions = [];
|
var _dbVersions = [];
|
||||||
var _schemaVersions = [];
|
var _schemaVersions = [];
|
||||||
|
@ -121,7 +124,9 @@ Zotero.Schema = new function(){
|
||||||
// 'user' is for pre-1.0b2 'user' table
|
// 'user' is for pre-1.0b2 'user' table
|
||||||
if (!dbVersion && !this.getDBVersion('schema') && !this.getDBVersion('user')){
|
if (!dbVersion && !this.getDBVersion('schema') && !this.getDBVersion('user')){
|
||||||
Zotero.debug('Database does not exist -- creating\n');
|
Zotero.debug('Database does not exist -- creating\n');
|
||||||
_initializeSchema();
|
_initializeSchema().then(function() {
|
||||||
|
_schemaUpdateDeferred.resolve(true);
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,6 +224,7 @@ Zotero.Schema = new function(){
|
||||||
Zotero.Schema.updateBundledFiles(null, false, true)
|
Zotero.Schema.updateBundledFiles(null, false, true)
|
||||||
.finally(function () {
|
.finally(function () {
|
||||||
Zotero.UnresponsiveScriptIndicator.enable();
|
Zotero.UnresponsiveScriptIndicator.enable();
|
||||||
|
_schemaUpdateDeferred.resolve(true);
|
||||||
})
|
})
|
||||||
.done();
|
.done();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
@ -1507,7 +1513,7 @@ Zotero.Schema = new function(){
|
||||||
throw(e);
|
throw(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.Schema.updateBundledFiles(null, null, true)
|
return Zotero.Schema.updateBundledFiles(null, null, true)
|
||||||
.catch(function (e) {
|
.catch(function (e) {
|
||||||
Zotero.debug(e);
|
Zotero.debug(e);
|
||||||
Zotero.logError(e);
|
Zotero.logError(e);
|
||||||
|
|
|
@ -108,6 +108,8 @@ if(ZoteroUnit.tests) {
|
||||||
|
|
||||||
if(run) {
|
if(run) {
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
mocha.run();
|
Zotero.Schema.schemaUpdatePromise.then(function() {
|
||||||
|
mocha.run();
|
||||||
|
}).done();
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -164,5 +164,7 @@ function resetDB() {
|
||||||
var db = Zotero.getZoteroDatabase();
|
var db = Zotero.getZoteroDatabase();
|
||||||
return Zotero.reinit(function() {
|
return Zotero.reinit(function() {
|
||||||
db.remove(false);
|
db.remove(false);
|
||||||
|
}).then(function() {
|
||||||
|
return Zotero.Schema.schemaUpdatePromise;
|
||||||
});
|
});
|
||||||
}
|
}
|
|
@ -13,7 +13,6 @@ describe("Add Item by Identifier", function() {
|
||||||
// make sure they're available before we run the tests)
|
// make sure they're available before we run the tests)
|
||||||
return loadZoteroPane().then(function(w) {
|
return loadZoteroPane().then(function(w) {
|
||||||
win = w;
|
win = w;
|
||||||
return Zotero.Schema.updateBundledFiles('translators', null, false);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
after(function() {
|
after(function() {
|
||||||
|
|
|
@ -8,7 +8,6 @@ describe("PDF Recognition", function() {
|
||||||
// translators
|
// translators
|
||||||
return Q.all([loadZoteroPane().then(function(w) {
|
return Q.all([loadZoteroPane().then(function(w) {
|
||||||
win = w;
|
win = w;
|
||||||
return Zotero.Schema.updateBundledFiles('translators', null, false);
|
|
||||||
}), installPDFTools()]);
|
}), installPDFTools()]);
|
||||||
});
|
});
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
describe("Support Functions for Unit Testing", function() {
|
describe("Support Functions for Unit Testing", function() {
|
||||||
describe("resetDB", function() {
|
describe("resetDB", function() {
|
||||||
it("should restore the DB to factory settings", function() {
|
it("should restore the DB to factory settings", function() {
|
||||||
|
this.timeout(10000);
|
||||||
var quickstart = Zotero.Items.erase(1);
|
var quickstart = Zotero.Items.erase(1);
|
||||||
assert.equal(Zotero.Items.get(1), false);
|
assert.equal(Zotero.Items.get(1), false);
|
||||||
return resetDB().then(function() {
|
return resetDB().then(function() {
|
||||||
|
|
Loading…
Reference in a new issue