1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Tools: Fixed tests

This commit is contained in:
Laurent Cozic 2021-08-16 18:05:22 +01:00
parent 3f5081e2cd
commit edc3496506
6 changed files with 25 additions and 15 deletions

View File

@ -85,6 +85,7 @@ const SyncTargetWebDAV = require('@joplin/lib/SyncTargetWebDAV.js');
const SyncTargetDropbox = require('@joplin/lib/SyncTargetDropbox.js');
const SyncTargetAmazonS3 = require('@joplin/lib/SyncTargetAmazonS3.js');
SyncTargetRegistry.addClass(SyncTargetNone);
SyncTargetRegistry.addClass(SyncTargetOneDrive);
SyncTargetRegistry.addClass(SyncTargetNextcloud);
SyncTargetRegistry.addClass(SyncTargetWebDAV);
@ -103,6 +104,7 @@ import setIgnoreTlsErrors from './utils/TlsUtils';
import ShareService from '@joplin/lib/services/share/ShareService';
import setupNotifications from './utils/setupNotifications';
import { loadMasterKeysFromSettings } from '@joplin/lib/services/e2ee/utils';
import SyncTargetNone from '../lib/SyncTargetNone';
let storeDispatch = function(_action: any) {};

View File

@ -52,6 +52,7 @@ const { toSystemSlashes } = require('./path-utils');
const { setAutoFreeze } = require('immer');
import { getEncryptionEnabled } from './services/synchronizer/syncInfoUtils';
import { loadMasterKeysFromSettings } from './services/e2ee/utils';
import SyncTargetNone from './SyncTargetNone';
const appLogger: LoggerWrapper = Logger.create('App');
@ -705,6 +706,7 @@ export default class BaseApplication {
Setting.setConstant('cacheDir', cacheDir);
Setting.setConstant('pluginDir', `${profileDir}/plugins`);
SyncTargetRegistry.addClass(SyncTargetNone);
SyncTargetRegistry.addClass(SyncTargetFilesystem);
SyncTargetRegistry.addClass(SyncTargetOneDrive);
SyncTargetRegistry.addClass(SyncTargetNextcloud);

View File

@ -1,5 +1,3 @@
import SyncTargetNone from './SyncTargetNone';
export interface SyncTargetInfo {
id: number;
name: string;
@ -21,17 +19,17 @@ export default class SyncTargetRegistry {
private static reg_: Record<number, SyncTargetInfo> = {};
private static get reg() {
if (!this.reg_[0]) {
this.reg_[0] = {
id: 0,
name: SyncTargetNone.targetName(),
label: SyncTargetNone.label(),
classRef: SyncTargetNone,
description: SyncTargetNone.description(),
supportsSelfHosted: false,
supportsConfigCheck: false,
};
}
// if (!this.reg_[0]) {
// this.reg_[0] = {
// id: 0,
// name: SyncTargetNone.targetName(),
// label: SyncTargetNone.label(),
// classRef: SyncTargetNone,
// description: SyncTargetNone.description(),
// supportsSelfHosted: false,
// supportsConfigCheck: false,
// };
// }
return this.reg_;
}

View File

@ -36,6 +36,7 @@ describe('Registry', function() {
beforeEach(() => {
Setting.setValue('sync.mobileWifiOnly', true);
Setting.setValue('sync.target', 1);
reg.setIsOnMobileData(true);
});

View File

@ -9,8 +9,9 @@ async function clearSyncContext() {
for (const syncTargetId of syncTargetIds) {
const key = `sync.${syncTargetId}.context`;
if (!Setting.keyExists(key)) break;
Setting.resetKey(key);
if (Setting.keyExists(key)) {
Setting.resetKey(key);
}
}
await Setting.saveAll();

View File

@ -56,6 +56,7 @@ import KeychainService from '../services/keychain/KeychainService';
import { loadKeychainServiceAndSettings } from '../services/SettingUtils';
import { setActiveMasterKeyId, setEncryptionEnabled } from '../services/synchronizer/syncInfoUtils';
import Synchronizer from '../Synchronizer';
import SyncTargetNone from '../SyncTargetNone';
const md5 = require('md5');
const S3 = require('aws-sdk/clients/s3');
const { Dirnames } = require('../services/synchronizer/utils/types');
@ -109,6 +110,7 @@ fs.mkdirpSync(baseTempDir);
fs.mkdirpSync(dataDir);
fs.mkdirpSync(profileDir);
SyncTargetRegistry.addClass(SyncTargetNone);
SyncTargetRegistry.addClass(SyncTargetMemory);
SyncTargetRegistry.addClass(SyncTargetFilesystem);
SyncTargetRegistry.addClass(SyncTargetOneDrive);
@ -273,6 +275,7 @@ async function switchClient(id: number, options: any = null) {
await loadKeychainServiceAndSettings(options.keychainEnabled ? KeychainServiceDriver : KeychainServiceDriverDummy);
Setting.setValue('sync.target', syncTargetId());
Setting.setValue('sync.wipeOutFailSafe', false); // To keep things simple, always disable fail-safe unless explicitely set in the test itself
// More generally, this function should clear all data, and so that should
@ -329,6 +332,7 @@ async function setupDatabase(id: number = null, options: any = null) {
BaseModel.setDb(databases_[id]);
await clearDatabase(id);
await loadKeychainServiceAndSettings(options.keychainEnabled ? KeychainServiceDriver : KeychainServiceDriverDummy);
Setting.setValue('sync.target', syncTargetId());
return;
}
@ -347,6 +351,8 @@ async function setupDatabase(id: number = null, options: any = null) {
BaseModel.setDb(databases_[id]);
await clearSettingFile(id);
await loadKeychainServiceAndSettings(options.keychainEnabled ? KeychainServiceDriver : KeychainServiceDriverDummy);
Setting.setValue('sync.target', syncTargetId());
}
async function clearSettingFile(id: number) {