|
@@ -9,46 +9,47 @@ FixturesManager = require "./helpers/FixturesManager"
|
|
|
async = require "async"
|
|
async = require "async"
|
|
|
|
|
|
|
|
describe "clientTracking", ->
|
|
describe "clientTracking", ->
|
|
|
- before (done) ->
|
|
|
|
|
- async.series [
|
|
|
|
|
- (cb) =>
|
|
|
|
|
- FixturesManager.setUpProject {
|
|
|
|
|
- privilegeLevel: "owner"
|
|
|
|
|
- project: { name: "Test Project" }
|
|
|
|
|
- }, (error, {@user_id, @project_id}) => cb()
|
|
|
|
|
-
|
|
|
|
|
- (cb) =>
|
|
|
|
|
- @clientA = RealTimeClient.connect()
|
|
|
|
|
- @clientA.on "connect", cb
|
|
|
|
|
-
|
|
|
|
|
- (cb) =>
|
|
|
|
|
- @clientB = RealTimeClient.connect()
|
|
|
|
|
- @clientB.on "connect", cb
|
|
|
|
|
-
|
|
|
|
|
- (cb) =>
|
|
|
|
|
- @clientA.emit "joinProject", {
|
|
|
|
|
- project_id: @project_id
|
|
|
|
|
- }, cb
|
|
|
|
|
-
|
|
|
|
|
- (cb) =>
|
|
|
|
|
- @clientB.emit "joinProject", {
|
|
|
|
|
- project_id: @project_id
|
|
|
|
|
- }, cb
|
|
|
|
|
- ], done
|
|
|
|
|
-
|
|
|
|
|
describe "when a client updates its cursor location", ->
|
|
describe "when a client updates its cursor location", ->
|
|
|
before (done) ->
|
|
before (done) ->
|
|
|
- @updates = []
|
|
|
|
|
- @clientB.on "clientTracking.clientUpdated", (data) =>
|
|
|
|
|
- @updates.push data
|
|
|
|
|
|
|
+ async.series [
|
|
|
|
|
+ (cb) =>
|
|
|
|
|
+ FixturesManager.setUpProject {
|
|
|
|
|
+ privilegeLevel: "owner"
|
|
|
|
|
+ project: { name: "Test Project" }
|
|
|
|
|
+ }, (error, {@user_id, @project_id}) => cb()
|
|
|
|
|
|
|
|
- @clientA.emit "clientTracking.updatePosition", {
|
|
|
|
|
- row: @row = 42
|
|
|
|
|
- column: @column = 36
|
|
|
|
|
- doc_id: @doc_id = "mock-doc-id"
|
|
|
|
|
- }, (error) ->
|
|
|
|
|
- throw error if error?
|
|
|
|
|
- setTimeout done, 300 # Give the message a chance to reach client B.
|
|
|
|
|
|
|
+ (cb) =>
|
|
|
|
|
+ @clientA = RealTimeClient.connect()
|
|
|
|
|
+ @clientA.on "connect", cb
|
|
|
|
|
+
|
|
|
|
|
+ (cb) =>
|
|
|
|
|
+ @clientB = RealTimeClient.connect()
|
|
|
|
|
+
|
|
|
|
|
+ @clientB.on "connect", cb
|
|
|
|
|
+
|
|
|
|
|
+ (cb) =>
|
|
|
|
|
+ @clientA.emit "joinProject", {
|
|
|
|
|
+ project_id: @project_id
|
|
|
|
|
+ }, cb
|
|
|
|
|
+
|
|
|
|
|
+ (cb) =>
|
|
|
|
|
+ @clientB.emit "joinProject", {
|
|
|
|
|
+ project_id: @project_id
|
|
|
|
|
+ }, cb
|
|
|
|
|
+
|
|
|
|
|
+ (cb) =>
|
|
|
|
|
+ @updates = []
|
|
|
|
|
+ @clientB.on "clientTracking.clientUpdated", (data) =>
|
|
|
|
|
+ @updates.push data
|
|
|
|
|
+
|
|
|
|
|
+ @clientA.emit "clientTracking.updatePosition", {
|
|
|
|
|
+ row: @row = 42
|
|
|
|
|
+ column: @column = 36
|
|
|
|
|
+ doc_id: @doc_id = "mock-doc-id"
|
|
|
|
|
+ }, (error) ->
|
|
|
|
|
+ throw error if error?
|
|
|
|
|
+ setTimeout cb, 300 # Give the message a chance to reach client B.
|
|
|
|
|
+ ], done
|
|
|
|
|
|
|
|
it "should tell other clients about the update", ->
|
|
it "should tell other clients about the update", ->
|
|
|
@updates.should.deep.equal [
|
|
@updates.should.deep.equal [
|
|
@@ -74,6 +75,58 @@ describe "clientTracking", ->
|
|
|
return done()
|
|
return done()
|
|
|
throw new Error("user was never found")
|
|
throw new Error("user was never found")
|
|
|
|
|
|
|
|
|
|
+ describe "when an anonymous client updates its cursor location", ->
|
|
|
|
|
+ before (done) ->
|
|
|
|
|
+ async.series [
|
|
|
|
|
+ (cb) =>
|
|
|
|
|
+ FixturesManager.setUpProject {
|
|
|
|
|
+ privilegeLevel: "owner"
|
|
|
|
|
+ project: { name: "Test Project" }
|
|
|
|
|
+ publicAccess: "readAndWrite"
|
|
|
|
|
+ }, (error, {@user_id, @project_id}) => cb()
|
|
|
|
|
|
|
|
- describe "anonymous users", ->
|
|
|
|
|
- it "should test something..."
|
|
|
|
|
|
|
+ (cb) =>
|
|
|
|
|
+ @clientA = RealTimeClient.connect()
|
|
|
|
|
+ @clientA.on "connect", cb
|
|
|
|
|
+ (cb) =>
|
|
|
|
|
+ @clientA.emit "joinProject", {
|
|
|
|
|
+ project_id: @project_id
|
|
|
|
|
+ }, cb
|
|
|
|
|
+
|
|
|
|
|
+ (cb) =>
|
|
|
|
|
+ RealTimeClient.setSession({}, cb)
|
|
|
|
|
+
|
|
|
|
|
+ (cb) =>
|
|
|
|
|
+ @anonymous = RealTimeClient.connect()
|
|
|
|
|
+ @anonymous.on "connect", cb
|
|
|
|
|
+
|
|
|
|
|
+ (cb) =>
|
|
|
|
|
+ @anonymous.emit "joinProject", {
|
|
|
|
|
+ project_id: @project_id
|
|
|
|
|
+ }, cb
|
|
|
|
|
+
|
|
|
|
|
+ (cb) =>
|
|
|
|
|
+ @updates = []
|
|
|
|
|
+ @clientA.on "clientTracking.clientUpdated", (data) =>
|
|
|
|
|
+ @updates.push data
|
|
|
|
|
+
|
|
|
|
|
+ @anonymous.emit "clientTracking.updatePosition", {
|
|
|
|
|
+ row: @row = 42
|
|
|
|
|
+ column: @column = 36
|
|
|
|
|
+ doc_id: @doc_id = "mock-doc-id"
|
|
|
|
|
+ }, (error) ->
|
|
|
|
|
+ throw error if error?
|
|
|
|
|
+ setTimeout cb, 300 # Give the message a chance to reach client B.
|
|
|
|
|
+ ], done
|
|
|
|
|
+
|
|
|
|
|
+ it "should tell other clients about the update", ->
|
|
|
|
|
+ @updates.should.deep.equal [
|
|
|
|
|
+ {
|
|
|
|
|
+ row: @row
|
|
|
|
|
+ column: @column
|
|
|
|
|
+ doc_id: @doc_id
|
|
|
|
|
+ id: @anonymous.socket.sessionid
|
|
|
|
|
+ user_id: "anonymous-user"
|
|
|
|
|
+ name: "Anonymous"
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|