mirror of https://github.com/laurent22/joplin.git
Tools: Fixed tests
parent
23cfbc2367
commit
5528ab7cc8
|
@ -71,7 +71,7 @@ export default class JoplinServerApi {
|
||||||
|
|
||||||
return this.session_;
|
return this.session_;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Could not acquire session:', error);
|
logger.error('Could not acquire session:', error.details, '\n', error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,6 +146,8 @@ export default class JoplinServerApi {
|
||||||
url += stringify(query);
|
url += stringify(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const startTime = Date.now();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.debugRequests_) {
|
if (this.debugRequests_) {
|
||||||
logger.debug(this.requestToCurl_(url, fetchOptions));
|
logger.debug(this.requestToCurl_(url, fetchOptions));
|
||||||
|
@ -170,7 +172,7 @@ export default class JoplinServerApi {
|
||||||
const responseText = await response.text();
|
const responseText = await response.text();
|
||||||
|
|
||||||
if (this.debugRequests_) {
|
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
|
// 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);
|
this.logger().error(error);
|
||||||
} else {
|
} else {
|
||||||
this.logger().error(error);
|
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.
|
// Don't save to the report errors that are due to things like temporary network errors or timeout.
|
||||||
if (!shim.fetchRequestCanBeRetried(error)) {
|
if (!shim.fetchRequestCanBeRetried(error)) {
|
||||||
|
|
|
@ -183,6 +183,12 @@ export default class FileApiDriverJoplinServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async clearRoot(path: string) {
|
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 Setting from '../../models/Setting';
|
||||||
import { allNotesFolders, remoteNotesAndFolders, localNotesFoldersSameAsRemote } from '../../testing/test-utils-synchronizer';
|
import { allNotesFolders, remoteNotesAndFolders, localNotesFoldersSameAsRemote } from '../../testing/test-utils-synchronizer';
|
||||||
|
import { syncTargetName, afterAllCleanUp, synchronizerStart, setupDatabaseAndSynchronizer, synchronizer, sleep, switchClient, syncTargetId, fileApi } from '../../testing/test-utils';
|
||||||
const { syncTargetName, afterAllCleanUp, synchronizerStart, setupDatabaseAndSynchronizer, synchronizer, sleep, switchClient, syncTargetId, fileApi } = require('../../testing/test-utils.js');
|
|
||||||
import Folder from '../../models/Folder';
|
import Folder from '../../models/Folder';
|
||||||
import Note from '../../models/Note';
|
import Note from '../../models/Note';
|
||||||
import BaseItem from '../../models/BaseItem';
|
import BaseItem from '../../models/BaseItem';
|
||||||
|
|
|
@ -50,7 +50,7 @@ const WebDavApi = require('../WebDavApi');
|
||||||
const DropboxApi = require('../DropboxApi');
|
const DropboxApi = require('../DropboxApi');
|
||||||
import JoplinServerApi from '../JoplinServerApi';
|
import JoplinServerApi from '../JoplinServerApi';
|
||||||
import { FolderEntity } from '../services/database/types';
|
import { FolderEntity } from '../services/database/types';
|
||||||
import { credentialFile } from '../utils/credentialFiles';
|
import { credentialFile, readCredentialFile } from '../utils/credentialFiles';
|
||||||
import SyncTargetJoplinCloud from '../SyncTargetJoplinCloud';
|
import SyncTargetJoplinCloud from '../SyncTargetJoplinCloud';
|
||||||
const { loadKeychainServiceAndSettings } = require('../services/SettingUtils');
|
const { loadKeychainServiceAndSettings } = require('../services/SettingUtils');
|
||||||
const md5 = require('md5');
|
const md5 = require('md5');
|
||||||
|
@ -435,7 +435,8 @@ async function synchronizerStart(id: number = null, extraOptions: any = null) {
|
||||||
if (id === null) id = currentClient_;
|
if (id === null) id = currentClient_;
|
||||||
|
|
||||||
const contextKey = `sync.${syncTargetId()}.context`;
|
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);
|
const options = Object.assign({}, extraOptions);
|
||||||
if (context) options.context = context;
|
if (context) options.context = context;
|
||||||
|
@ -571,14 +572,23 @@ async function initFileApi() {
|
||||||
} else if (syncTargetId_ == SyncTargetRegistry.nameToId('joplinServer')) {
|
} else if (syncTargetId_ == SyncTargetRegistry.nameToId('joplinServer')) {
|
||||||
mustRunInBand();
|
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
|
// 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
|
// as database, as the SQLite database is not reliable when being
|
||||||
// read/write from multiple processes at the same time.
|
// read/write from multiple processes at the same time.
|
||||||
const api = new JoplinServerApi({
|
const api = new JoplinServerApi({
|
||||||
baseUrl: () => 'http://localhost:22300',
|
baseUrl: () => joplinServerAuth.baseUrl,
|
||||||
userContentBaseUrl: () => '',
|
userContentBaseUrl: () => joplinServerAuth.userContentBaseUrl,
|
||||||
username: () => 'admin@localhost',
|
username: () => joplinServerAuth.email,
|
||||||
password: () => 'admin',
|
password: () => joplinServerAuth.password,
|
||||||
});
|
});
|
||||||
|
|
||||||
fileApi = new FileApi('', new FileApiDriverJoplinServer(api));
|
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
|
// we can't return void, so let's return one of the valid domains
|
||||||
return corsAllowedDomains[0];
|
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);
|
app.use(ownerHandler);
|
||||||
|
|
Loading…
Reference in New Issue