overleaf/services/web/test/acceptance/coffee/ProjectInviteTests.coffee

80 lines
1.9 KiB
CoffeeScript
Raw Normal View History

expect = require("chai").expect
Async = require("async")
User = require "./helpers/User"
request = require "./helpers/request"
settings = require "settings-sharelatex"
2016-07-28 11:00:18 -04:00
CollaboratorsEmailHandler = require "../../../app/js/Features/Collaborators/CollaboratorsEmailHandler"
_createInvite = (projectId, user, email, callback=(err, invite)->) ->
user.getCsrfToken (err) ->
return callback(err) if err
user.request.post {
url: "/project/#{projectId}/invite",
json:
email: email
}, (err, response, body) ->
return callback(err) if err
callback(err, body.invite)
describe "ProjectInviteTests", ->
before (done) ->
@timeout(20000)
@sendingUser = new User()
@user = new User()
@site_admin = new User({email: "admin@example.com"})
2016-07-28 11:00:18 -04:00
@email = 'user@example.com'
@projectName = 'sharing test'
@projectId = null
2016-07-28 11:00:18 -04:00
@fakeProject = null
Async.series [
(cb) => @user.login cb
(cb) => @sendingUser.login cb
2016-07-28 11:00:18 -04:00
(cb) => @sendingUser.createProject(@projectName, (err, projectId, project) =>
throw err if err
@projectId = projectId
2016-07-28 11:00:18 -04:00
@fakeProject = {
_id: projectId,
name: @projectName,
owner_ref: @sendingUser
}
cb()
)
], done
2016-07-28 11:00:18 -04:00
after (done) ->
Async.series [
(cb) => @sendingUser.deleteProject(@projectId, cb)
], done
describe "user is logged in", ->
beforeEach (done) ->
@user.login (err) =>
if err
throw err
done()
describe 'user is already a member of the project', ->
2016-07-28 11:00:18 -04:00
beforeEach (done) ->
@invite = null
@link = null
_createInvite @projectId, @sendingUser, @email, (err, invite) =>
@invite = invite
@link = CollaboratorsEmailHandler._buildInviteUrl(@fakeProject, @invite)
done()
it 'should redirect to the project page', (done) ->
Async.series(
[
(cb) =>
2016-07-28 11:00:18 -04:00
console.log ">> yes"
cb()
], (err, result) =>
if err
throw err
done()
)