Record project notification timestamp in Redis on applyUpdate (#29509)

* Record project notification timestamp in Redis on applyUpdate

* Refactor project notification timestamp recording in Redis

* Remove tests which are catching errors that are no longer used

GitOrigin-RevId: faa7a97fa929941cade5d62d2d680c6c3f34cdc8
This commit is contained in:
Domagoj Kriskovic
2026-01-12 09:06:07 +00:00
committed by Copybot
parent 239e89a0a8
commit 8bca2545ee
5 changed files with 111 additions and 0 deletions
@@ -35,6 +35,7 @@ describe('UpdateManager', function () {
promises: {
setDocument: sinon.stub().resolves(),
updateDocument: sinon.stub(),
recordProjectNotificationTimestamp: sinon.stub().resolves(),
},
}
@@ -416,6 +417,55 @@ describe('UpdateManager', function () {
this.historyUpdates.length
)
})
it('should record the project notification timestamp', function () {
this.RedisManager.promises.recordProjectNotificationTimestamp.should.have.been.calledWith(
this.project_id,
sinon.match.number
)
})
})
describe('when update has a timestamp in meta', function () {
beforeEach(async function () {
this.timestamp = 1234567890
this.update = {
op: [{ p: 42, i: 'foo' }],
meta: { ...this.updateMeta, ts: this.timestamp },
}
await this.UpdateManager.promises.applyUpdate(
this.project_id,
this.doc_id,
this.update
)
})
it('should record the project notification timestamp with the provided timestamp', function () {
this.RedisManager.promises.recordProjectNotificationTimestamp.should.have.been.calledWith(
this.project_id,
this.timestamp
)
})
})
describe('when there are no history updates', function () {
beforeEach(async function () {
this.RangesManager.applyUpdate.returns({
newRanges: this.updated_ranges,
rangesWereCollapsed: false,
historyUpdates: [],
})
await this.UpdateManager.promises.applyUpdate(
this.project_id,
this.doc_id,
this.update
)
})
it('should not record the project notification timestamp', function () {
this.RedisManager.promises.recordProjectNotificationTimestamp.should.not
.have.been.called
})
})
describe('with UTF-16 surrogate pairs in the update', function () {