Skip to content

Commit

Permalink
fix: address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpascal committed Jun 20, 2024
1 parent 9e45f2f commit 5109fa2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/lib/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module.exports = () => {
}

return new PouchDB(environment.apiUrl, {
ajax: { timeout: 60000 },
session: environment.sessionToken,
});
};
21 changes: 13 additions & 8 deletions test/e2e/session-token.spec.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
}
Expand All @@ -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');
Expand Down Expand Up @@ -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');
});
});

0 comments on commit 5109fa2

Please sign in to comment.