2014-08-19 09:54:33 +00:00
|
|
|
child = require "child_process"
|
|
|
|
fs = require "fs"
|
|
|
|
assert = require("assert")
|
2014-02-12 10:23:40 +00:00
|
|
|
chai = require("chai")
|
|
|
|
chai.should()
|
|
|
|
expect = chai.expect
|
|
|
|
Settings = require "settings-sharelatex"
|
|
|
|
port = Settings.internal?.web?.port or Settings.port or 3000
|
2014-08-19 11:01:30 +00:00
|
|
|
cookeFilePath = "/tmp/smoke-test-cookie-#{port}.txt"
|
2014-08-19 13:35:20 +00:00
|
|
|
buildUrl = (path) -> " -b #{cookeFilePath} -c #{cookeFilePath} -H 'X-Forwarded-Proto: https' --resolve 'smoke#{Settings.cookieDomain}:#{port}:127.0.0.1' http://smoke#{Settings.cookieDomain}:#{port}/#{path}?setLng=en"
|
2014-02-12 10:23:40 +00:00
|
|
|
|
|
|
|
describe "Opening", ->
|
2014-08-19 09:54:33 +00:00
|
|
|
|
2014-02-12 10:23:40 +00:00
|
|
|
before (done) ->
|
|
|
|
|
2014-08-19 13:35:20 +00:00
|
|
|
command = """
|
|
|
|
curl #{buildUrl('register')}
|
|
|
|
"""
|
2014-08-19 09:54:33 +00:00
|
|
|
child.exec command, (err, stdout, stderr)->
|
2014-08-19 10:17:51 +00:00
|
|
|
if err? then done(err)
|
2014-08-19 09:54:33 +00:00
|
|
|
csrf = stdout.match("<input name=\"_csrf\" type=\"hidden\" value=\"(.*?)\">")[1]
|
2014-08-19 13:35:20 +00:00
|
|
|
|
2014-08-19 09:54:33 +00:00
|
|
|
command = """
|
2014-08-19 10:17:51 +00:00
|
|
|
curl -H "Content-Type: application/json" -d '{"_csrf":"#{csrf}", "email":"#{Settings.smokeTest.user}", "password":"#{Settings.smokeTest.password}"}' #{buildUrl('register')}
|
2014-08-19 09:54:33 +00:00
|
|
|
"""
|
2014-08-19 13:35:20 +00:00
|
|
|
|
2014-08-19 09:54:33 +00:00
|
|
|
child.exec command, (err, stdout, stderr)->
|
2014-08-19 13:35:20 +00:00
|
|
|
|
2014-08-19 10:17:51 +00:00
|
|
|
done(err)
|
2014-05-19 10:53:10 +00:00
|
|
|
|
2014-08-19 09:54:33 +00:00
|
|
|
after (done)->
|
2014-08-19 11:01:30 +00:00
|
|
|
fs.unlink cookeFilePath, done
|
2014-08-19 09:54:33 +00:00
|
|
|
|
2014-05-19 10:53:10 +00:00
|
|
|
|
2014-02-12 10:23:40 +00:00
|
|
|
it "a project", (done) ->
|
2014-08-19 10:17:51 +00:00
|
|
|
@timeout(4000)
|
|
|
|
command = """
|
2014-08-19 13:35:20 +00:00
|
|
|
curl -v #{buildUrl("project/#{Settings.smokeTest.projectId}")}
|
2014-08-19 10:17:51 +00:00
|
|
|
"""
|
|
|
|
child.exec command, (error, stdout, stderr)->
|
|
|
|
expect(error, "smoke test: error in getting project").to.not.exist
|
|
|
|
|
|
|
|
statusCodeMatch = !!stderr.match("200 OK")
|
|
|
|
expect(statusCodeMatch, "smoke test: response code is not 200 getting project").to.equal true
|
|
|
|
|
|
|
|
# Check that the project id is present in the javascript that loads up the project
|
|
|
|
match = !!stdout.match("window.project_id = \"#{Settings.smokeTest.projectId}\"")
|
|
|
|
expect(match, "smoke test: project page html does not have project_id").to.equal true
|
|
|
|
done()
|
2014-02-12 10:23:40 +00:00
|
|
|
|
2014-08-08 12:11:49 +00:00
|
|
|
|
2014-02-12 10:23:40 +00:00
|
|
|
it "the project list", (done) ->
|
2014-08-19 10:17:51 +00:00
|
|
|
@timeout(4000)
|
|
|
|
command = """
|
2014-08-19 13:35:20 +00:00
|
|
|
curl -v #{buildUrl("project")}
|
2014-08-19 10:17:51 +00:00
|
|
|
"""
|
|
|
|
child.exec command, (error, stdout, stderr)->
|
|
|
|
|
|
|
|
expect(error, "smoke test: error returned in getting project list").to.not.exist
|
|
|
|
expect(!!stderr.match("200 OK"), "smoke test: response code is not 200 getting project list").to.equal true
|
|
|
|
expect(!!stdout.match("<title>Your Projects - ShareLaTeX, Online LaTeX Editor</title>"), "smoke test: body does not have correct title").to.equal true
|
|
|
|
expect(!!stdout.match("ProjectPageController"), "smoke test: body does not have correct angular controller").to.equal true
|
|
|
|
done()
|
2014-02-12 10:23:40 +00:00
|
|
|
|
2014-08-19 09:54:33 +00:00
|
|
|
|