mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Test creating, listing and revoking invites as owner
This commit is contained in:
parent
0e0ccb41ff
commit
5351e79c7a
1 changed files with 66 additions and 0 deletions
|
@ -87,6 +87,14 @@ tryLoginUser = (user, redir, callback=(err, response, body)->) ->
|
||||||
redir: redir
|
redir: redir
|
||||||
}, callback
|
}, callback
|
||||||
|
|
||||||
|
tryGetInviteList = (user, projectId, callback=(err, response, body)->) ->
|
||||||
|
user.getCsrfToken (error) =>
|
||||||
|
return callback(error) if error?
|
||||||
|
user.request.get {
|
||||||
|
url: "/project/#{projectId}/invites"
|
||||||
|
json: true
|
||||||
|
}, callback
|
||||||
|
|
||||||
|
|
||||||
# Expectations
|
# Expectations
|
||||||
expectProjectAccess = (user, projectId, callback=(err,result)->) ->
|
expectProjectAccess = (user, projectId, callback=(err,result)->) ->
|
||||||
|
@ -169,6 +177,14 @@ expectAcceptInviteAndRedirect = (user, invite, callback=(err,result)->) ->
|
||||||
expect(response.headers.location).to.equal "/project/#{invite.projectId}"
|
expect(response.headers.location).to.equal "/project/#{invite.projectId}"
|
||||||
callback()
|
callback()
|
||||||
|
|
||||||
|
expectInviteListCount = (user, projectId, count, callback=(err)->) ->
|
||||||
|
tryGetInviteList user, projectId, (err, response, body) ->
|
||||||
|
expect(err).to.be.oneOf [null, undefined]
|
||||||
|
expect(response.statusCode).to.equal 200
|
||||||
|
expect(body).to.have.all.keys ['invites']
|
||||||
|
expect(body.invites.length).to.equal count
|
||||||
|
callback()
|
||||||
|
|
||||||
|
|
||||||
describe "ProjectInviteTests", ->
|
describe "ProjectInviteTests", ->
|
||||||
before (done) ->
|
before (done) ->
|
||||||
|
@ -183,6 +199,56 @@ describe "ProjectInviteTests", ->
|
||||||
(cb) => @sendingUser.login cb
|
(cb) => @sendingUser.login cb
|
||||||
], done
|
], done
|
||||||
|
|
||||||
|
describe 'creating invites', ->
|
||||||
|
|
||||||
|
beforeEach (done) ->
|
||||||
|
@projectName = "wat"
|
||||||
|
@projectId = null
|
||||||
|
@fakeProject = null
|
||||||
|
done()
|
||||||
|
|
||||||
|
afterEach ->
|
||||||
|
|
||||||
|
describe 'creating two invites', ->
|
||||||
|
|
||||||
|
beforeEach (done) ->
|
||||||
|
Async.series [
|
||||||
|
(cb) =>
|
||||||
|
createProject @sendingUser, @projectName, (err, projectId, project) =>
|
||||||
|
@projectId = projectId
|
||||||
|
@fakeProject = project
|
||||||
|
cb()
|
||||||
|
], done
|
||||||
|
|
||||||
|
afterEach (done) ->
|
||||||
|
Async.series [
|
||||||
|
(cb) => @sendingUser.deleteProject(@projectId, cb)
|
||||||
|
(cb) => @sendingUser.deleteProject(@projectId, cb)
|
||||||
|
], done
|
||||||
|
|
||||||
|
it 'should allow the project owner to create and remove invites', (done) ->
|
||||||
|
@invite = null
|
||||||
|
Async.series [
|
||||||
|
(cb) => expectProjectAccess @sendingUser, @projectId, cb
|
||||||
|
(cb) => expectInviteListCount @sendingUser, @projectId, 0, cb
|
||||||
|
# create invite, check invite list count
|
||||||
|
(cb) => createInvite @sendingUser, @projectId, @email, (err, invite) =>
|
||||||
|
return cb(err) if err
|
||||||
|
@invite = invite
|
||||||
|
cb()
|
||||||
|
(cb) => expectInviteListCount @sendingUser, @projectId, 1, cb
|
||||||
|
(cb) => revokeInvite @sendingUser, @projectId, @invite._id, cb
|
||||||
|
(cb) => expectInviteListCount @sendingUser, @projectId, 0, cb
|
||||||
|
# and a second time
|
||||||
|
(cb) => createInvite @sendingUser, @projectId, @email, (err, invite) =>
|
||||||
|
return cb(err) if err
|
||||||
|
@invite = invite
|
||||||
|
cb()
|
||||||
|
(cb) => expectInviteListCount @sendingUser, @projectId, 1, cb
|
||||||
|
(cb) => revokeInvite @sendingUser, @projectId, @invite._id, cb
|
||||||
|
(cb) => expectInviteListCount @sendingUser, @projectId, 0, cb
|
||||||
|
], done
|
||||||
|
|
||||||
describe 'clicking the invite link', ->
|
describe 'clicking the invite link', ->
|
||||||
|
|
||||||
beforeEach (done) ->
|
beforeEach (done) ->
|
||||||
|
|
Loading…
Reference in a new issue