diff --git a/services/project-history/app/js/SnapshotManager.js b/services/project-history/app/js/SnapshotManager.js index f7d743864c..59b6ae867d 100644 --- a/services/project-history/app/js/SnapshotManager.js +++ b/services/project-history/app/js/SnapshotManager.js @@ -78,7 +78,7 @@ async function getRangesSnapshot(projectId, version, pathname) { const historyId = await WebApiManager.promises.getHistoryId(projectId) await file.load('eager', HistoryStoreManager.getBlobStore(historyId)) const content = file.getContent() - if (!content) { + if (content == null) { throw new Error('Unable to read file contents') } const trackedChanges = file.getTrackedChanges().asSorted() diff --git a/services/project-history/test/unit/js/SnapshotManager/SnapshotManagerTests.js b/services/project-history/test/unit/js/SnapshotManager/SnapshotManagerTests.js index 69891b604b..5055bd733a 100644 --- a/services/project-history/test/unit/js/SnapshotManager/SnapshotManagerTests.js +++ b/services/project-history/test/unit/js/SnapshotManager/SnapshotManagerTests.js @@ -978,5 +978,24 @@ Four five six\ }) }) }) + + describe('with an empty file', function () { + beforeEach(async function () { + this.getString.resolves('') + this.getObject.resolves({}) + this.data = await this.SnapshotManager.promises.getRangesSnapshot( + this.projectId, + 1, + 'main.tex' + ) + }) + + it('should return empty comments and changes', function () { + expect(this.data).to.deep.equal({ + changes: [], + comments: [], + }) + }) + }) }) })