mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Merge pull request #9647 from overleaf/bg-dropbox-to-overleaf-existing-doc
handle updates to existing doc in dropbox to overleaf metadata GitOrigin-RevId: e82955a4a76e62fb649263a94103fdb7f322de85
This commit is contained in:
@@ -76,6 +76,7 @@ describe('Setting a document', function () {
|
||||
return done(error)
|
||||
}
|
||||
this.statusCode = res.statusCode
|
||||
this.body = body
|
||||
done()
|
||||
}
|
||||
)
|
||||
@@ -91,8 +92,8 @@ describe('Setting a document', function () {
|
||||
MockWebApi.setDocument.resetHistory()
|
||||
})
|
||||
|
||||
it('should return a 204 status code', function () {
|
||||
this.statusCode.should.equal(204)
|
||||
it('should return a 200 status code', function () {
|
||||
this.statusCode.should.equal(200)
|
||||
})
|
||||
|
||||
it('should send the updated doc lines and version to the web api', function () {
|
||||
@@ -141,6 +142,10 @@ describe('Setting a document', function () {
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it('should return the mongo rev in the json response', function () {
|
||||
this.body.should.deep.equal({ rev: '123' })
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the updated doc does not exist in the doc updater', function () {
|
||||
@@ -163,6 +168,7 @@ describe('Setting a document', function () {
|
||||
return done(error)
|
||||
}
|
||||
this.statusCode = res.statusCode
|
||||
this.body = body
|
||||
setTimeout(done, 200)
|
||||
}
|
||||
)
|
||||
@@ -174,8 +180,8 @@ describe('Setting a document', function () {
|
||||
MockWebApi.setDocument.resetHistory()
|
||||
})
|
||||
|
||||
it('should return a 204 status code', function () {
|
||||
this.statusCode.should.equal(204)
|
||||
it('should return a 200 status code', function () {
|
||||
this.statusCode.should.equal(200)
|
||||
})
|
||||
|
||||
it('should send the updated doc lines to the web api', function () {
|
||||
@@ -206,6 +212,10 @@ describe('Setting a document', function () {
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it('should return the mongo rev in the json response', function () {
|
||||
this.body.should.deep.equal({ rev: '123' })
|
||||
})
|
||||
})
|
||||
|
||||
const DOC_TOO_LARGE_TEST_CASES = [
|
||||
@@ -302,6 +312,7 @@ describe('Setting a document', function () {
|
||||
return done(error)
|
||||
}
|
||||
this.statusCode = res.statusCode
|
||||
this.body = body
|
||||
setTimeout(done, 200)
|
||||
}
|
||||
)
|
||||
@@ -313,8 +324,8 @@ describe('Setting a document', function () {
|
||||
MockWebApi.setDocument.resetHistory()
|
||||
})
|
||||
|
||||
it('should return a 204 status code', function () {
|
||||
this.statusCode.should.equal(204)
|
||||
it('should return a 200 status code', function () {
|
||||
this.statusCode.should.equal(200)
|
||||
})
|
||||
|
||||
it('should send the updated doc lines to the web api', function () {
|
||||
@@ -322,6 +333,10 @@ describe('Setting a document', function () {
|
||||
.calledWith(this.project_id, this.doc_id, this.newLines)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should return the mongo rev in the json response', function () {
|
||||
this.body.should.deep.equal({ rev: '123' })
|
||||
})
|
||||
})
|
||||
|
||||
describe('with track changes', function () {
|
||||
|
||||
@@ -99,7 +99,7 @@ module.exports = MockWebApi = {
|
||||
if (error != null) {
|
||||
return res.sendStatus(500)
|
||||
} else {
|
||||
return res.sendStatus(204)
|
||||
return res.json({ rev: '123' })
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -17,6 +17,7 @@ describe('HttpController', function () {
|
||||
'./RedisManager': (this.RedisManager = {}),
|
||||
'./Metrics': (this.Metrics = {}),
|
||||
'./Errors': Errors,
|
||||
'@overleaf/settings': { max_doc_length: 2 * 1024 * 1024 },
|
||||
},
|
||||
})
|
||||
this.Metrics.Timer = class Timer {}
|
||||
@@ -202,7 +203,9 @@ describe('HttpController', function () {
|
||||
|
||||
describe('successfully', function () {
|
||||
beforeEach(function () {
|
||||
this.DocumentManager.setDocWithLock = sinon.stub().callsArgWith(6)
|
||||
this.DocumentManager.setDocWithLock = sinon
|
||||
.stub()
|
||||
.callsArgWith(6, null, { rev: '123' })
|
||||
this.HttpController.setDoc(this.req, this.res, this.next)
|
||||
})
|
||||
|
||||
@@ -219,8 +222,8 @@ describe('HttpController', function () {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should return a successful No Content response', function () {
|
||||
this.res.sendStatus.calledWith(204).should.equal(true)
|
||||
it('should return a json response with the document rev from web', function () {
|
||||
this.res.json.calledWithMatch({ rev: '123' }).should.equal(true)
|
||||
})
|
||||
|
||||
it('should log the request', function () {
|
||||
|
||||
Reference in New Issue
Block a user