From d0e56e505441487cbd475579815ce51a7b99ef75 Mon Sep 17 00:00:00 2001 From: Hayden Faulds Date: Fri, 10 Nov 2017 15:01:37 +0000 Subject: [PATCH] add acceptance tests for entity additions --- ...lyingUpdatesToProjectStructureTests.coffee | 57 ++++++++++++++++++- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToProjectStructureTests.coffee b/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToProjectStructureTests.coffee index 21657793a8..5526a0b40f 100644 --- a/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToProjectStructureTests.coffee +++ b/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToProjectStructureTests.coffee @@ -24,7 +24,7 @@ describe "Applying updates to a project's structure", -> throw error if error? setTimeout done, 200 - it "should push the applied file renames to the project history changes api", (done) -> + it "should push the applied file renames to the project history api", (done) -> rclient_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => throw error if error? @@ -52,7 +52,7 @@ describe "Applying updates to a project's structure", -> throw error if error? setTimeout done, 200 - it "should push the applied doc renames to the project history changes api", (done) -> + it "should push the applied doc renames to the project history api", (done) -> rclient_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => throw error if error? @@ -84,7 +84,7 @@ describe "Applying updates to a project's structure", -> doc.pathname.should.equal @docUpdate.newPathname done() - it "should push the applied doc renames to the project history changes api", (done) -> + it "should push the applied doc renames to the project history api", (done) -> rclient_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => throw error if error? @@ -96,3 +96,54 @@ describe "Applying updates to a project's structure", -> update.meta.ts.should.be.a('string') done() + + describe "adding a file", -> + before (done) -> + @project_id = DocUpdaterClient.randomId() + @fileUpdate = + id: DocUpdaterClient.randomId() + pathname: '/file-path' + url: 'filestore.example.com' + @fileUpdates = [ @fileUpdate ] + DocUpdaterClient.sendProjectUpdate @project_id, @user_id, [], @fileUpdates, (error) -> + throw error if error? + setTimeout done, 200 + + it "should push the file addition to the project history api", (done) -> + rclient_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => + throw error if error? + + update = JSON.parse(updates[0]) + update.file.should.equal @fileUpdate.id + update.pathname.should.equal '/file-path' + update.url.should.equal 'filestore.example.com' + update.meta.user_id.should.equal @user_id + update.meta.ts.should.be.a('string') + + done() + + describe "adding a doc", -> + before (done) -> + @project_id = DocUpdaterClient.randomId() + @docUpdate = + id: DocUpdaterClient.randomId() + pathname: '/file-path' + docLines: 'a\nb' + @docUpdates = [ @docUpdate ] + DocUpdaterClient.sendProjectUpdate @project_id, @user_id, @docUpdates, [], (error) -> + throw error if error? + setTimeout done, 200 + + it "should push the doc addition to the project history api", (done) -> + rclient_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => + throw error if error? + + update = JSON.parse(updates[0]) + update.doc.should.equal @docUpdate.id + update.pathname.should.equal '/file-path' + update.docLines.should.equal 'a\nb' + update.meta.user_id.should.equal @user_id + update.meta.ts.should.be.a('string') + + done() +