mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Move acceptance tests to single process pattern
This commit is contained in:
parent
35a861bfec
commit
a59dc9e149
8 changed files with 46 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -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) ->
|
||||
|
|
|
@ -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) ->
|
||||
|
|
|
@ -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) ->
|
||||
|
|
|
@ -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) ->
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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) ->
|
||||
|
|
20
services/chat/test/acceptance/coffee/helpers/ChatApp.coffee
Normal file
20
services/chat/test/acceptance/coffee/helpers/ChatApp.coffee
Normal 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()
|
Loading…
Reference in a new issue