mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Add leaveDoc acceptance tests
This commit is contained in:
parent
0b18edeff3
commit
431abdc6eb
2 changed files with 62 additions and 1 deletions
|
@ -36,6 +36,11 @@ describe "joinDoc", ->
|
||||||
|
|
||||||
it "should return the doc lines, version and ops", ->
|
it "should return the doc lines, version and ops", ->
|
||||||
@returnedArgs.should.deep.equal [@lines, @version, @ops]
|
@returnedArgs.should.deep.equal [@lines, @version, @ops]
|
||||||
|
|
||||||
|
it "should have joined the doc room", (done) ->
|
||||||
|
RealTimeClient.getConnectedClient @client.socket.sessionid, (error, client) =>
|
||||||
|
expect(@doc_id in client.rooms).to.equal true
|
||||||
|
done()
|
||||||
|
|
||||||
describe "when authorised readOnly", ->
|
describe "when authorised readOnly", ->
|
||||||
before (done) ->
|
before (done) ->
|
||||||
|
@ -61,6 +66,11 @@ describe "joinDoc", ->
|
||||||
|
|
||||||
it "should return the doc lines, version and ops", ->
|
it "should return the doc lines, version and ops", ->
|
||||||
@returnedArgs.should.deep.equal [@lines, @version, @ops]
|
@returnedArgs.should.deep.equal [@lines, @version, @ops]
|
||||||
|
|
||||||
|
it "should have joined the doc room", (done) ->
|
||||||
|
RealTimeClient.getConnectedClient @client.socket.sessionid, (error, client) =>
|
||||||
|
expect(@doc_id in client.rooms).to.equal true
|
||||||
|
done()
|
||||||
|
|
||||||
describe "when authorised as owner", ->
|
describe "when authorised as owner", ->
|
||||||
before (done) ->
|
before (done) ->
|
||||||
|
@ -86,6 +96,11 @@ describe "joinDoc", ->
|
||||||
|
|
||||||
it "should return the doc lines, version and ops", ->
|
it "should return the doc lines, version and ops", ->
|
||||||
@returnedArgs.should.deep.equal [@lines, @version, @ops]
|
@returnedArgs.should.deep.equal [@lines, @version, @ops]
|
||||||
|
|
||||||
|
it "should have joined the doc room", (done) ->
|
||||||
|
RealTimeClient.getConnectedClient @client.socket.sessionid, (error, client) =>
|
||||||
|
expect(@doc_id in client.rooms).to.equal true
|
||||||
|
done()
|
||||||
|
|
||||||
# It is impossible to write an acceptance test to test joining an unauthorized
|
# It is impossible to write an acceptance test to test joining an unauthorized
|
||||||
# project, since joinProject already catches that. If you can join a project,
|
# project, since joinProject already catches that. If you can join a project,
|
||||||
|
@ -115,4 +130,9 @@ describe "joinDoc", ->
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
it "should return the doc lines, version and ops", ->
|
it "should return the doc lines, version and ops", ->
|
||||||
@returnedArgs.should.deep.equal [@lines, @version, @ops]
|
@returnedArgs.should.deep.equal [@lines, @version, @ops]
|
||||||
|
|
||||||
|
it "should have joined the doc room", (done) ->
|
||||||
|
RealTimeClient.getConnectedClient @client.socket.sessionid, (error, client) =>
|
||||||
|
expect(@doc_id in client.rooms).to.equal true
|
||||||
|
done()
|
|
@ -0,0 +1,41 @@
|
||||||
|
chai = require("chai")
|
||||||
|
expect = chai.expect
|
||||||
|
chai.should()
|
||||||
|
|
||||||
|
RealTimeClient = require "./helpers/RealTimeClient"
|
||||||
|
MockDocUpdaterServer = require "./helpers/MockDocUpdaterServer"
|
||||||
|
FixturesManager = require "./helpers/FixturesManager"
|
||||||
|
|
||||||
|
describe "leaveDoc", ->
|
||||||
|
before ->
|
||||||
|
@lines = ["test", "doc", "lines"]
|
||||||
|
@version = 42
|
||||||
|
@ops = ["mock", "doc", "ops"]
|
||||||
|
|
||||||
|
describe "when joined to a doc", ->
|
||||||
|
before (done) ->
|
||||||
|
FixturesManager.setUpProject {
|
||||||
|
privilegeLevel: "readAndWrite"
|
||||||
|
}, (error, data) =>
|
||||||
|
throw error if error?
|
||||||
|
{@project_id, @user_id} = data
|
||||||
|
FixturesManager.setUpDoc @project_id, {@lines, @version, @ops}, (error, data) =>
|
||||||
|
throw error if error?
|
||||||
|
{@doc_id} = data
|
||||||
|
@client = RealTimeClient.connect()
|
||||||
|
@client.emit "joinProject", project_id: @project_id, (error) =>
|
||||||
|
throw error if error?
|
||||||
|
@client.emit "joinDoc", @doc_id, (error, @returnedArgs...) =>
|
||||||
|
throw error if error?
|
||||||
|
done()
|
||||||
|
|
||||||
|
describe "then leaving the doc", ->
|
||||||
|
before (done) ->
|
||||||
|
@client.emit "leaveDoc", @doc_id, (error) ->
|
||||||
|
throw error if error?
|
||||||
|
done()
|
||||||
|
|
||||||
|
it "should have left the doc room", (done) ->
|
||||||
|
RealTimeClient.getConnectedClient @client.socket.sessionid, (error, client) =>
|
||||||
|
expect(@doc_id in client.rooms).to.equal false
|
||||||
|
done()
|
Loading…
Reference in a new issue