Move acceptance tests to single process pattern

This commit is contained in:
James Allen 2018-01-29 12:01:26 +00:00
parent 35a861bfec
commit a59dc9e149
8 changed files with 46 additions and 11 deletions

View file

@ -3,9 +3,11 @@ settings = require 'settings-sharelatex'
Server = require "./app/js/server"
port = settings.internal?.chat?.port or 3010
host = settings.internal?.chat?.host or "localhost"
if !module.parent # Called directly
port = settings.internal?.chat?.port or 3010
host = settings.internal?.chat?.host or "localhost"
Server.server.listen port, host, (error) ->
throw error if error?
logger.info "Chat starting up, listening on #{host}:#{port}"
Server.server.listen port, host, (error) ->
throw error if error?
logger.info "Chat starting up, listening on #{host}:#{port}"
module.exports = Server.server

View file

@ -2,12 +2,14 @@
expect = require("chai").expect
ChatClient = require "./helpers/ChatClient"
ChatApp = require "./helpers/ChatApp"
describe "Deleting a message", ->
before ->
before (done) ->
@project_id = ObjectId().toString()
@user_id = ObjectId().toString()
@thread_id = ObjectId().toString()
ChatApp.ensureRunning done
describe "in a thread", ->
before (done) ->

View file

@ -3,11 +3,13 @@ expect = require("chai").expect
crypto = require "crypto"
ChatClient = require "./helpers/ChatClient"
ChatApp = require "./helpers/ChatApp"
describe "Deleting a thread", ->
before ->
before (done) ->
@project_id = ObjectId().toString()
@user_id = ObjectId().toString()
ChatApp.ensureRunning done
describe "with a thread that is deleted", ->
before (done) ->

View file

@ -2,12 +2,14 @@
expect = require("chai").expect
ChatClient = require "./helpers/ChatClient"
ChatApp = require "./helpers/ChatApp"
describe "Editing a message", ->
before ->
before (done) ->
@project_id = ObjectId().toString()
@user_id = ObjectId().toString()
@thread_id = ObjectId().toString()
ChatApp.ensureRunning done
describe "in a thread", ->
before (done) ->

View file

@ -4,13 +4,15 @@ async = require "async"
crypto = require "crypto"
ChatClient = require "./helpers/ChatClient"
ChatApp = require "./helpers/ChatApp"
describe "Getting messages", ->
before ->
before (done) ->
@user_id1 = ObjectId().toString()
@user_id2 = ObjectId().toString()
@content1 = "foo bar"
@content2 = "hello world"
ChatApp.ensureRunning done
describe "globally", ->
before (done) ->

View file

@ -3,11 +3,14 @@ expect = require("chai").expect
crypto = require "crypto"
ChatClient = require "./helpers/ChatClient"
ChatApp = require "./helpers/ChatApp"
describe "Resolving a thread", ->
before ->
before (done) ->
@project_id = ObjectId().toString()
@user_id = ObjectId().toString()
ChatApp.ensureRunning done
describe "with a resolved thread", ->
before (done) ->
@thread_id = ObjectId().toString()

View file

@ -2,9 +2,11 @@
expect = require("chai").expect
ChatClient = require "./helpers/ChatClient"
ChatApp = require "./helpers/ChatApp"
describe "Sending a message", ->
before ->
before (done) ->
ChatApp.ensureRunning done
describe "globally", ->
before (done) ->

View file

@ -0,0 +1,20 @@
app = require('../../../../app')
require("logger-sharelatex").logger.level("error")
module.exports =
running: false
initing: false
callbacks: []
ensureRunning: (callback = (error) ->) ->
if @running
return callback()
else if @initing
@callbacks.push callback
else
@initing = true
@callbacks.push callback
app.listen 3010, "localhost", (error) =>
throw error if error?
@running = true
for callback in @callbacks
callback()