diff --git a/services/document-updater/app/js/DocumentManager.js b/services/document-updater/app/js/DocumentManager.js index 0f50920196..157a99ccf6 100644 --- a/services/document-updater/app/js/DocumentManager.js +++ b/services/document-updater/app/js/DocumentManager.js @@ -431,7 +431,7 @@ const DocumentManager = { projectHistoryId, docId, lines, - ranges, + ranges ?? {}, resolvedCommentIds, version, // use the path from the resyncProjectStructure update diff --git a/services/document-updater/test/unit/js/DocumentManager/DocumentManagerTests.js b/services/document-updater/test/unit/js/DocumentManager/DocumentManagerTests.js index 58e4aca9e7..a0c379a5be 100644 --- a/services/document-updater/test/unit/js/DocumentManager/DocumentManagerTests.js +++ b/services/document-updater/test/unit/js/DocumentManager/DocumentManagerTests.js @@ -1085,5 +1085,48 @@ describe('DocumentManager', function () { .should.equal(true) }) }) + + describe('when a doc has no ranges in docstore', function () { + beforeEach(async function () { + this.pathnameFromProjectStructureUpdate = '/foo/bar.tex' + this.RedisManager.promises.getDoc.resolves({}) + this.PersistenceManager.promises.getDoc.resolves({ + lines: this.lines, + version: this.version, + ranges: undefined, + resolvedCommentIds: [], + pathname: this.pathname, + projectHistoryId: this.projectHistoryId, + historyRangesSupport: this.historyRangesSupport, + }) + await this.DocumentManager.promises.resyncDocContents( + this.project_id, + this.doc_id, + this.pathnameFromProjectStructureUpdate + ) + }) + + it('gets the doc contents from web', function () { + this.PersistenceManager.promises.getDoc + .calledWith(this.project_id, this.doc_id, { peek: true }) + .should.equal(true) + }) + + it('queues a resync doc content update with an empty ranges object', function () { + this.ProjectHistoryRedisManager.promises.queueResyncDocContent + .calledWith( + this.project_id, + this.projectHistoryId, + this.doc_id, + this.lines, + {}, + [], + this.version, + this.pathnameFromProjectStructureUpdate, + this.historyRangesSupport + ) + .should.equal(true) + }) + }) }) })