Merge pull request #3074 from overleaf/msm-update-oerror-logger-v3

Update o-error to v3 and logger-sharelatex to v3

GitOrigin-RevId: 5e6386f65b7893949336aa4ff021212aebd98f4a
This commit is contained in:
Miguel Serrano
2020-08-12 02:06:58 +00:00
committed by Copybot
parent 42c917d909
commit d2845d9a38
27 changed files with 446 additions and 719 deletions
@@ -3,6 +3,7 @@ const sinon = require('sinon')
const { expect } = require('chai')
const SandboxedModule = require('sandboxed-module')
const Errors = require('../../../../app/src/Features/Errors/Errors')
const OError = require('@overleaf/o-error')
const MODULE_PATH = '../../../../app/src/Features/FileStore/FileStoreHandler.js'
@@ -283,10 +284,13 @@ describe('FileStoreHandler', function() {
})
it('should wrap the error if there is one', function(done) {
const error = 'my error'
const error = new Error('my error')
this.request.callsArgWith(1, error)
this.handler.deleteProject(this.projectId, err => {
assert.equal(err.cause, error)
expect(OError.getFullStack(err)).to.match(
/something went wrong deleting a project in filestore/
)
expect(OError.getFullStack(err)).to.match(/my error/)
done()
})
})
@@ -154,5 +154,27 @@ describe('NewsletterManager', function() {
`/lists/list_id/members/${this.emailHash}`
)
})
it('does not reject on non-fatal error ', async function() {
const nonFatalError = new Error('merge fields were invalid')
this.mailchimp.patch.rejects(nonFatalError)
await expect(
this.NewsletterManager.changeEmail(
this.user,
'overleaf.squirrel@example.com'
)
).to.be.fulfilled
})
it('rejects on any other error', async function() {
const fatalError = new Error('fatal error')
this.mailchimp.patch.rejects(fatalError)
await expect(
this.NewsletterManager.changeEmail(
this.user,
'overleaf.squirrel@example.com'
)
).to.be.rejected
})
})
})
@@ -432,7 +432,7 @@ describe('UserController', function() {
describe('when changeEmailAddress yields an error', function() {
it('should pass on an error and not send a success status', function(done) {
this.req.body.email = this.newEmail.toUpperCase()
this.UserUpdater.changeEmailAddress.callsArgWith(2, new Error())
this.UserUpdater.changeEmailAddress.callsArgWith(2, new OError())
this.HttpErrorHandler.legacyInternal = sinon.spy(
(req, res, message, error) => {
expect(req).to.exist