overleaf/services/web/test/smoke/coffee/SmokeTests.coffee

64 lines
2.2 KiB
CoffeeScript
Raw Normal View History

2014-08-19 05:54:33 -04:00
child = require "child_process"
fs = require "fs"
assert = require("assert")
2014-02-12 05:23:40 -05:00
chai = require("chai")
chai.should()
expect = chai.expect
Settings = require "settings-sharelatex"
2014-02-12 05:23:40 -05:00
port = Settings.internal?.web?.port or Settings.port or 3000
2014-08-19 05:54:33 -04:00
buildUrl = (path) -> "http://www.sharelatex.dev:#{port}/#{path}"
2014-02-12 05:23:40 -05:00
describe "Opening", ->
2014-08-19 05:54:33 -04:00
2014-02-12 05:23:40 -05:00
before (done) ->
2014-08-19 05:54:33 -04:00
command = "curl -b cookies.txt -c cookies.txt #{buildUrl('register')}"
child.exec command, (err, stdout, stderr)->
csrf = stdout.match("<input name=\"_csrf\" type=\"hidden\" value=\"(.*?)\">")[1]
command = """
curl -b cookies.txt -c cookies.txt -H "Content-Type: application/json" -d '{"_csrf":"#{csrf}", "email":"#{Settings.smokeTest.user}", "password":"#{Settings.smokeTest.password}"}' http://www.sharelatex.dev:3000/register
"""
console.log csrf
2014-05-19 06:53:10 -04:00
2014-08-19 05:54:33 -04:00
child.exec command, (err, stdout, stderr)->
done()
2014-05-19 06:53:10 -04:00
2014-08-19 05:54:33 -04:00
after (done)->
fs.unlink "cookies.txt", done
2014-05-19 06:53:10 -04:00
2014-02-12 05:23:40 -05:00
it "a project", (done) ->
2014-08-19 05:54:33 -04:00
# request {
# url: buildUrl("project/#{Settings.smokeTest.projectId}")
# headers:
# "X-Forwarded-Proto": "https"
# }, (error, response, body) ->
# expect(error, "smoke test: error in getting project").to.not.exist
# expect(response.statusCode, "smoke test: response code is not 200 getting project").to.equal(200)
# # Check that the project id is present in the javascript that loads up the project
# match = !!body.match("window.project_id = \"#{Settings.smokeTest.projectId}\"")
# expect(match, "smoke test: project page html does not have project_id").to.equal true
# done()
done()
2014-02-12 05:23:40 -05:00
2014-02-12 05:23:40 -05:00
it "the project list", (done) ->
2014-08-19 05:54:33 -04:00
# request {
# url: buildUrl("project")
# headers:
# "X-Forwarded-Proto": "https"
# }, (error, response, body) ->
# expect(error, "smoke test: error returned in getting project list").to.not.exist
# expect(response.statusCode, "smoke test: response code is not 200 getting project list").to.equal(200)
# expect(!!body.match("<title>Your Projects - ShareLaTeX, Online LaTeX Editor</title>"), "smoke test: body does not have correct title").to.equal true
# expect(!!body.match("ProjectPageController"), "smoke test: body does not have correct angular controller").to.equal true
# done()
done()
2014-02-12 05:23:40 -05:00
2014-08-19 05:54:33 -04:00