mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Turn a unit test into an acceptance test
This commit is contained in:
parent
bdaa2ffa77
commit
772ee4083a
1 changed files with 11 additions and 23 deletions
|
@ -4,11 +4,8 @@ chai.should()
|
|||
Settings = require('settings-sharelatex')
|
||||
rclient_history = require("redis-sharelatex").createClient(Settings.redis.history)
|
||||
ProjectHistoryKeys = Settings.redis.project_history.key_schema
|
||||
SandboxedModule = require('sandboxed-module')
|
||||
HistoryManagerModulePath = require('path').join __dirname, '../../../app/js/HistoryManager.js'
|
||||
ProjectManagerModulePath = require('path').join __dirname, '../../../app/js/ProjectManager.js'
|
||||
RedisManagerModulePath = require('path').join __dirname, '../../../app/js/RedisManager.js'
|
||||
|
||||
MockProjectHistoryApi = require "./helpers/MockProjectHistoryApi"
|
||||
MockWebApi = require "./helpers/MockWebApi"
|
||||
DocUpdaterClient = require "./helpers/DocUpdaterClient"
|
||||
|
||||
|
@ -153,22 +150,6 @@ describe "Applying updates to a project's structure", ->
|
|||
|
||||
describe "with enough updates to flush to the history service", ->
|
||||
before (done) ->
|
||||
@RedisManager = SandboxedModule.require RedisManagerModulePath, requires:
|
||||
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() }
|
||||
@HistoryManager = SandboxedModule.require HistoryManagerModulePath, requires:
|
||||
"request": {}
|
||||
"settings-sharelatex": {}
|
||||
"logger-sharelatex": @logger
|
||||
"./HistoryRedisManager": {}
|
||||
@HistoryManager.flushProjectChangesAsync = sinon.stub()
|
||||
@ProjectManager = SandboxedModule.require ProjectManagerModulePath, requires:
|
||||
'./HistoryManager': @HistoryManager
|
||||
'logger-sharelatex' : @logger
|
||||
'./Metrics': @Metrics = {}
|
||||
'./RedisManager': @RedisManager
|
||||
@Metrics.Timer = class Timer
|
||||
done: sinon.stub()
|
||||
|
||||
@project_id = DocUpdaterClient.randomId()
|
||||
@user_id = DocUpdaterClient.randomId()
|
||||
|
||||
|
@ -179,12 +160,19 @@ describe "Applying updates to a project's structure", ->
|
|||
pathname: '/file-' + v
|
||||
docLines: 'a\nb'
|
||||
|
||||
sinon.spy MockProjectHistoryApi, "flushProject"
|
||||
|
||||
# Send updates in chunks to causes multiple flushes
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @user_id, updates.slice(0, 250), [], (error) =>
|
||||
projectId = @project_id
|
||||
userId = @project_id
|
||||
DocUpdaterClient.sendProjectUpdate projectId, userId, updates.slice(0, 250), [], (error) ->
|
||||
throw error if error?
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @user_id, updates.slice(250), [], (error) =>
|
||||
DocUpdaterClient.sendProjectUpdate projectId, userId, updates.slice(250), [], (error) ->
|
||||
throw error if error?
|
||||
setTimeout done, 2000
|
||||
|
||||
after ->
|
||||
MockProjectHistoryApi.flushProject.restore()
|
||||
|
||||
it "should flush project history", ->
|
||||
@HistoryManager.flushProjectChangesAsync.calledWith(@project_id).should.equal true
|
||||
MockProjectHistoryApi.flushProject.calledWith(@project_id).should.equal true
|
||||
|
|
Loading…
Reference in a new issue