Revert "Revert "clear rootDoc_id when deleting doc, reset on compiles if invalid""
This reverts commit 7acba5876581044a08d6deb4767a4a2196dcb765. GitOrigin-RevId: 034ae6fa4d8515944683395ef14d99801829cb6a
This commit is contained in:
@@ -6,6 +6,7 @@ const fs = require('fs')
|
||||
const Settings = require('settings-sharelatex')
|
||||
const _ = require('underscore')
|
||||
|
||||
const { Project } = require('../../../app/src/models/Project')
|
||||
const ProjectGetter = require('../../../app/src/Features/Project/ProjectGetter.js')
|
||||
|
||||
const MockDocUpdaterApi = require('./helpers/MockDocUpdaterApi')
|
||||
@@ -1098,6 +1099,68 @@ describe('ProjectStructureChanges', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('deleting docs', function() {
|
||||
beforeEach(function(done) {
|
||||
createExampleProject(this, () => {
|
||||
createExampleFolder(this, () => {
|
||||
createExampleDoc(this, () => {
|
||||
MockDocUpdaterApi.clearProjectStructureUpdates()
|
||||
ProjectGetter.getProject(
|
||||
this.exampleProjectId,
|
||||
(error, project) => {
|
||||
if (error) {
|
||||
throw error
|
||||
}
|
||||
this.project0 = project
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('when rootDoc_id matches doc being deleted', () => {
|
||||
beforeEach(function(done) {
|
||||
Project.update({_id: this.exampleProjectId}, {$set: {rootDoc_id: this.exampleDocId}}, done)
|
||||
})
|
||||
|
||||
it('should clear rootDoc_id', function(done) {
|
||||
deleteItem(this, 'doc', this.exampleDocId, () => {
|
||||
ProjectGetter.getProject(
|
||||
this.exampleProjectId,
|
||||
(error, project) => {
|
||||
if (error) {
|
||||
throw error
|
||||
}
|
||||
expect(project.rootDoc_id).to.be.undefined
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('when rootDoc_id does not match doc being deleted', () => {
|
||||
beforeEach(function(done) {
|
||||
this.exampleRootDocId = new ObjectId()
|
||||
Project.update({_id: this.exampleProjectId}, {$set: {rootDoc_id: this.exampleRootDocId}}, done)
|
||||
})
|
||||
|
||||
it('should not clear rootDoc_id', function(done) {
|
||||
deleteItem(this, 'doc', this.exampleDocId, () => {
|
||||
ProjectGetter.getProject(
|
||||
this.exampleProjectId,
|
||||
(error, project) => {
|
||||
if (error) {
|
||||
throw error
|
||||
}
|
||||
expect(project.rootDoc_id.toString()).to.equal(this.exampleRootDocId.toString())
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('tpds', function() {
|
||||
let projectName, exampleProjectId, oldVersion, rootFolderId
|
||||
|
||||
|
||||
Reference in New Issue
Block a user