You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
Tests: Integration harness fixes and refactors. (#2569)
* Test harness fixes and integration test refactor and addition. * Clean up. * Address review comments. * Improve method names.
This commit is contained in:
@@ -55,11 +55,20 @@ class BaseApplication {
|
||||
}
|
||||
|
||||
async destroy() {
|
||||
if (this.scheduleAutoAddResourcesIID_) {
|
||||
clearTimeout(this.scheduleAutoAddResourcesIID_);
|
||||
this.scheduleAutoAddResourcesIID_ = null;
|
||||
}
|
||||
await ResourceFetcher.instance().destroy();
|
||||
await SearchEngine.instance().destroy();
|
||||
await DecryptionWorker.instance().destroy();
|
||||
await FoldersScreenUtils.cancelTimers();
|
||||
await SearchEngine.instance().cancelTimers();
|
||||
await DecryptionWorker.instance().cancelTimers();
|
||||
await reg.cancelTimers();
|
||||
|
||||
this.eventEmitter_.removeAllListeners();
|
||||
BaseModel.db_ = null;
|
||||
reg.setDb(null);
|
||||
|
||||
this.logger_ = null;
|
||||
this.dbLogger_ = null;
|
||||
this.eventEmitter_ = null;
|
||||
|
||||
@@ -56,7 +56,10 @@ class FoldersScreenUtils {
|
||||
}
|
||||
|
||||
static async cancelTimers() {
|
||||
if (this.scheduleRefreshFoldersIID_) clearTimeout(this.scheduleRefreshFoldersIID_);
|
||||
if (this.scheduleRefreshFoldersIID_) {
|
||||
clearTimeout(this.scheduleRefreshFoldersIID_);
|
||||
this.scheduleRefreshFoldersIID_ = null;
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
const iid = setInterval(() => {
|
||||
if (!FoldersScreenUtils.refreshCalls_.length) {
|
||||
|
||||
@@ -193,7 +193,10 @@ reg.db = () => {
|
||||
};
|
||||
|
||||
reg.cancelTimers = async () => {
|
||||
if (this.recurrentSyncId_) clearTimeout(this.recurrentSyncId_);
|
||||
if (this.recurrentSyncId_) {
|
||||
clearTimeout(this.recurrentSyncId_);
|
||||
this.recurrentSyncId_ = null;
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
const iid = setInterval(() => {
|
||||
if (!reg.syncCalls_.length) {
|
||||
|
||||
@@ -37,9 +37,9 @@ class DecryptionWorker {
|
||||
}
|
||||
|
||||
static instance() {
|
||||
if (this.instance_) return this.instance_;
|
||||
this.instance_ = new DecryptionWorker();
|
||||
return this.instance_;
|
||||
if (DecryptionWorker.instance_) return DecryptionWorker.instance_;
|
||||
DecryptionWorker.instance_ = new DecryptionWorker();
|
||||
return DecryptionWorker.instance_;
|
||||
}
|
||||
|
||||
setEncryptionService(v) {
|
||||
@@ -250,8 +250,15 @@ class DecryptionWorker {
|
||||
}
|
||||
}
|
||||
|
||||
async cancelTimers() {
|
||||
if (this.scheduleId_) clearTimeout(this.scheduleId_);
|
||||
async destroy() {
|
||||
this.eventEmitter_.removeAllListeners();
|
||||
if (this.scheduleId_) {
|
||||
clearTimeout(this.scheduleId_);
|
||||
this.scheduleId_ = null;
|
||||
}
|
||||
this.eventEmitter_ = null;
|
||||
DecryptionWorker.instance_ = null;
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const iid = setInterval(() => {
|
||||
if (!this.startCalls_.length) {
|
||||
@@ -263,4 +270,6 @@ class DecryptionWorker {
|
||||
}
|
||||
}
|
||||
|
||||
DecryptionWorker.instance_ = null;
|
||||
|
||||
module.exports = DecryptionWorker;
|
||||
|
||||
@@ -24,9 +24,9 @@ class ResourceFetcher extends BaseService {
|
||||
}
|
||||
|
||||
static instance() {
|
||||
if (this.instance_) return this.instance_;
|
||||
this.instance_ = new ResourceFetcher();
|
||||
return this.instance_;
|
||||
if (ResourceFetcher.instance_) return ResourceFetcher.instance_;
|
||||
ResourceFetcher.instance_ = new ResourceFetcher();
|
||||
return ResourceFetcher.instance_;
|
||||
}
|
||||
|
||||
on(eventName, callback) {
|
||||
@@ -248,6 +248,20 @@ class ResourceFetcher extends BaseService {
|
||||
await Resource.resetStartedFetchStatus();
|
||||
this.autoAddResources(null);
|
||||
}
|
||||
|
||||
async destroy() {
|
||||
this.eventEmitter_.removeAllListeners();
|
||||
if (this.scheduleQueueProcessIID_) {
|
||||
clearTimeout(this.scheduleQueueProcessIID_);
|
||||
this.scheduleQueueProcessIID_ = null;
|
||||
}
|
||||
this.eventEmitter_ = null;
|
||||
ResourceFetcher.instance_ = null;
|
||||
|
||||
return await this.waitForAllFinished();
|
||||
}
|
||||
}
|
||||
|
||||
ResourceFetcher.instance_ = null;
|
||||
|
||||
module.exports = ResourceFetcher;
|
||||
|
||||
@@ -18,9 +18,9 @@ class SearchEngine {
|
||||
}
|
||||
|
||||
static instance() {
|
||||
if (this.instance_) return this.instance_;
|
||||
this.instance_ = new SearchEngine();
|
||||
return this.instance_;
|
||||
if (SearchEngine.instance_) return SearchEngine.instance_;
|
||||
SearchEngine.instance_ = new SearchEngine();
|
||||
return SearchEngine.instance_;
|
||||
}
|
||||
|
||||
setLogger(logger) {
|
||||
@@ -413,8 +413,13 @@ class SearchEngine {
|
||||
}
|
||||
}
|
||||
|
||||
async cancelTimers() {
|
||||
if (this.scheduleSyncTablesIID_) clearTimeout(this.scheduleSyncTablesIID_);
|
||||
async destroy() {
|
||||
if (this.scheduleSyncTablesIID_) {
|
||||
clearTimeout(this.scheduleSyncTablesIID_);
|
||||
this.scheduleSyncTablesIID_ = null;
|
||||
}
|
||||
SearchEngine.instance_ = null;
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const iid = setInterval(() => {
|
||||
if (!this.syncCalls_.length) {
|
||||
@@ -426,4 +431,6 @@ class SearchEngine {
|
||||
}
|
||||
}
|
||||
|
||||
SearchEngine.instance_ = null;
|
||||
|
||||
module.exports = SearchEngine;
|
||||
|
||||
Reference in New Issue
Block a user