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:
parent
23cfbc2367
commit
5528ab7cc8
@ -71,7 +71,7 @@ export default class JoplinServerApi {
|
||||
|
||||
return this.session_;
|
||||
} catch (error) {
|
||||
logger.error('Could not acquire session:', error);
|
||||
logger.error('Could not acquire session:', error.details, '\n', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@ -146,6 +146,8 @@ export default class JoplinServerApi {
|
||||
url += stringify(query);
|
||||
}
|
||||
|
||||
const startTime = Date.now();
|
||||
|
||||
try {
|
||||
if (this.debugRequests_) {
|
||||
logger.debug(this.requestToCurl_(url, fetchOptions));
|
||||
@ -170,7 +172,7 @@ export default class JoplinServerApi {
|
||||
const responseText = await response.text();
|
||||
|
||||
if (this.debugRequests_) {
|
||||
logger.debug('Response', options.responseFormat, responseText);
|
||||
logger.debug('Response', Date.now() - startTime, options.responseFormat, responseText);
|
||||
}
|
||||
|
||||
// Creates an error object with as much data as possible as it will appear in the log, which will make debugging easier
|
||||
|
@ -926,6 +926,7 @@ export default class Synchronizer {
|
||||
this.logger().error(error);
|
||||
} else {
|
||||
this.logger().error(error);
|
||||
if (error.details) this.logger().error('Details:', error.details);
|
||||
|
||||
// Don't save to the report errors that are due to things like temporary network errors or timeout.
|
||||
if (!shim.fetchRequestCanBeRetried(error)) {
|
||||
|
@ -183,6 +183,12 @@ export default class FileApiDriverJoplinServer {
|
||||
}
|
||||
|
||||
public async clearRoot(path: string) {
|
||||
await this.delete(path);
|
||||
const response = await this.list(path);
|
||||
|
||||
for (const item of response.items) {
|
||||
await this.delete(item.path);
|
||||
}
|
||||
|
||||
if (response.has_more) throw new Error('has_more support not implemented');
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import Setting from '../../models/Setting';
|
||||
import { allNotesFolders, remoteNotesAndFolders, localNotesFoldersSameAsRemote } from '../../testing/test-utils-synchronizer';
|
||||
|
||||
const { syncTargetName, afterAllCleanUp, synchronizerStart, setupDatabaseAndSynchronizer, synchronizer, sleep, switchClient, syncTargetId, fileApi } = require('../../testing/test-utils.js');
|
||||
import { syncTargetName, afterAllCleanUp, synchronizerStart, setupDatabaseAndSynchronizer, synchronizer, sleep, switchClient, syncTargetId, fileApi } from '../../testing/test-utils';
|
||||
import Folder from '../../models/Folder';
|
||||
import Note from '../../models/Note';
|
||||
import BaseItem from '../../models/BaseItem';
|
||||
|
@ -50,7 +50,7 @@ const WebDavApi = require('../WebDavApi');
|
||||
const DropboxApi = require('../DropboxApi');
|
||||
import JoplinServerApi from '../JoplinServerApi';
|
||||
import { FolderEntity } from '../services/database/types';
|
||||
import { credentialFile } from '../utils/credentialFiles';
|
||||
import { credentialFile, readCredentialFile } from '../utils/credentialFiles';
|
||||
import SyncTargetJoplinCloud from '../SyncTargetJoplinCloud';
|
||||
const { loadKeychainServiceAndSettings } = require('../services/SettingUtils');
|
||||
const md5 = require('md5');
|
||||
@ -435,7 +435,8 @@ async function synchronizerStart(id: number = null, extraOptions: any = null) {
|
||||
if (id === null) id = currentClient_;
|
||||
|
||||
const contextKey = `sync.${syncTargetId()}.context`;
|
||||
const context = Setting.value(contextKey);
|
||||
const contextString = Setting.value(contextKey);
|
||||
const context = contextString ? JSON.parse(contextString) : {};
|
||||
|
||||
const options = Object.assign({}, extraOptions);
|
||||
if (context) options.context = context;
|
||||
@ -571,14 +572,23 @@ async function initFileApi() {
|
||||
} else if (syncTargetId_ == SyncTargetRegistry.nameToId('joplinServer')) {
|
||||
mustRunInBand();
|
||||
|
||||
const joplinServerAuth = JSON.parse(await readCredentialFile('joplin-server-test-units-2.json'));
|
||||
|
||||
// const joplinServerAuth = {
|
||||
// "email": "admin@localhost",
|
||||
// "password": "admin",
|
||||
// "baseUrl": "http://api-joplincloud.local:22300",
|
||||
// "userContentBaseUrl": ""
|
||||
// }
|
||||
|
||||
// Note that to test the API in parallel mode, you need to use Postgres
|
||||
// as database, as the SQLite database is not reliable when being
|
||||
// read/write from multiple processes at the same time.
|
||||
const api = new JoplinServerApi({
|
||||
baseUrl: () => 'http://localhost:22300',
|
||||
userContentBaseUrl: () => '',
|
||||
username: () => 'admin@localhost',
|
||||
password: () => 'admin',
|
||||
baseUrl: () => joplinServerAuth.baseUrl,
|
||||
userContentBaseUrl: () => joplinServerAuth.userContentBaseUrl,
|
||||
username: () => joplinServerAuth.email,
|
||||
password: () => joplinServerAuth.password,
|
||||
});
|
||||
|
||||
fileApi = new FileApi('', new FileApiDriverJoplinServer(api));
|
||||
|
@ -117,15 +117,6 @@ async function main() {
|
||||
// we can't return void, so let's return one of the valid domains
|
||||
return corsAllowedDomains[0];
|
||||
}
|
||||
|
||||
// const requestOrigin = ctx.request.header.origin;
|
||||
|
||||
// if (hostname === envVariables.USER_CONTENT_BASE_URL) return
|
||||
|
||||
// if (corsAllowedDomains.indexOf(requestOrigin) === 0) {
|
||||
// return requestOrigin;
|
||||
// }
|
||||
|
||||
},
|
||||
}));
|
||||
app.use(ownerHandler);
|
||||
|
Loading…
Reference in New Issue
Block a user