mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Fix acceptance tests
This commit is contained in:
parent
993c261b10
commit
b09a41c557
2 changed files with 42 additions and 20 deletions
|
@ -34,9 +34,9 @@ describe "Sessions", ->
|
||||||
expect(sessions[0].slice(0, 5)).to.equal 'sess:'
|
expect(sessions[0].slice(0, 5)).to.equal 'sess:'
|
||||||
next()
|
next()
|
||||||
|
|
||||||
# should be able to access settings page
|
# should be able to access project list page
|
||||||
, (next) =>
|
, (next) =>
|
||||||
@user1.getUserSettingsPage (err, statusCode) =>
|
@user1.getProjectListPage (err, statusCode) =>
|
||||||
expect(err).to.equal null
|
expect(err).to.equal null
|
||||||
expect(statusCode).to.equal 200
|
expect(statusCode).to.equal 200
|
||||||
next()
|
next()
|
||||||
|
@ -94,15 +94,15 @@ describe "Sessions", ->
|
||||||
expect(sessions[1].slice(0, 5)).to.equal 'sess:'
|
expect(sessions[1].slice(0, 5)).to.equal 'sess:'
|
||||||
next()
|
next()
|
||||||
|
|
||||||
# both should be able to access settings page
|
# both should be able to access project list page
|
||||||
, (next) =>
|
, (next) =>
|
||||||
@user1.getUserSettingsPage (err, statusCode) =>
|
@user1.getProjectListPage (err, statusCode) =>
|
||||||
expect(err).to.equal null
|
expect(err).to.equal null
|
||||||
expect(statusCode).to.equal 200
|
expect(statusCode).to.equal 200
|
||||||
next()
|
next()
|
||||||
|
|
||||||
, (next) =>
|
, (next) =>
|
||||||
@user2.getUserSettingsPage (err, statusCode) =>
|
@user2.getProjectListPage (err, statusCode) =>
|
||||||
expect(err).to.equal null
|
expect(err).to.equal null
|
||||||
expect(statusCode).to.equal 200
|
expect(statusCode).to.equal 200
|
||||||
next()
|
next()
|
||||||
|
@ -117,16 +117,16 @@ describe "Sessions", ->
|
||||||
expect(sessions.length).to.equal 1
|
expect(sessions.length).to.equal 1
|
||||||
next()
|
next()
|
||||||
|
|
||||||
# first session should not have access to settings page
|
# first session should not have access to project list page
|
||||||
, (next) =>
|
, (next) =>
|
||||||
@user1.getUserSettingsPage (err, statusCode) =>
|
@user1.getProjectListPage (err, statusCode) =>
|
||||||
expect(err).to.equal null
|
expect(err).to.equal null
|
||||||
expect(statusCode).to.equal 302
|
expect(statusCode).to.equal 302
|
||||||
next()
|
next()
|
||||||
|
|
||||||
# second session should still have access to settings
|
# second session should still have access to settings
|
||||||
, (next) =>
|
, (next) =>
|
||||||
@user2.getUserSettingsPage (err, statusCode) =>
|
@user2.getProjectListPage (err, statusCode) =>
|
||||||
expect(err).to.equal null
|
expect(err).to.equal null
|
||||||
expect(statusCode).to.equal 200
|
expect(statusCode).to.equal 200
|
||||||
next()
|
next()
|
||||||
|
@ -141,9 +141,9 @@ describe "Sessions", ->
|
||||||
expect(sessions.length).to.equal 0
|
expect(sessions.length).to.equal 0
|
||||||
next()
|
next()
|
||||||
|
|
||||||
# second session should not have access to settings page
|
# second session should not have access to project list page
|
||||||
, (next) =>
|
, (next) =>
|
||||||
@user2.getUserSettingsPage (err, statusCode) =>
|
@user2.getProjectListPage (err, statusCode) =>
|
||||||
expect(err).to.equal null
|
expect(err).to.equal null
|
||||||
expect(statusCode).to.equal 302
|
expect(statusCode).to.equal 302
|
||||||
next()
|
next()
|
||||||
|
@ -216,22 +216,22 @@ describe "Sessions", ->
|
||||||
expect(sessions.length).to.equal 1
|
expect(sessions.length).to.equal 1
|
||||||
next()
|
next()
|
||||||
|
|
||||||
# users one and three should not be able to access settings page
|
# users one and three should not be able to access project list page
|
||||||
, (next) =>
|
, (next) =>
|
||||||
@user1.getUserSettingsPage (err, statusCode) =>
|
@user1.getProjectListPage (err, statusCode) =>
|
||||||
expect(err).to.equal null
|
expect(err).to.equal null
|
||||||
expect(statusCode).to.equal 302
|
expect(statusCode).to.equal 302
|
||||||
next()
|
next()
|
||||||
|
|
||||||
, (next) =>
|
, (next) =>
|
||||||
@user3.getUserSettingsPage (err, statusCode) =>
|
@user3.getProjectListPage (err, statusCode) =>
|
||||||
expect(err).to.equal null
|
expect(err).to.equal null
|
||||||
expect(statusCode).to.equal 302
|
expect(statusCode).to.equal 302
|
||||||
next()
|
next()
|
||||||
|
|
||||||
# user two should still be logged in, and able to access settings page
|
# user two should still be logged in, and able to access project list page
|
||||||
, (next) =>
|
, (next) =>
|
||||||
@user2.getUserSettingsPage (err, statusCode) =>
|
@user2.getProjectListPage (err, statusCode) =>
|
||||||
expect(err).to.equal null
|
expect(err).to.equal null
|
||||||
expect(statusCode).to.equal 200
|
expect(statusCode).to.equal 200
|
||||||
next()
|
next()
|
||||||
|
@ -305,6 +305,19 @@ describe "Sessions", ->
|
||||||
expect(sessions[1].slice(0, 5)).to.equal 'sess:'
|
expect(sessions[1].slice(0, 5)).to.equal 'sess:'
|
||||||
next()
|
next()
|
||||||
|
|
||||||
|
# enter sudo-mode
|
||||||
|
, (next) =>
|
||||||
|
@user2.getCsrfToken (err) =>
|
||||||
|
expect(err).to.be.oneOf [null, undefined]
|
||||||
|
@user2.request.post {
|
||||||
|
uri: '/confirm-password/submit',
|
||||||
|
json:
|
||||||
|
password: @user2.password
|
||||||
|
}, (err, response, body) =>
|
||||||
|
expect(err).to.be.oneOf [null, undefined]
|
||||||
|
expect(response.statusCode).to.equal 200
|
||||||
|
next()
|
||||||
|
|
||||||
# check the sessions page
|
# check the sessions page
|
||||||
, (next) =>
|
, (next) =>
|
||||||
@user2.request.get {
|
@user2.request.get {
|
||||||
|
@ -328,22 +341,22 @@ describe "Sessions", ->
|
||||||
expect(sessions.length).to.equal 1
|
expect(sessions.length).to.equal 1
|
||||||
next()
|
next()
|
||||||
|
|
||||||
# users one and three should not be able to access settings page
|
# users one and three should not be able to access project list page
|
||||||
, (next) =>
|
, (next) =>
|
||||||
@user1.getUserSettingsPage (err, statusCode) =>
|
@user1.getProjectListPage (err, statusCode) =>
|
||||||
expect(err).to.equal null
|
expect(err).to.equal null
|
||||||
expect(statusCode).to.equal 302
|
expect(statusCode).to.equal 302
|
||||||
next()
|
next()
|
||||||
|
|
||||||
, (next) =>
|
, (next) =>
|
||||||
@user3.getUserSettingsPage (err, statusCode) =>
|
@user3.getProjectListPage (err, statusCode) =>
|
||||||
expect(err).to.equal null
|
expect(err).to.equal null
|
||||||
expect(statusCode).to.equal 302
|
expect(statusCode).to.equal 302
|
||||||
next()
|
next()
|
||||||
|
|
||||||
# user two should still be logged in, and able to access settings page
|
# user two should still be logged in, and able to access project list page
|
||||||
, (next) =>
|
, (next) =>
|
||||||
@user2.getUserSettingsPage (err, statusCode) =>
|
@user2.getProjectListPage (err, statusCode) =>
|
||||||
expect(err).to.equal null
|
expect(err).to.equal null
|
||||||
expect(statusCode).to.equal 200
|
expect(statusCode).to.equal 200
|
||||||
next()
|
next()
|
||||||
|
|
|
@ -134,6 +134,15 @@ class User
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
callback(null, response.statusCode)
|
callback(null, response.statusCode)
|
||||||
|
|
||||||
|
getProjectListPage: (callback=(error, statusCode)->) ->
|
||||||
|
@getCsrfToken (error) =>
|
||||||
|
return callback(error) if error?
|
||||||
|
@request.get {
|
||||||
|
url: "/project"
|
||||||
|
}, (error, response, body) =>
|
||||||
|
return callback(error) if error?
|
||||||
|
callback(null, response.statusCode)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = User
|
module.exports = User
|
||||||
|
|
Loading…
Reference in a new issue