Merge pull request #19263 from overleaf/mj-doc-updater-missing-ranges

[doc-updater] Allow resyncs on docs without ranges property

GitOrigin-RevId: b393e463036990ae18bb18aa93ed24c833a619ea
This commit is contained in:
Eric Mc Sween 2024-07-04 11:57:00 -04:00 committed by Copybot
parent 02cfb38a56
commit adf21125b7
2 changed files with 44 additions and 1 deletions

View file

@ -431,7 +431,7 @@ const DocumentManager = {
projectHistoryId,
docId,
lines,
ranges,
ranges ?? {},
resolvedCommentIds,
version,
// use the path from the resyncProjectStructure update

View file

@ -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)
})
})
})
})