mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Fix up tests
This commit is contained in:
@@ -111,7 +111,8 @@ module.exports = settings =
|
|||||||
trackchanges:
|
trackchanges:
|
||||||
url : "http://localhost:3015"
|
url : "http://localhost:3015"
|
||||||
project_history:
|
project_history:
|
||||||
enabled: process.env.PROJECT_HISTORY_ENABLED == 'true' or false
|
sendProjectStructureOps: process.env.PROJECT_HISTORY_ENABLED == 'true' or false
|
||||||
|
initializeHistoryForNewProjects: process.env.PROJECT_HISTORY_ENABLED == 'true' or false
|
||||||
url : "http://localhost:3054"
|
url : "http://localhost:3054"
|
||||||
docstore:
|
docstore:
|
||||||
url : "http://#{process.env['DOCSTORE_HOST'] or 'localhost'}:3016"
|
url : "http://#{process.env['DOCSTORE_HOST'] or 'localhost'}:3016"
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ describe 'DocumentUpdaterHandler', ->
|
|||||||
|
|
||||||
describe "with project history disabled", ->
|
describe "with project history disabled", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@settings.apis.project_history.enabled = false
|
@settings.apis.project_history.sendProjectStructureOps = false
|
||||||
@request.post = sinon.stub()
|
@request.post = sinon.stub()
|
||||||
|
|
||||||
@handler.updateProjectStructure @project_id, @user_id, {}, @callback
|
@handler.updateProjectStructure @project_id, @user_id, {}, @callback
|
||||||
@@ -406,7 +406,7 @@ describe 'DocumentUpdaterHandler', ->
|
|||||||
|
|
||||||
describe "with project history enabled", ->
|
describe "with project history enabled", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@settings.apis.project_history.enabled = true
|
@settings.apis.project_history.sendProjectStructureOps = true
|
||||||
@url = "#{@settings.apis.documentupdater.url}/project/#{@project_id}"
|
@url = "#{@settings.apis.documentupdater.url}/project/#{@project_id}"
|
||||||
@request.post = sinon.stub().callsArgWith(1, null, {statusCode: 204}, "")
|
@request.post = sinon.stub().callsArgWith(1, null, {statusCode: 204}, "")
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ describe "HistoryController", ->
|
|||||||
|
|
||||||
describe "for a project with project history", ->
|
describe "for a project with project history", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@ProjectDetailsHandler.getDetails = sinon.stub().callsArgWith(1, null, {overleaf:{history:{display:true}}})
|
@ProjectDetailsHandler.getDetails = sinon.stub().callsArgWith(1, null, {overleaf:{history:{id: 42, display:true}}})
|
||||||
@HistoryController.selectHistoryApi @req, @res, @next
|
@HistoryController.selectHistoryApi @req, @res, @next
|
||||||
|
|
||||||
it "should set the flag for project history to true", ->
|
it "should set the flag for project history to true", ->
|
||||||
@@ -57,93 +57,55 @@ describe "HistoryController", ->
|
|||||||
on: (event, handler) -> @events[event] = handler
|
on: (event, handler) -> @events[event] = handler
|
||||||
@request.returns @proxy
|
@request.returns @proxy
|
||||||
|
|
||||||
describe "with project history enabled", ->
|
describe "for a project with the project history flag", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@settings.apis.project_history.enabled = true
|
@req.useProjectHistory = true
|
||||||
|
@HistoryController.proxyToHistoryApi @req, @res, @next
|
||||||
|
|
||||||
describe "for a project with the project history flag", ->
|
it "should get the user id", ->
|
||||||
beforeEach ->
|
@AuthenticationController.getLoggedInUserId
|
||||||
@req.useProjectHistory = true
|
.calledWith(@req)
|
||||||
@HistoryController.proxyToHistoryApi @req, @res, @next
|
.should.equal true
|
||||||
|
|
||||||
it "should get the user id", ->
|
it "should call the project history api", ->
|
||||||
@AuthenticationController.getLoggedInUserId
|
@request
|
||||||
.calledWith(@req)
|
.calledWith({
|
||||||
.should.equal true
|
url: "#{@settings.apis.project_history.url}#{@req.url}"
|
||||||
|
method: @req.method
|
||||||
|
headers:
|
||||||
|
"X-User-Id": @user_id
|
||||||
|
})
|
||||||
|
.should.equal true
|
||||||
|
|
||||||
it "should call the project history api", ->
|
it "should pipe the response to the client", ->
|
||||||
@request
|
@proxy.pipe
|
||||||
.calledWith({
|
.calledWith(@res)
|
||||||
url: "#{@settings.apis.project_history.url}#{@req.url}"
|
.should.equal true
|
||||||
method: @req.method
|
|
||||||
headers:
|
|
||||||
"X-User-Id": @user_id
|
|
||||||
})
|
|
||||||
.should.equal true
|
|
||||||
|
|
||||||
it "should pipe the response to the client", ->
|
describe "for a project without the project history flag", ->
|
||||||
@proxy.pipe
|
|
||||||
.calledWith(@res)
|
|
||||||
.should.equal true
|
|
||||||
|
|
||||||
describe "for a project without the project history flag", ->
|
|
||||||
beforeEach ->
|
|
||||||
@req.useProjectHistory = false
|
|
||||||
@HistoryController.proxyToHistoryApi @req, @res, @next
|
|
||||||
|
|
||||||
it "should get the user id", ->
|
|
||||||
@AuthenticationController.getLoggedInUserId
|
|
||||||
.calledWith(@req)
|
|
||||||
.should.equal true
|
|
||||||
|
|
||||||
it "should call the track changes api", ->
|
|
||||||
@request
|
|
||||||
.calledWith({
|
|
||||||
url: "#{@settings.apis.trackchanges.url}#{@req.url}"
|
|
||||||
method: @req.method
|
|
||||||
headers:
|
|
||||||
"X-User-Id": @user_id
|
|
||||||
})
|
|
||||||
.should.equal true
|
|
||||||
|
|
||||||
it "should pipe the response to the client", ->
|
|
||||||
@proxy.pipe
|
|
||||||
.calledWith(@res)
|
|
||||||
.should.equal true
|
|
||||||
|
|
||||||
describe "with project history disabled", ->
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@settings.apis.project_history.enabled = false
|
@req.useProjectHistory = false
|
||||||
|
@HistoryController.proxyToHistoryApi @req, @res, @next
|
||||||
|
|
||||||
describe "for a project with the project history flag", ->
|
it "should get the user id", ->
|
||||||
beforeEach ->
|
@AuthenticationController.getLoggedInUserId
|
||||||
@req.useProjectHistory = true
|
.calledWith(@req)
|
||||||
@HistoryController.proxyToHistoryApi @req, @res, @next
|
.should.equal true
|
||||||
|
|
||||||
it "should call the track changes api", ->
|
it "should call the track changes api", ->
|
||||||
@request
|
@request
|
||||||
.calledWith({
|
.calledWith({
|
||||||
url: "#{@settings.apis.trackchanges.url}#{@req.url}"
|
url: "#{@settings.apis.trackchanges.url}#{@req.url}"
|
||||||
method: @req.method
|
method: @req.method
|
||||||
headers:
|
headers:
|
||||||
"X-User-Id": @user_id
|
"X-User-Id": @user_id
|
||||||
})
|
})
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
describe "for a project without the project history flag", ->
|
it "should pipe the response to the client", ->
|
||||||
beforeEach ->
|
@proxy.pipe
|
||||||
@req.useProjectHistory = false
|
.calledWith(@res)
|
||||||
@HistoryController.proxyToHistoryApi @req, @res, @next
|
.should.equal true
|
||||||
|
|
||||||
it "should call the track changes api", ->
|
|
||||||
@request
|
|
||||||
.calledWith({
|
|
||||||
url: "#{@settings.apis.trackchanges.url}#{@req.url}"
|
|
||||||
method: @req.method
|
|
||||||
headers:
|
|
||||||
"X-User-Id": @user_id
|
|
||||||
})
|
|
||||||
.should.equal true
|
|
||||||
|
|
||||||
describe "with an error", ->
|
describe "with an error", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@@ -156,7 +118,7 @@ describe "HistoryController", ->
|
|||||||
describe "initializeProject", ->
|
describe "initializeProject", ->
|
||||||
describe "with project history enabled", ->
|
describe "with project history enabled", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@settings.apis.project_history.enabled = true
|
@settings.apis.project_history.initializeHistoryForNewProjects = true
|
||||||
|
|
||||||
describe "project history returns a successful response", ->
|
describe "project history returns a successful response", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@@ -212,7 +174,7 @@ describe "HistoryController", ->
|
|||||||
|
|
||||||
describe "with project history disabled", ->
|
describe "with project history disabled", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@settings.apis.project_history.enabled = false
|
@settings.apis.project_history.initializeHistoryForNewProjects = false
|
||||||
@HistoryController.initializeProject @callback
|
@HistoryController.initializeProject @callback
|
||||||
|
|
||||||
it "should return the callback", ->
|
it "should return the callback", ->
|
||||||
|
|||||||
Reference in New Issue
Block a user