mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
acceptance test versioning entity deletions
This commit is contained in:
parent
475e84b039
commit
99a52d48c8
3 changed files with 43 additions and 2 deletions
|
@ -261,12 +261,12 @@ describe "ProjectStructureChanges", ->
|
|||
name: 'bar'
|
||||
}, (error, res, body) =>
|
||||
throw error if error?
|
||||
example_folder_id_2 = JSON.parse(body)._id
|
||||
@example_folder_id_2 = JSON.parse(body)._id
|
||||
|
||||
@owner.request.post {
|
||||
uri: "project/#{@example_project_id}/Folder/#{@example_folder_id_1}/move",
|
||||
json:
|
||||
folder_id: example_folder_id_2
|
||||
folder_id: @example_folder_id_2
|
||||
}, (error, res, body) =>
|
||||
throw error if error?
|
||||
if res.statusCode < 200 || res.statusCode >= 300
|
||||
|
@ -288,6 +288,34 @@ describe "ProjectStructureChanges", ->
|
|||
|
||||
done()
|
||||
|
||||
describe "deleting entities", ->
|
||||
beforeEach () ->
|
||||
MockDocUpdaterApi.clearProjectStructureUpdates()
|
||||
|
||||
it "should version deleting a folder", (done) ->
|
||||
@owner.request.delete {
|
||||
uri: "project/#{@example_project_id}/Folder/#{@example_folder_id_2}",
|
||||
}, (error, res, body) =>
|
||||
throw error if error?
|
||||
if res.statusCode < 200 || res.statusCode >= 300
|
||||
throw new Error("failed to delete folder #{res.statusCode}")
|
||||
|
||||
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).docUpdates
|
||||
expect(updates.length).to.equal(1)
|
||||
update = updates[0]
|
||||
#expect(update.userId).to.equal(@owner._id)
|
||||
expect(update.pathname).to.equal("/bar/foo/new.tex")
|
||||
expect(update.newPathname).to.equal("")
|
||||
|
||||
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).fileUpdates
|
||||
expect(updates.length).to.equal(1)
|
||||
update = updates[0]
|
||||
#expect(update.userId).to.equal(@owner._id)
|
||||
expect(update.pathname).to.equal("/bar/foo/1pixel.png")
|
||||
expect(update.newPathname).to.equal("")
|
||||
|
||||
done()
|
||||
|
||||
describe "tpds", ->
|
||||
before (done) ->
|
||||
@tpds_project_name = "tpds-project-#{new ObjectId().toString()}"
|
||||
|
|
|
@ -33,6 +33,9 @@ module.exports = MockDocUpdaterApi =
|
|||
@addProjectStructureUpdates(project_id, userId, docUpdates, fileUpdates)
|
||||
res.sendStatus 200
|
||||
|
||||
app.delete "/project/:project_id/doc/:doc_id", (req, res, next) =>
|
||||
res.send 204
|
||||
|
||||
app.listen 3003, (error) ->
|
||||
throw error if error?
|
||||
.on "error", (error) ->
|
||||
|
|
|
@ -23,6 +23,16 @@ module.exports = MockDocStoreApi =
|
|||
docs = (doc for doc_id, doc of @docs[req.params.project_id])
|
||||
res.send JSON.stringify docs
|
||||
|
||||
app.delete "/project/:project_id/doc/:doc_id", (req, res, next) =>
|
||||
{project_id, doc_id} = req.params
|
||||
if !@docs[project_id]?
|
||||
res.send 404
|
||||
else if !@docs[project_id][doc_id]?
|
||||
res.send 404
|
||||
else
|
||||
@docs[project_id][doc_id] = undefined
|
||||
res.send 204
|
||||
|
||||
app.listen 3016, (error) ->
|
||||
throw error if error?
|
||||
.on "error", (error) ->
|
||||
|
|
Loading…
Reference in a new issue