diff --git a/src/lib/db.js b/src/lib/db.js index cf9baaac..801bdc62 100644 --- a/src/lib/db.js +++ b/src/lib/db.js @@ -12,7 +12,6 @@ module.exports = () => { } return new PouchDB(environment.apiUrl, { - ajax: { timeout: 60000 }, session: environment.sessionToken, }); }; diff --git a/test/e2e/session-token.spec.js b/test/e2e/session-token.spec.js index 540ea57c..b0e0c0ca 100644 --- a/test/e2e/session-token.spec.js +++ b/test/e2e/session-token.spec.js @@ -1,11 +1,14 @@ /* eslint-disable no-console */ -const { expect } = require('chai'); +const chai = require('chai'); const { exec } = require('child_process'); const rpn = require('request-promise-native'); const fs = require('fs-extra'); const path = require('path'); const PouchDB = require('pouchdb-core'); +const { expect } = chai; +chai.use(require('chai-as-promised')); + const COUCHDB_USERNAME = 'admin'; const COUCHDB_PASSWORD = 'password'; const COUCHDB_URL = 'http://localhost:6984'; @@ -45,7 +48,7 @@ const runCliCommand = (command) => { exec(`node ${cliPath} ${command}`, { cwd: projectPath }, (error, stdout, stderr) => { if (error) { console.error(stderr); - reject(stdout); + reject(new Error(stdout)); } else { resolve(stdout); } @@ -57,7 +60,7 @@ describe('e2e/session-token', function() { this.timeout(15000); let sessionToken; - let action = 'upload-docs --force'; + const action = 'upload-docs --force'; const initializeProject = async () => { await runCliCommand('initialise-project-layout'); @@ -137,11 +140,13 @@ describe('e2e/session-token', function() { it('should fail with incorrect session token', async () => { const incorrectToken = 'incorrect-token'; - try { - await runCliCommand(`--url=${COUCHDB_URL} --session-token=${incorrectToken} ${action}`); - } catch (error) { + const promiseToExecute = runCliCommand( + `--url=${COUCHDB_URL} --session-token=${incorrectToken} ${action}` + ); + await expect(promiseToExecute) + .to.be.rejected + .and.eventually.have.property('message') // Bad Request: Malformed AuthSession cookie - expect(error).to.contain('INFO Error: Received error code 400'); - } + .that.contains('INFO Error: Received error code 400'); }); }); \ No newline at end of file