mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
add acceptance test for realtime shutdown
This commit is contained in:
parent
a76e0dca88
commit
7493462154
2 changed files with 47 additions and 5 deletions
|
@ -41,17 +41,15 @@ describe "Deleting a project", ->
|
||||||
version: doc.update.v
|
version: doc.update.v
|
||||||
}
|
}
|
||||||
|
|
||||||
sinon.spy MockTrackChangesApi, "flushDoc"
|
|
||||||
sinon.spy MockProjectHistoryApi, "flushProject"
|
|
||||||
DocUpdaterApp.ensureRunning(done)
|
DocUpdaterApp.ensureRunning(done)
|
||||||
|
|
||||||
after ->
|
|
||||||
MockTrackChangesApi.flushDoc.restore()
|
|
||||||
MockProjectHistoryApi.flushProject.restore()
|
|
||||||
|
|
||||||
describe "with documents which have been updated", ->
|
describe "with documents which have been updated", ->
|
||||||
before (done) ->
|
before (done) ->
|
||||||
sinon.spy MockWebApi, "setDocument"
|
sinon.spy MockWebApi, "setDocument"
|
||||||
|
sinon.spy MockTrackChangesApi, "flushDoc"
|
||||||
|
sinon.spy MockProjectHistoryApi, "flushProject"
|
||||||
|
|
||||||
async.series @docs.map((doc) =>
|
async.series @docs.map((doc) =>
|
||||||
(callback) =>
|
(callback) =>
|
||||||
DocUpdaterClient.preloadDoc @project_id, doc.id, (error) =>
|
DocUpdaterClient.preloadDoc @project_id, doc.id, (error) =>
|
||||||
|
@ -68,6 +66,8 @@ describe "Deleting a project", ->
|
||||||
|
|
||||||
after ->
|
after ->
|
||||||
MockWebApi.setDocument.restore()
|
MockWebApi.setDocument.restore()
|
||||||
|
MockTrackChangesApi.flushDoc.restore()
|
||||||
|
MockProjectHistoryApi.flushProject.restore()
|
||||||
|
|
||||||
it "should return a 204 status code", ->
|
it "should return a 204 status code", ->
|
||||||
@statusCode.should.equal 204
|
@statusCode.should.equal 204
|
||||||
|
@ -96,3 +96,42 @@ describe "Deleting a project", ->
|
||||||
|
|
||||||
it "should flush each doc in project history", ->
|
it "should flush each doc in project history", ->
|
||||||
MockProjectHistoryApi.flushProject.calledWith(@project_id).should.equal true
|
MockProjectHistoryApi.flushProject.calledWith(@project_id).should.equal true
|
||||||
|
|
||||||
|
describe "with the shutdown=true parameter from realtime", ->
|
||||||
|
before (done) ->
|
||||||
|
sinon.spy MockWebApi, "setDocument"
|
||||||
|
sinon.spy MockTrackChangesApi, "flushDoc"
|
||||||
|
sinon.spy MockProjectHistoryApi, "flushProject"
|
||||||
|
|
||||||
|
async.series @docs.map((doc) =>
|
||||||
|
(callback) =>
|
||||||
|
DocUpdaterClient.preloadDoc @project_id, doc.id, callback
|
||||||
|
), (error) =>
|
||||||
|
throw error if error?
|
||||||
|
setTimeout () =>
|
||||||
|
DocUpdaterClient.deleteProjectOnShutdown @project_id, (error, res, body) =>
|
||||||
|
@statusCode = res.statusCode
|
||||||
|
done()
|
||||||
|
, 200
|
||||||
|
|
||||||
|
after ->
|
||||||
|
MockWebApi.setDocument.restore()
|
||||||
|
MockTrackChangesApi.flushDoc.restore()
|
||||||
|
MockProjectHistoryApi.flushProject.restore()
|
||||||
|
|
||||||
|
it "should return a 204 status code", ->
|
||||||
|
@statusCode.should.equal 204
|
||||||
|
|
||||||
|
it "should send each document to the web api", ->
|
||||||
|
for doc in @docs
|
||||||
|
MockWebApi.setDocument
|
||||||
|
.calledWith(@project_id, doc.id, doc.updatedLines)
|
||||||
|
.should.equal true
|
||||||
|
|
||||||
|
it "should flush each doc in track changes", ->
|
||||||
|
for doc in @docs
|
||||||
|
MockTrackChangesApi.flushDoc.calledWith(doc.id).should.equal true
|
||||||
|
|
||||||
|
it "should not flush to project history", ->
|
||||||
|
MockProjectHistoryApi.flushProject.called.should.equal false
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,9 @@ module.exports = DocUpdaterClient =
|
||||||
deleteProject: (project_id, callback = () ->) ->
|
deleteProject: (project_id, callback = () ->) ->
|
||||||
request.del "http://localhost:3003/project/#{project_id}", callback
|
request.del "http://localhost:3003/project/#{project_id}", callback
|
||||||
|
|
||||||
|
deleteProjectOnShutdown: (project_id, callback = () ->) ->
|
||||||
|
request.del "http://localhost:3003/project/#{project_id}?background=true&shutdown=true", callback
|
||||||
|
|
||||||
acceptChange: (project_id, doc_id, change_id, callback = () ->) ->
|
acceptChange: (project_id, doc_id, change_id, callback = () ->) ->
|
||||||
request.post "http://localhost:3003/project/#{project_id}/doc/#{doc_id}/change/#{change_id}/accept", callback
|
request.post "http://localhost:3003/project/#{project_id}/doc/#{doc_id}/change/#{change_id}/accept", callback
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue