|
|
@@ -74,6 +74,12 @@ describe('UpdateManager', function () {
|
|
|
},
|
|
|
}
|
|
|
|
|
|
+ this.WebApiManager = {
|
|
|
+ promises: {
|
|
|
+ notifyTrackChangesRejected: sinon.stub().resolves(),
|
|
|
+ },
|
|
|
+ }
|
|
|
+
|
|
|
this.ProjectHistoryRedisManager = {
|
|
|
promises: {
|
|
|
queueOps: sinon
|
|
|
@@ -94,6 +100,7 @@ describe('UpdateManager', function () {
|
|
|
'./DocumentManager': this.DocumentManager,
|
|
|
'./RangesManager': this.RangesManager,
|
|
|
'./SnapshotManager': this.SnapshotManager,
|
|
|
+ './WebApiManager': this.WebApiManager,
|
|
|
'./Profiler': this.Profiler,
|
|
|
'./ProjectHistoryRedisManager': this.ProjectHistoryRedisManager,
|
|
|
},
|
|
|
@@ -337,6 +344,7 @@ describe('UpdateManager', function () {
|
|
|
newRanges: this.updated_ranges,
|
|
|
rangesWereCollapsed: false,
|
|
|
historyUpdates: this.historyUpdates,
|
|
|
+ removedChangeIds: [],
|
|
|
})
|
|
|
this.ShareJsUpdateManager.promises.applyUpdate = sinon.stub().resolves({
|
|
|
updatedDocLines: this.updatedDocLines,
|
|
|
@@ -468,6 +476,7 @@ describe('UpdateManager', function () {
|
|
|
newRanges: this.updated_ranges,
|
|
|
rangesWereCollapsed: true,
|
|
|
historyUpdates: this.historyUpdates,
|
|
|
+ removedChangeIds: [],
|
|
|
})
|
|
|
await this.UpdateManager.promises.applyUpdate(
|
|
|
this.project_id,
|
|
|
@@ -524,6 +533,48 @@ describe('UpdateManager', function () {
|
|
|
)
|
|
|
})
|
|
|
})
|
|
|
+
|
|
|
+ describe('when tracked changes are rejected', function () {
|
|
|
+ beforeEach(async function () {
|
|
|
+ this.removedChangeIds = ['change-1', 'change-2']
|
|
|
+ this.RangesManager.applyUpdate.returns({
|
|
|
+ newRanges: this.updated_ranges,
|
|
|
+ rangesWereCollapsed: false,
|
|
|
+ historyUpdates: this.historyUpdates,
|
|
|
+ removedChangeIds: this.removedChangeIds,
|
|
|
+ })
|
|
|
+ await this.UpdateManager.promises.applyUpdate(
|
|
|
+ this.project_id,
|
|
|
+ this.doc_id,
|
|
|
+ this.update
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
+ it('should notify web of the rejected tracked changes', function () {
|
|
|
+ this.WebApiManager.promises.notifyTrackChangesRejected.should.have.been.calledWith(
|
|
|
+ this.project_id,
|
|
|
+ this.doc_id,
|
|
|
+ this.removedChangeIds,
|
|
|
+ this.updateMeta.user_id
|
|
|
+ )
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ describe('when no tracked changes are rejected', function () {
|
|
|
+ beforeEach(async function () {
|
|
|
+ await this.UpdateManager.promises.applyUpdate(
|
|
|
+ this.project_id,
|
|
|
+ this.doc_id,
|
|
|
+ this.update
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
+ it('should not notify web', function () {
|
|
|
+ this.WebApiManager.promises.notifyTrackChangesRejected.called.should.equal(
|
|
|
+ false
|
|
|
+ )
|
|
|
+ })
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
describe('_adjustHistoryUpdatesMetadata', function () {
|