From 109d14f9b47ac3f0864823c654d14256413e97c2 Mon Sep 17 00:00:00 2001 From: Eric Mc Sween <5454374+emcsween@users.noreply.github.com> Date: Thu, 4 Jul 2024 11:57:00 -0400 Subject: [PATCH] Merge pull request #19263 from overleaf/mj-doc-updater-missing-ranges [doc-updater] Allow resyncs on docs without ranges property GitOrigin-RevId: b393e463036990ae18bb18aa93ed24c833a619ea --- .../app/js/DocumentManager.js | 2 +- .../DocumentManager/DocumentManagerTests.js | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) 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) + }) + }) }) })