Fix acceptance tests

This commit is contained in:
James Allen 2016-12-08 11:12:07 +00:00
parent 02194f7f86
commit 4cff89becc
3 changed files with 24 additions and 11 deletions

View file

@ -117,7 +117,7 @@ module.exports = WebsocketController =
AuthorizationManager.assertClientCanViewProjectAndDoc client, cursorData.doc_id, (error) ->
if error?
logger.warn {client_id: client.id, project_id, user_id}, "silently ignoring unauthorized updateClientPosition. Client likely hasn't called joinProject yet."
logger.warn {err: error, client_id: client.id, project_id, user_id}, "silently ignoring unauthorized updateClientPosition. Client likely hasn't called joinProject yet."
return callback()
cursorData.id = client.id
cursorData.user_id = user_id if user_id?

View file

@ -15,22 +15,28 @@ describe "clientTracking", ->
(cb) =>
FixturesManager.setUpProject {
privilegeLevel: "owner"
project: { name: "Test Project" }
project: { name: "Test Project" }
}, (error, {@user_id, @project_id}) => cb()
(cb) =>
FixturesManager.setUpDoc @project_id, {@lines, @version, @ops}, (e, {@doc_id}) =>
cb(e)
(cb) =>
@clientA = RealTimeClient.connect()
@clientA.on "connect", cb
@clientA.on "connectionAccepted", cb
(cb) =>
@clientB = RealTimeClient.connect()
@clientB.on "connect", cb
@clientB.on "connectionAccepted", cb
(cb) =>
@clientA.emit "joinProject", {
project_id: @project_id
}, cb
(cb) =>
@clientA.emit "joinDoc", @doc_id, cb
(cb) =>
@clientB.emit "joinProject", {
@ -45,7 +51,7 @@ describe "clientTracking", ->
@clientA.emit "clientTracking.updatePosition", {
row: @row = 42
column: @column = 36
doc_id: @doc_id = "mock-doc-id"
doc_id: @doc_id
}, (error) ->
throw error if error?
setTimeout cb, 300 # Give the message a chance to reach client B.
@ -85,9 +91,14 @@ describe "clientTracking", ->
publicAccess: "readAndWrite"
}, (error, {@user_id, @project_id}) => cb()
(cb) =>
FixturesManager.setUpDoc @project_id, {@lines, @version, @ops}, (e, {@doc_id}) =>
cb(e)
(cb) =>
@clientA = RealTimeClient.connect()
@clientA.on "connect", cb
@clientA.on "connectionAccepted", cb
(cb) =>
@clientA.emit "joinProject", {
project_id: @project_id
@ -98,12 +109,15 @@ describe "clientTracking", ->
(cb) =>
@anonymous = RealTimeClient.connect()
@anonymous.on "connect", cb
@anonymous.on "connectionAccepted", cb
(cb) =>
@anonymous.emit "joinProject", {
project_id: @project_id
}, cb
(cb) =>
@anonymous.emit "joinDoc", @doc_id, cb
(cb) =>
@updates = []
@ -113,7 +127,7 @@ describe "clientTracking", ->
@anonymous.emit "clientTracking.updatePosition", {
row: @row = 42
column: @column = 36
doc_id: @doc_id = "mock-doc-id"
doc_id: @doc_id
}, (error) ->
throw error if error?
setTimeout cb, 300 # Give the message a chance to reach client B.

View file

@ -83,8 +83,7 @@ describe "joinProject", ->
], done
it "should return an error", ->
# We don't return specific errors
@error.message.should.equal "Something went wrong"
@error.message.should.equal "not authorized"
it "should not have joined the project room", (done) ->
RealTimeClient.getConnectedClient @client.socket.sessionid, (error, client) =>