Merge pull request #14803 from overleaf/jpa-split-test-cache-alpha-beta

[web] invalidate split test cache when alpha/beta program status changes

GitOrigin-RevId: 3023d2adf8466b48490c51497f5c80e7b0a1fe3d
This commit is contained in:
Jakob Ackermann
2023-09-13 13:07:00 +02:00
committed by Copybot
parent 7d3c8fb78d
commit 1e4dcc84d9
8 changed files with 99 additions and 3 deletions

View File

@@ -21,8 +21,12 @@ describe('BetaProgramController', function () {
user: this.user,
},
}
this.SplitTestHandler = {
sessionMaintenance: sinon.stub().yields(),
}
this.BetaProgramController = SandboxedModule.require(modulePath, {
requires: {
'../SplitTests/SplitTestHandler': this.SplitTestHandler,
'./BetaProgramHandler': (this.BetaProgramHandler = {
optIn: sinon.stub(),
optOut: sinon.stub(),
@@ -68,6 +72,13 @@ describe('BetaProgramController', function () {
this.BetaProgramHandler.optIn.callCount.should.equal(1)
})
it('should invoke the session maintenance', function () {
this.BetaProgramController.optIn(this.req, this.res, this.next)
this.SplitTestHandler.sessionMaintenance.should.have.been.calledWith(
this.req
)
})
describe('when BetaProgramHandler.opIn produces an error', function () {
beforeEach(function () {
this.BetaProgramHandler.optIn.callsArgWith(1, new Error('woops'))
@@ -107,6 +118,13 @@ describe('BetaProgramController', function () {
this.BetaProgramHandler.optOut.callCount.should.equal(1)
})
it('should invoke the session maintenance', function () {
this.BetaProgramController.optOut(this.req, this.res, this.next)
this.SplitTestHandler.sessionMaintenance.should.have.been.calledWith(
this.req
)
})
describe('when BetaProgramHandler.optOut produces an error', function () {
beforeEach(function () {
this.BetaProgramHandler.optOut.callsArgWith(1, new Error('woops'))