mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-24 18:33:44 +00:00
Add tests for getting V1 projects
This commit is contained in:
parent
9bf74f29bd
commit
fff6873e10
1 changed files with 35 additions and 1 deletions
|
@ -54,6 +54,8 @@ describe "ProjectController", ->
|
||||||
@ProjectGetter =
|
@ProjectGetter =
|
||||||
findAllUsersProjects: sinon.stub()
|
findAllUsersProjects: sinon.stub()
|
||||||
getProject: sinon.stub()
|
getProject: sinon.stub()
|
||||||
|
@V1ProjectGetter =
|
||||||
|
findAllUsersProjects: sinon.stub()
|
||||||
@AuthenticationController =
|
@AuthenticationController =
|
||||||
getLoggedInUser: sinon.stub().callsArgWith(1, null, @user)
|
getLoggedInUser: sinon.stub().callsArgWith(1, null, @user)
|
||||||
getLoggedInUserId: sinon.stub().returns(@user._id)
|
getLoggedInUserId: sinon.stub().returns(@user._id)
|
||||||
|
@ -89,6 +91,7 @@ describe "ProjectController", ->
|
||||||
"./ProjectUpdateHandler":@ProjectUpdateHandler
|
"./ProjectUpdateHandler":@ProjectUpdateHandler
|
||||||
"../ReferencesSearch/ReferencesSearchHandler": @ReferencesSearchHandler
|
"../ReferencesSearch/ReferencesSearchHandler": @ReferencesSearchHandler
|
||||||
"./ProjectGetter": @ProjectGetter
|
"./ProjectGetter": @ProjectGetter
|
||||||
|
'./V1ProjectGetter': @V1ProjectGetter
|
||||||
'../Authentication/AuthenticationController': @AuthenticationController
|
'../Authentication/AuthenticationController': @AuthenticationController
|
||||||
"../Analytics/AnalyticsManager": @AnalyticsManager
|
"../Analytics/AnalyticsManager": @AnalyticsManager
|
||||||
"../TokenAccess/TokenAccessHandler": @TokenAccessHandler
|
"../TokenAccess/TokenAccessHandler": @TokenAccessHandler
|
||||||
|
@ -263,6 +266,7 @@ describe "ProjectController", ->
|
||||||
@TagsHandler.getAllTags.callsArgWith(1, null, @tags, {})
|
@TagsHandler.getAllTags.callsArgWith(1, null, @tags, {})
|
||||||
@NotificationsHandler.getUserNotifications = sinon.stub().callsArgWith(1, null, @notifications, {})
|
@NotificationsHandler.getUserNotifications = sinon.stub().callsArgWith(1, null, @notifications, {})
|
||||||
@ProjectGetter.findAllUsersProjects.callsArgWith(2, null, @allProjects)
|
@ProjectGetter.findAllUsersProjects.callsArgWith(2, null, @allProjects)
|
||||||
|
@V1ProjectGetter.findAllUsersProjects.callsArg(1) # Without integration module cb returns without args
|
||||||
|
|
||||||
it "should render the project/list page", (done)->
|
it "should render the project/list page", (done)->
|
||||||
@res.render = (pageName, opts)=>
|
@res.render = (pageName, opts)=>
|
||||||
|
@ -278,7 +282,7 @@ describe "ProjectController", ->
|
||||||
|
|
||||||
it "should send the projects", (done)->
|
it "should send the projects", (done)->
|
||||||
@res.render = (pageName, opts)=>
|
@res.render = (pageName, opts)=>
|
||||||
opts.projects.length.should.equal (@projects.length + @collabertions.length + @readOnly.length + @tokenReadAndWrite.length + @tokenReadOnly.length)
|
opts.projects.length.should.equal (@projects.length + @collabertions.length + @readOnly.length)
|
||||||
done()
|
done()
|
||||||
@ProjectController.projectListPage @req, @res
|
@ProjectController.projectListPage @req, @res
|
||||||
|
|
||||||
|
@ -295,6 +299,36 @@ describe "ProjectController", ->
|
||||||
done()
|
done()
|
||||||
@ProjectController.projectListPage @req, @res
|
@ProjectController.projectListPage @req, @res
|
||||||
|
|
||||||
|
describe 'with overleaf-integration-web-module', ->
|
||||||
|
beforeEach ->
|
||||||
|
@V1Response =
|
||||||
|
projects: [
|
||||||
|
{ id: '123mockV1Id', title: 'mock title', updated_at: 1509616411, removed: false, archived: false }
|
||||||
|
{ id: '456mockV1Id', title: 'mock title 2', updated_at: 1509616411, removed: true, archived: false }
|
||||||
|
],
|
||||||
|
tags: [
|
||||||
|
{ name: 'mock tag', project_ids: ['123mockV1Id'] }
|
||||||
|
]
|
||||||
|
@V1ProjectGetter.findAllUsersProjects.callsArgWith(1, null, @V1Response)
|
||||||
|
|
||||||
|
it 'should include V1 projects', (done) ->
|
||||||
|
@res.render = (pageName, opts) =>
|
||||||
|
opts.projects.length.should.equal (@projects.length + @collabertions.length + @readOnly.length + @V1Response.projects.length)
|
||||||
|
done()
|
||||||
|
@ProjectController.projectListPage @req, @res
|
||||||
|
|
||||||
|
it 'should include V1 tags', (done) ->
|
||||||
|
@res.render = (pageName, opts) =>
|
||||||
|
opts.tags.length.should.equal (@tags.length + @V1Response.tags.length)
|
||||||
|
done()
|
||||||
|
@ProjectController.projectListPage @req, @res
|
||||||
|
|
||||||
|
it 'should have isShowingV1Projects flag', (done) ->
|
||||||
|
@res.render = (pageName, opts) =>
|
||||||
|
opts.isShowingV1Projects.should.equal true
|
||||||
|
done()
|
||||||
|
@ProjectController.projectListPage @req, @res
|
||||||
|
|
||||||
describe "projectListPage with duplicate projects", ->
|
describe "projectListPage with duplicate projects", ->
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
|
Loading…
Reference in a new issue