diff --git a/packages/app-cli/tests/test-utils.ts b/packages/app-cli/tests/test-utils.ts index d7c34db31..f1d0dd70c 100644 --- a/packages/app-cli/tests/test-utils.ts +++ b/packages/app-cli/tests/test-utils.ts @@ -55,6 +55,7 @@ const md5 = require('md5'); const S3 = require('aws-sdk/clients/s3'); const { Dirnames } = require('@joplin/lib/services/synchronizer/utils/types'); const sharp = require('sharp'); +const { credentialFile } = require('@joplin/tools/tool-utils'); // Each suite has its own separate data and temp directory so that multiple // suites can be run at the same time. suiteName is what is used to @@ -469,15 +470,27 @@ async function initFileApi() { fileApi = new FileApi('', new FileApiDriverDropbox(api)); } else if (syncTargetId_ == SyncTargetRegistry.nameToId('onedrive')) { // To get a token, open the URL below, then copy the *complete* - // redirection URL in onedrive-auth.txt. Keep in mind that auth data - // only lasts 1h for OneDrive. + // redirection URL in onedrive-auth.txt. Keep in mind that auth + // data only lasts 1h for OneDrive. + // // https://login.live.com/oauth20_authorize.srf?client_id=f1e68e1e-a729-4514-b041-4fdd5c7ac03a&scope=files.readwrite,offline_access&response_type=token&redirect_uri=https://joplinapp.org + // + // Also for now OneDrive tests cannot be run in parallel because + // for that each suite would need its own sub-directory within the + // OneDrive app directory, and it's not clear how to get that + // working. + + if (!process.argv.includes('--runInBand')) { + throw new Error('OneDrive tests must be run sequentially, with the --runInBand arg. eg `npm test -- --runInBand`'); + + } + const { parameters, setEnvOverride } = require('@joplin/lib/parameters.js'); Setting.setConstant('env', 'dev'); setEnvOverride('test'); const config = parameters().oneDriveTest; const api = new OneDriveApi(config.id, config.secret, false); - const authData = fs.readFileSync(`${__dirname}/support/onedrive-auth.txt`, 'utf8'); + const authData = fs.readFileSync(await credentialFile('onedrive-auth.txt'), 'utf8'); const urlInfo = require('url-parse')(authData, true); const auth = require('querystring').parse(urlInfo.hash.substr(1)); api.setAuth(auth); diff --git a/packages/lib/file-api-driver-onedrive.js b/packages/lib/file-api-driver-onedrive.js index 7284650a4..e4e626490 100644 --- a/packages/lib/file-api-driver-onedrive.js +++ b/packages/lib/file-api-driver-onedrive.js @@ -40,7 +40,7 @@ class FileApiDriverOneDrive { output.isDeleted = true; } else { // output.created_time = moment(odItem.fileSystemInfo.createdDateTime, 'YYYY-MM-DDTHH:mm:ss.SSSZ').format('x'); - output.updated_time = moment(odItem.fileSystemInfo.lastModifiedDateTime, 'YYYY-MM-DDTHH:mm:ss.SSSZ').format('x'); + output.updated_time = Number(moment(odItem.fileSystemInfo.lastModifiedDateTime, 'YYYY-MM-DDTHH:mm:ss.SSSZ').format('x')); } return output;