mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-07 16:19:02 +02:00
Merge pull request #24125 from overleaf/rh-current-version-fix
Fix version check for undefined split tests GitOrigin-RevId: bbbd44a27ca41c5ffac02cb34ac0049a14cd13e4
This commit is contained in:
@@ -150,6 +150,14 @@ async function hasUserBeenAssignedToVariant(
|
||||
const splitTest = await _getSplitTest(splitTestName)
|
||||
const currentVersion = SplitTestUtils.getCurrentVersion(splitTest)
|
||||
|
||||
if (
|
||||
!userId ||
|
||||
!SessionManager.isUserLoggedIn(session) ||
|
||||
!currentVersion?.active
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check the query string for an override, ignoring an invalid value
|
||||
const queryVariant = query[splitTestName]
|
||||
if (queryVariant === variant) {
|
||||
|
||||
@@ -55,12 +55,17 @@ describe('SplitTestHandler', function () {
|
||||
}
|
||||
this.SplitTestSessionHandler = {
|
||||
collectSessionStats: sinon.stub(),
|
||||
getCachedVariant: sinon.stub(),
|
||||
setVariantInCache: sinon.stub(),
|
||||
}
|
||||
this.SplitTestUserGetter = {
|
||||
promises: {
|
||||
getUser: sinon.stub().resolves(null),
|
||||
},
|
||||
}
|
||||
this.SessionManager = {
|
||||
isUserLoggedIn: sinon.stub().returns(false),
|
||||
}
|
||||
|
||||
this.SplitTestHandler = SandboxedModule.require(MODULE_PATH, {
|
||||
requires: {
|
||||
@@ -72,6 +77,7 @@ describe('SplitTestHandler', function () {
|
||||
'./LocalsHelper': this.LocalsHelper,
|
||||
'./SplitTestSessionHandler': this.SplitTestSessionHandler,
|
||||
'./SplitTestUserGetter': this.SplitTestUserGetter,
|
||||
'../Authentication/SessionManager': this.SessionManager,
|
||||
'@overleaf/settings': this.Settings,
|
||||
},
|
||||
})
|
||||
@@ -105,6 +111,7 @@ describe('SplitTestHandler', function () {
|
||||
},
|
||||
}
|
||||
this.SplitTestUserGetter.promises.getUser.resolves(this.user)
|
||||
this.SessionManager.isUserLoggedIn.returns(true)
|
||||
this.assignments =
|
||||
await this.SplitTestHandler.promises.getActiveAssignmentsForUser(
|
||||
this.user._id
|
||||
|
||||
Reference in New Issue
Block a user